@@ -1084,7 +1084,7 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
10841084 AssocItemConstraintKind :: Equality { term } => {
10851085 let term = match term {
10861086 Term :: Ty ( ty) => self . lower_ty ( ty, itctx) . into ( ) ,
1087- Term :: Const ( c) => self . lower_anon_const_to_const_arg ( c, false ) . into ( ) ,
1087+ Term :: Const ( c) => self . lower_anon_const_to_const_arg ( c) . into ( ) ,
10881088 } ;
10891089 hir:: AssocItemConstraintKind :: Equality { term }
10901090 }
@@ -1210,9 +1210,9 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
12101210 }
12111211 GenericArg :: Type ( self . lower_ty ( ty, itctx) . try_as_ambig_ty ( ) . unwrap ( ) )
12121212 }
1213- ast:: GenericArg :: Const ( ct) => GenericArg :: Const (
1214- self . lower_anon_const_to_const_arg ( ct, false ) . try_as_ambig_ct ( ) . unwrap ( ) ,
1215- ) ,
1213+ ast:: GenericArg :: Const ( ct) => {
1214+ GenericArg :: Const ( self . lower_anon_const_to_const_arg ( ct) . try_as_ambig_ct ( ) . unwrap ( ) )
1215+ }
12161216 }
12171217 }
12181218
@@ -2024,7 +2024,7 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
20242024 false
20252025 }
20262026 } )
2027- . map ( |def| self . lower_anon_const_to_const_arg ( def, false ) ) ;
2027+ . map ( |def| self . lower_anon_const_to_const_arg ( def) ) ;
20282028
20292029 (
20302030 hir:: ParamName :: Plain ( self . lower_ident ( param. ident ) ) ,
@@ -2236,7 +2236,7 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
22362236 let ct_kind = hir:: ConstArgKind :: Infer ( self . lower_span ( c. value . span ) , ( ) ) ;
22372237 self . arena . alloc ( hir:: ConstArg { hir_id : self . lower_node_id ( c. id ) , kind : ct_kind } )
22382238 }
2239- _ => self . lower_anon_const_to_const_arg ( c, false ) ,
2239+ _ => self . lower_anon_const_to_const_arg ( c) ,
22402240 }
22412241 }
22422242
@@ -2305,13 +2305,31 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
23052305
23062306 /// See [`hir::ConstArg`] for when to use this function vs
23072307 /// [`Self::lower_anon_const_to_anon_const`].
2308- fn lower_anon_const_to_const_arg (
2308+ fn lower_item_body_to_const_arg (
23092309 & mut self ,
2310- anon : & AnonConst ,
2311- always_lower_to_anon_const : bool ,
2310+ anon : Option < & AnonConst > ,
23122311 ) -> & ' hir hir:: ConstArg < ' hir > {
2313- self . arena
2314- . alloc ( self . lower_anon_const_to_const_arg_direct ( anon, always_lower_to_anon_const) )
2312+ let Some ( anon) = anon else {
2313+ let const_arg = ConstArg {
2314+ hir_id : self . next_id ( ) ,
2315+ kind : hir:: ConstArgKind :: Error (
2316+ DUMMY_SP ,
2317+ self . dcx ( ) . span_delayed_bug ( DUMMY_SP , "no block" ) ,
2318+ ) ,
2319+ } ;
2320+ return self . arena . alloc ( const_arg) ;
2321+ } ;
2322+
2323+ self . arena . alloc ( self . lower_anon_const_to_const_arg_direct (
2324+ anon,
2325+ !self . tcx . features ( ) . min_generic_const_args ( ) ,
2326+ ) )
2327+ }
2328+
2329+ /// See [`hir::ConstArg`] for when to use this function vs
2330+ /// [`Self::lower_anon_const_to_anon_const`].
2331+ fn lower_anon_const_to_const_arg ( & mut self , anon : & AnonConst ) -> & ' hir hir:: ConstArg < ' hir > {
2332+ self . arena . alloc ( self . lower_anon_const_to_const_arg_direct ( anon, false ) )
23152333 }
23162334
23172335 #[ instrument( level = "debug" , skip( self ) ) ]
0 commit comments