@@ -1084,7 +1084,7 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
1084
1084
AssocItemConstraintKind :: Equality { term } => {
1085
1085
let term = match term {
1086
1086
Term :: Ty ( ty) => self . lower_ty ( ty, itctx) . into ( ) ,
1087
- Term :: Const ( c) => self . lower_anon_const_to_const_arg ( c) . into ( ) ,
1087
+ Term :: Const ( c) => self . lower_anon_const_to_const_arg ( c, false ) . into ( ) ,
1088
1088
} ;
1089
1089
hir:: AssocItemConstraintKind :: Equality { term }
1090
1090
}
@@ -1210,9 +1210,9 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
1210
1210
}
1211
1211
GenericArg :: Type ( self . lower_ty ( ty, itctx) . try_as_ambig_ty ( ) . unwrap ( ) )
1212
1212
}
1213
- ast:: GenericArg :: Const ( ct) => {
1214
- GenericArg :: Const ( self . lower_anon_const_to_const_arg ( ct) . try_as_ambig_ct ( ) . unwrap ( ) )
1215
- }
1213
+ ast:: GenericArg :: Const ( ct) => GenericArg :: Const (
1214
+ self . lower_anon_const_to_const_arg ( ct, false ) . try_as_ambig_ct ( ) . unwrap ( ) ,
1215
+ ) ,
1216
1216
}
1217
1217
}
1218
1218
@@ -2024,7 +2024,7 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
2024
2024
false
2025
2025
}
2026
2026
} )
2027
- . map ( |def| self . lower_anon_const_to_const_arg ( def) ) ;
2027
+ . map ( |def| self . lower_anon_const_to_const_arg ( def, false ) ) ;
2028
2028
2029
2029
(
2030
2030
hir:: ParamName :: Plain ( self . lower_ident ( param. ident ) ) ,
@@ -2236,7 +2236,7 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
2236
2236
let ct_kind = hir:: ConstArgKind :: Infer ( self . lower_span ( c. value . span ) , ( ) ) ;
2237
2237
self . arena . alloc ( hir:: ConstArg { hir_id : self . lower_node_id ( c. id ) , kind : ct_kind } )
2238
2238
}
2239
- _ => self . lower_anon_const_to_const_arg ( c) ,
2239
+ _ => self . lower_anon_const_to_const_arg ( c, false ) ,
2240
2240
}
2241
2241
}
2242
2242
@@ -2305,12 +2305,21 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
2305
2305
2306
2306
/// See [`hir::ConstArg`] for when to use this function vs
2307
2307
/// [`Self::lower_anon_const_to_anon_const`].
2308
- fn lower_anon_const_to_const_arg ( & mut self , anon : & AnonConst ) -> & ' hir hir:: ConstArg < ' hir > {
2309
- self . arena . alloc ( self . lower_anon_const_to_const_arg_direct ( anon) )
2308
+ fn lower_anon_const_to_const_arg (
2309
+ & mut self ,
2310
+ anon : & AnonConst ,
2311
+ always_lower_to_anon_const : bool ,
2312
+ ) -> & ' hir hir:: ConstArg < ' hir > {
2313
+ self . arena
2314
+ . alloc ( self . lower_anon_const_to_const_arg_direct ( anon, always_lower_to_anon_const) )
2310
2315
}
2311
2316
2312
2317
#[ instrument( level = "debug" , skip( self ) ) ]
2313
- fn lower_anon_const_to_const_arg_direct ( & mut self , anon : & AnonConst ) -> hir:: ConstArg < ' hir > {
2318
+ fn lower_anon_const_to_const_arg_direct (
2319
+ & mut self ,
2320
+ anon : & AnonConst ,
2321
+ always_lower_to_anon_const : bool ,
2322
+ ) -> hir:: ConstArg < ' hir > {
2314
2323
let tcx = self . tcx ;
2315
2324
// Unwrap a block, so that e.g. `{ P }` is recognised as a parameter. Const arguments
2316
2325
// currently have to be wrapped in curly brackets, so it's necessary to special-case.
@@ -2329,6 +2338,7 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
2329
2338
&& path. is_potential_trivial_const_arg ( tcx. features ( ) . min_generic_const_args ( ) )
2330
2339
&& ( tcx. features ( ) . min_generic_const_args ( )
2331
2340
|| matches ! ( maybe_res, Some ( Res :: Def ( DefKind :: ConstParam , _) ) ) )
2341
+ && !always_lower_to_anon_const
2332
2342
{
2333
2343
let qpath = self . lower_qpath (
2334
2344
expr. id ,
0 commit comments