@@ -1172,7 +1172,14 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
1172
1172
}
1173
1173
1174
1174
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
+ {
1176
1183
let qpath = self . lower_qpath (
1177
1184
anon. id ,
1178
1185
qself,
@@ -1181,18 +1188,11 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
1181
1188
ImplTraitContext :: Disallowed ( ImplTraitPosition :: Path ) ,
1182
1189
None ,
1183
1190
) ;
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
+ } ;
1196
1196
}
1197
1197
1198
1198
let lowered_anon = self . lower_anon_const ( anon) ;
@@ -2597,12 +2597,11 @@ impl<'hir> GenericArgsCtor<'hir> {
2597
2597
return ;
2598
2598
}
2599
2599
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 {
2604
2601
BoundConstness :: Never => return ,
2605
2602
BoundConstness :: Always ( span) => {
2603
+ let id = lcx. next_node_id ( ) ;
2604
+ let hir_id = lcx. next_id ( ) ;
2606
2605
let span = lcx. lower_span ( span) ;
2607
2606
2608
2607
let body = hir:: ExprKind :: Lit (
@@ -2619,14 +2618,18 @@ impl<'hir> GenericArgsCtor<'hir> {
2619
2618
) ;
2620
2619
2621
2620
lcx. children . push ( ( def_id, hir:: MaybeOwner :: NonOwner ( hir_id) ) ) ;
2622
- hir:: ConstArgKind :: Anon ( lcx. arena . alloc ( hir:: AnonConst {
2623
- def_id,
2621
+ (
2624
2622
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
+ )
2628
2630
}
2629
2631
BoundConstness :: Maybe ( span) => {
2632
+ let hir_id = lcx. next_id ( ) ;
2630
2633
let span = lcx. lower_span ( span) ;
2631
2634
2632
2635
let Some ( host_param_id) = lcx. host_param_id else {
@@ -2650,7 +2653,7 @@ impl<'hir> GenericArgsCtor<'hir> {
2650
2653
)
2651
2654
] ,
2652
2655
} ) ;
2653
- hir:: ConstArgKind :: Path ( hir:: QPath :: Resolved ( None , path) )
2656
+ ( hir_id , hir:: ConstArgKind :: Path ( hir:: QPath :: Resolved ( None , path) ) )
2654
2657
}
2655
2658
} ;
2656
2659
0 commit comments