@@ -1172,7 +1172,14 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
11721172 }
11731173
11741174 fn lower_anon_const_as_const_arg ( & mut self , anon : & AnonConst ) -> hir:: ConstArg < ' hir > {
1175- if let ExprKind :: Path ( qself, path) = & anon. value . kind {
1175+ if let ExprKind :: Path ( qself, path) = & anon. value . kind
1176+ && let Some ( res) = self
1177+ . resolver
1178+ . get_partial_res ( anon. id )
1179+ . and_then ( |partial_res| partial_res. full_res ( ) )
1180+ // FIXME(min_generic_const_exprs): for now we only lower params to ConstArgKind::Path
1181+ && let Res :: Def ( DefKind :: ConstParam , _) = res
1182+ {
11761183 let qpath = self . lower_qpath (
11771184 anon. id ,
11781185 qself,
@@ -1181,18 +1188,11 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
11811188 ImplTraitContext :: Disallowed ( ImplTraitPosition :: Path ) ,
11821189 None ,
11831190 ) ;
1184- // FIXME(min_generic_const_exprs): for now we only lower params to ConstArgKind::Path
1185- if let hir:: QPath :: Resolved (
1186- _,
1187- & hir:: Path { res : Res :: Def ( DefKind :: ConstParam , _) , .. } ,
1188- ) = qpath
1189- {
1190- return ConstArg {
1191- hir_id : self . lower_node_id ( anon. id ) ,
1192- kind : ConstArgKind :: Path ( qpath) ,
1193- is_desugared_from_effects : false ,
1194- } ;
1195- }
1191+ return ConstArg {
1192+ hir_id : self . lower_node_id ( anon. id ) ,
1193+ kind : ConstArgKind :: Path ( qpath) ,
1194+ is_desugared_from_effects : false ,
1195+ } ;
11961196 }
11971197
11981198 let lowered_anon = self . lower_anon_const ( anon) ;
@@ -2597,12 +2597,11 @@ impl<'hir> GenericArgsCtor<'hir> {
25972597 return ;
25982598 }
25992599
2600- let id = lcx. next_node_id ( ) ;
2601- let hir_id = lcx. next_id ( ) ;
2602-
2603- let const_arg_kind = match constness {
2600+ let ( hir_id, const_arg_kind) = match constness {
26042601 BoundConstness :: Never => return ,
26052602 BoundConstness :: Always ( span) => {
2603+ let id = lcx. next_node_id ( ) ;
2604+ let hir_id = lcx. next_id ( ) ;
26062605 let span = lcx. lower_span ( span) ;
26072606
26082607 let body = hir:: ExprKind :: Lit (
@@ -2619,14 +2618,18 @@ impl<'hir> GenericArgsCtor<'hir> {
26192618 ) ;
26202619
26212620 lcx. children . push ( ( def_id, hir:: MaybeOwner :: NonOwner ( hir_id) ) ) ;
2622- hir:: ConstArgKind :: Anon ( lcx. arena . alloc ( hir:: AnonConst {
2623- def_id,
2621+ (
26242622 hir_id,
2625- body,
2626- span,
2627- } ) )
2623+ hir:: ConstArgKind :: Anon ( lcx. arena . alloc ( hir:: AnonConst {
2624+ def_id,
2625+ hir_id,
2626+ body,
2627+ span,
2628+ } ) ) ,
2629+ )
26282630 }
26292631 BoundConstness :: Maybe ( span) => {
2632+ let hir_id = lcx. next_id ( ) ;
26302633 let span = lcx. lower_span ( span) ;
26312634
26322635 let Some ( host_param_id) = lcx. host_param_id else {
@@ -2650,7 +2653,7 @@ impl<'hir> GenericArgsCtor<'hir> {
26502653 )
26512654 ] ,
26522655 } ) ;
2653- hir:: ConstArgKind :: Path ( hir:: QPath :: Resolved ( None , path) )
2656+ ( hir_id , hir:: ConstArgKind :: Path ( hir:: QPath :: Resolved ( None , path) ) )
26542657 }
26552658 } ;
26562659
0 commit comments