Skip to content

Commit 8fcddc6

Browse files
committed
remove legacy_const_generic_args cache
1 parent f2c7087 commit 8fcddc6

File tree

4 files changed

+14
-18
lines changed

4 files changed

+14
-18
lines changed

compiler/rustc_ast_lowering/src/expr.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,8 @@ impl<'hir> LoweringContext<'_, 'hir> {
114114
}
115115
ExprKind::Tup(elts) => hir::ExprKind::Tup(self.lower_exprs(elts)),
116116
ExprKind::Call(f, args) => {
117-
if let Some(legacy_args) = self.resolver.legacy_const_generic_args(f) {
117+
if let Some(legacy_args) = self.resolver.legacy_const_generic_args(f, self.tcx)
118+
{
118119
self.lower_legacy_const_generics((**f).clone(), args.clone(), &legacy_args)
119120
} else {
120121
let f = self.lower_expr(f);

compiler/rustc_ast_lowering/src/lib.rs

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -47,13 +47,14 @@ use rustc_data_structures::stable_hasher::{HashStable, StableHasher};
4747
use rustc_data_structures::sync::spawn;
4848
use rustc_data_structures::tagged_ptr::TaggedRef;
4949
use rustc_errors::{DiagArgFromDisplay, DiagCtxtHandle};
50+
use rustc_hir::attrs::AttributeKind;
5051
use rustc_hir::def::{DefKind, LifetimeRes, Namespace, PartialRes, PerNS, Res};
5152
use rustc_hir::def_id::{CRATE_DEF_ID, LOCAL_CRATE, LocalDefId};
5253
use rustc_hir::definitions::{DefPathData, DisambiguatorState};
5354
use rustc_hir::lints::DelayedLint;
5455
use rustc_hir::{
5556
self as hir, AngleBrackets, ConstArg, GenericArg, HirId, ItemLocalMap, LifetimeSource,
56-
LifetimeSyntax, ParamName, Target, TraitCandidate,
57+
LifetimeSyntax, ParamName, Target, TraitCandidate, find_attr,
5758
};
5859
use rustc_index::{Idx, IndexSlice, IndexVec};
5960
use rustc_macros::extension;
@@ -236,7 +237,7 @@ impl SpanLowerer {
236237

237238
#[extension(trait ResolverAstLoweringExt)]
238239
impl ResolverAstLowering {
239-
fn legacy_const_generic_args(&self, expr: &Expr) -> Option<Vec<usize>> {
240+
fn legacy_const_generic_args(&self, expr: &Expr, tcx: TyCtxt<'_>) -> Option<Vec<usize>> {
240241
let ExprKind::Path(None, path) = &expr.kind else {
241242
return None;
242243
};
@@ -256,11 +257,12 @@ impl ResolverAstLowering {
256257
return None;
257258
}
258259

259-
if let Some(v) = self.legacy_const_generic_args.get(&def_id) {
260-
return v.clone();
261-
}
262-
263-
None
260+
find_attr!(
261+
// we can use parsed attrs here since for other crates they're already available
262+
tcx.get_all_attrs(def_id),
263+
AttributeKind::RustcLegacyConstGenerics{fn_indexes,..} => fn_indexes
264+
)
265+
.map(|fn_indexes| fn_indexes.iter().map(|(num, _)| *num).collect())
264266
}
265267

266268
fn get_partial_res(&self, id: NodeId) -> Option<PartialRes> {

compiler/rustc_middle/src/ty/mod.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ use rustc_ast::AttrVec;
3131
use rustc_ast::expand::typetree::{FncTree, Kind, Type, TypeTree};
3232
use rustc_ast::node_id::NodeMap;
3333
pub use rustc_ast_ir::{Movability, Mutability, try_visit};
34-
use rustc_data_structures::fx::{FxHashMap, FxHashSet, FxIndexMap, FxIndexSet};
34+
use rustc_data_structures::fx::{FxHashSet, FxIndexMap, FxIndexSet};
3535
use rustc_data_structures::intern::Interned;
3636
use rustc_data_structures::stable_hasher::{HashStable, StableHasher};
3737
use rustc_data_structures::steal::Steal;
@@ -196,7 +196,6 @@ pub struct ResolverGlobalCtxt {
196196
/// This struct is meant to be consumed by lowering.
197197
#[derive(Debug)]
198198
pub struct ResolverAstLowering {
199-
pub legacy_const_generic_args: FxHashMap<DefId, Option<Vec<usize>>>,
200199
/// Resolutions for nodes that have a single resolution.
201200
pub partial_res_map: NodeMap<hir::def::PartialRes>,
202201
/// Resolutions for import nodes, which have multiple resolutions in different namespaces.

compiler/rustc_resolve/src/lib.rs

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1271,7 +1271,6 @@ pub struct Resolver<'ra, 'tcx> {
12711271
/// and how the `impl Trait` fragments were introduced.
12721272
invocation_parents: FxHashMap<LocalExpnId, InvocationParent>,
12731273

1274-
legacy_const_generic_args: FxHashMap<DefId, Option<Vec<usize>>>,
12751274
/// Amount of lifetime parameters for each item in the crate.
12761275
item_generics_num_lifetimes: FxHashMap<LocalDefId, usize>,
12771276
delegation_fn_sigs: LocalDefIdMap<DelegationFnSig>,
@@ -1675,7 +1674,6 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
16751674
node_id_to_def_id,
16761675
disambiguator: DisambiguatorState::new(),
16771676
placeholder_field_indices: Default::default(),
1678-
legacy_const_generic_args: Default::default(),
16791677
invocation_parents,
16801678
item_generics_num_lifetimes: Default::default(),
16811679
trait_impls: Default::default(),
@@ -1805,7 +1803,6 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
18051803
stripped_cfg_items,
18061804
};
18071805
let ast_lowering = ty::ResolverAstLowering {
1808-
legacy_const_generic_args: self.legacy_const_generic_args,
18091806
partial_res_map: self.partial_res_map,
18101807
import_res_map: self.import_res_map,
18111808
label_res_map: self.label_res_map,
@@ -2413,15 +2410,12 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
24132410
return None;
24142411
}
24152412

2416-
let indexes = find_attr!(
2413+
find_attr!(
24172414
// we can use parsed attrs here since for other crates they're already available
24182415
self.tcx.get_all_attrs(def_id),
24192416
AttributeKind::RustcLegacyConstGenerics{fn_indexes,..} => fn_indexes
24202417
)
2421-
.map(|fn_indexes| fn_indexes.iter().map(|(num, _)| *num).collect());
2422-
2423-
self.legacy_const_generic_args.insert(def_id, indexes.clone());
2424-
indexes
2418+
.map(|fn_indexes| fn_indexes.iter().map(|(num, _)| *num).collect())
24252419
}
24262420

24272421
fn resolve_main(&mut self) {

0 commit comments

Comments
 (0)