@@ -1177,7 +1177,14 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
1177
1177
}
1178
1178
1179
1179
fn lower_anon_const_as_const_arg ( & mut self , anon : & AnonConst ) -> hir:: ConstArg < ' hir > {
1180
- if let ExprKind :: Path ( qself, path) = & anon. value . kind {
1180
+ if let ExprKind :: Path ( qself, path) = & anon. value . kind
1181
+ && let Some ( res) = self
1182
+ . resolver
1183
+ . get_partial_res ( anon. id )
1184
+ . and_then ( |partial_res| partial_res. full_res ( ) )
1185
+ // FIXME(min_generic_const_exprs): for now we only lower params to ConstArgKind::Path
1186
+ && let Res :: Def ( DefKind :: ConstParam , _) = res
1187
+ {
1181
1188
let qpath = self . lower_qpath (
1182
1189
anon. id ,
1183
1190
qself,
@@ -1186,18 +1193,11 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
1186
1193
ImplTraitContext :: Disallowed ( ImplTraitPosition :: Path ) ,
1187
1194
None ,
1188
1195
) ;
1189
- // FIXME(min_generic_const_exprs): for now we only lower params to ConstArgKind::Path
1190
- if let hir:: QPath :: Resolved (
1191
- _,
1192
- & hir:: Path { res : Res :: Def ( DefKind :: ConstParam , _) , .. } ,
1193
- ) = qpath
1194
- {
1195
- return ConstArg {
1196
- hir_id : self . lower_node_id ( anon. id ) ,
1197
- kind : ConstArgKind :: Path ( qpath) ,
1198
- is_desugared_from_effects : false ,
1199
- } ;
1200
- }
1196
+ return ConstArg {
1197
+ hir_id : self . lower_node_id ( anon. id ) ,
1198
+ kind : ConstArgKind :: Path ( qpath) ,
1199
+ is_desugared_from_effects : false ,
1200
+ } ;
1201
1201
}
1202
1202
1203
1203
let lowered_anon = self . lower_anon_const ( anon) ;
@@ -2602,12 +2602,11 @@ impl<'hir> GenericArgsCtor<'hir> {
2602
2602
return ;
2603
2603
}
2604
2604
2605
- let id = lcx. next_node_id ( ) ;
2606
- let hir_id = lcx. next_id ( ) ;
2607
-
2608
- let const_arg_kind = match constness {
2605
+ let ( hir_id, const_arg_kind) = match constness {
2609
2606
BoundConstness :: Never => return ,
2610
2607
BoundConstness :: Always ( span) => {
2608
+ let id = lcx. next_node_id ( ) ;
2609
+ let hir_id = lcx. next_id ( ) ;
2611
2610
let span = lcx. lower_span ( span) ;
2612
2611
2613
2612
let body = hir:: ExprKind :: Lit (
@@ -2624,14 +2623,18 @@ impl<'hir> GenericArgsCtor<'hir> {
2624
2623
) ;
2625
2624
2626
2625
lcx. children . push ( ( def_id, hir:: MaybeOwner :: NonOwner ( hir_id) ) ) ;
2627
- hir:: ConstArgKind :: Anon ( lcx. arena . alloc ( hir:: AnonConst {
2628
- def_id,
2626
+ (
2629
2627
hir_id,
2630
- body,
2631
- span,
2632
- } ) )
2628
+ hir:: ConstArgKind :: Anon ( lcx. arena . alloc ( hir:: AnonConst {
2629
+ def_id,
2630
+ hir_id,
2631
+ body,
2632
+ span,
2633
+ } ) ) ,
2634
+ )
2633
2635
}
2634
2636
BoundConstness :: Maybe ( span) => {
2637
+ let hir_id = lcx. next_id ( ) ;
2635
2638
let span = lcx. lower_span ( span) ;
2636
2639
2637
2640
let Some ( host_param_id) = lcx. host_param_id else {
@@ -2655,7 +2658,7 @@ impl<'hir> GenericArgsCtor<'hir> {
2655
2658
)
2656
2659
] ,
2657
2660
} ) ;
2658
- hir:: ConstArgKind :: Path ( hir:: QPath :: Resolved ( None , path) )
2661
+ ( hir_id , hir:: ConstArgKind :: Path ( hir:: QPath :: Resolved ( None , path) ) )
2659
2662
}
2660
2663
} ;
2661
2664
0 commit comments