@@ -47,13 +47,14 @@ use rustc_data_structures::stable_hasher::{HashStable, StableHasher};
4747use rustc_data_structures:: sync:: spawn;
4848use rustc_data_structures:: tagged_ptr:: TaggedRef ;
4949use rustc_errors:: { DiagArgFromDisplay , DiagCtxtHandle } ;
50+ use rustc_hir:: attrs:: AttributeKind ;
5051use rustc_hir:: def:: { DefKind , LifetimeRes , Namespace , PartialRes , PerNS , Res } ;
5152use rustc_hir:: def_id:: { CRATE_DEF_ID , LOCAL_CRATE , LocalDefId } ;
5253use rustc_hir:: definitions:: { DefPathData , DisambiguatorState } ;
5354use rustc_hir:: lints:: DelayedLint ;
5455use 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} ;
5859use rustc_index:: { Idx , IndexSlice , IndexVec } ;
5960use rustc_macros:: extension;
@@ -236,7 +237,7 @@ impl SpanLowerer {
236237
237238#[ extension( trait ResolverAstLoweringExt ) ]
238239impl 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 > {
0 commit comments