@@ -1174,7 +1174,14 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
1174
1174
}
1175
1175
1176
1176
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
+ {
1178
1185
let qpath = self . lower_qpath (
1179
1186
anon. id ,
1180
1187
qself,
@@ -1183,18 +1190,11 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
1183
1190
ImplTraitContext :: Disallowed ( ImplTraitPosition :: Path ) ,
1184
1191
None ,
1185
1192
) ;
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
+ } ;
1198
1198
}
1199
1199
1200
1200
let lowered_anon = self . lower_anon_const ( anon) ;
@@ -2599,12 +2599,11 @@ impl<'hir> GenericArgsCtor<'hir> {
2599
2599
return ;
2600
2600
}
2601
2601
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 {
2606
2603
BoundConstness :: Never => return ,
2607
2604
BoundConstness :: Always ( span) => {
2605
+ let id = lcx. next_node_id ( ) ;
2606
+ let hir_id = lcx. next_id ( ) ;
2608
2607
let span = lcx. lower_span ( span) ;
2609
2608
2610
2609
let body = hir:: ExprKind :: Lit (
@@ -2621,14 +2620,18 @@ impl<'hir> GenericArgsCtor<'hir> {
2621
2620
) ;
2622
2621
2623
2622
lcx. children . push ( ( def_id, hir:: MaybeOwner :: NonOwner ( hir_id) ) ) ;
2624
- hir:: ConstArgKind :: Anon ( lcx. arena . alloc ( hir:: AnonConst {
2625
- def_id,
2623
+ (
2626
2624
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
+ )
2630
2632
}
2631
2633
BoundConstness :: Maybe ( span) => {
2634
+ let hir_id = lcx. next_id ( ) ;
2632
2635
let span = lcx. lower_span ( span) ;
2633
2636
2634
2637
let Some ( host_param_id) = lcx. host_param_id else {
@@ -2652,7 +2655,7 @@ impl<'hir> GenericArgsCtor<'hir> {
2652
2655
)
2653
2656
] ,
2654
2657
} ) ;
2655
- hir:: ConstArgKind :: Path ( hir:: QPath :: Resolved ( None , path) )
2658
+ ( hir_id , hir:: ConstArgKind :: Path ( hir:: QPath :: Resolved ( None , path) ) )
2656
2659
}
2657
2660
} ;
2658
2661
0 commit comments