@@ -1174,7 +1174,14 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
11741174 }
11751175
11761176 fn lower_anon_const_as_const_arg ( & mut self , anon : & AnonConst ) -> hir:: ConstArg < ' hir > {
1177- if let ExprKind :: Path ( qself, path) = & anon. value . kind {
1177+ if let ExprKind :: Path ( qself, path) = & anon. value . kind
1178+ && let Some ( res) = self
1179+ . resolver
1180+ . get_partial_res ( anon. id )
1181+ . and_then ( |partial_res| partial_res. full_res ( ) )
1182+ // FIXME(min_generic_const_exprs): for now we only lower params to ConstArgKind::Path
1183+ && let Res :: Def ( DefKind :: ConstParam , _) = res
1184+ {
11781185 let qpath = self . lower_qpath (
11791186 anon. id ,
11801187 qself,
@@ -1183,18 +1190,11 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
11831190 ImplTraitContext :: Disallowed ( ImplTraitPosition :: Path ) ,
11841191 None ,
11851192 ) ;
1186- // FIXME(min_generic_const_exprs): for now we only lower params to ConstArgKind::Path
1187- if let hir:: QPath :: Resolved (
1188- _,
1189- & hir:: Path { res : Res :: Def ( DefKind :: ConstParam , _) , .. } ,
1190- ) = qpath
1191- {
1192- return ConstArg {
1193- hir_id : self . lower_node_id ( anon. id ) ,
1194- kind : ConstArgKind :: Path ( qpath) ,
1195- is_desugared_from_effects : false ,
1196- } ;
1197- }
1193+ return ConstArg {
1194+ hir_id : self . lower_node_id ( anon. id ) ,
1195+ kind : ConstArgKind :: Path ( qpath) ,
1196+ is_desugared_from_effects : false ,
1197+ } ;
11981198 }
11991199
12001200 let lowered_anon = self . lower_anon_const ( anon) ;
@@ -2599,12 +2599,11 @@ impl<'hir> GenericArgsCtor<'hir> {
25992599 return ;
26002600 }
26012601
2602- let id = lcx. next_node_id ( ) ;
2603- let hir_id = lcx. next_id ( ) ;
2604-
2605- let const_arg_kind = match constness {
2602+ let ( hir_id, const_arg_kind) = match constness {
26062603 BoundConstness :: Never => return ,
26072604 BoundConstness :: Always ( span) => {
2605+ let id = lcx. next_node_id ( ) ;
2606+ let hir_id = lcx. next_id ( ) ;
26082607 let span = lcx. lower_span ( span) ;
26092608
26102609 let body = hir:: ExprKind :: Lit (
@@ -2621,14 +2620,18 @@ impl<'hir> GenericArgsCtor<'hir> {
26212620 ) ;
26222621
26232622 lcx. children . push ( ( def_id, hir:: MaybeOwner :: NonOwner ( hir_id) ) ) ;
2624- hir:: ConstArgKind :: Anon ( lcx. arena . alloc ( hir:: AnonConst {
2625- def_id,
2623+ (
26262624 hir_id,
2627- body,
2628- span,
2629- } ) )
2625+ hir:: ConstArgKind :: Anon ( lcx. arena . alloc ( hir:: AnonConst {
2626+ def_id,
2627+ hir_id,
2628+ body,
2629+ span,
2630+ } ) ) ,
2631+ )
26302632 }
26312633 BoundConstness :: Maybe ( span) => {
2634+ let hir_id = lcx. next_id ( ) ;
26322635 let span = lcx. lower_span ( span) ;
26332636
26342637 let Some ( host_param_id) = lcx. host_param_id else {
@@ -2652,7 +2655,7 @@ impl<'hir> GenericArgsCtor<'hir> {
26522655 )
26532656 ] ,
26542657 } ) ;
2655- hir:: ConstArgKind :: Path ( hir:: QPath :: Resolved ( None , path) )
2658+ ( hir_id , hir:: ConstArgKind :: Path ( hir:: QPath :: Resolved ( None , path) ) )
26562659 }
26572660 } ;
26582661
0 commit comments