@@ -1123,7 +1123,7 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
11231123 let kind = match & constraint. kind {
11241124 AssocItemConstraintKind :: Equality { term } => {
11251125 let term = match term {
1126- Term :: Ty ( ty) => self . lower_ty ( ty, itctx) . into ( ) ,
1126+ Term :: Ty ( ty) => self . lower_ty_and_alloc ( ty, itctx) . into ( ) ,
11271127 Term :: Const ( c) => self . lower_anon_const_to_const_arg ( c) . into ( ) ,
11281128 } ;
11291129 hir:: AssocItemConstraintKind :: Equality { term }
@@ -1248,7 +1248,7 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
12481248 }
12491249 _ => { }
12501250 }
1251- GenericArg :: Type ( self . lower_ty ( ty, itctx) . try_as_ambig_ty ( ) . unwrap ( ) )
1251+ GenericArg :: Type ( self . lower_ty_and_alloc ( ty, itctx) . try_as_ambig_ty ( ) . unwrap ( ) )
12521252 }
12531253 ast:: GenericArg :: Const ( ct) => {
12541254 GenericArg :: Const ( self . lower_anon_const_to_const_arg ( ct) . try_as_ambig_ct ( ) . unwrap ( ) )
@@ -1257,8 +1257,8 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
12571257 }
12581258
12591259 #[ instrument( level = "debug" , skip( self ) ) ]
1260- fn lower_ty ( & mut self , t : & Ty , itctx : ImplTraitContext ) -> & ' hir hir:: Ty < ' hir > {
1261- self . arena . alloc ( self . lower_ty_direct ( t, itctx) )
1260+ fn lower_ty_and_alloc ( & mut self , t : & Ty , itctx : ImplTraitContext ) -> & ' hir hir:: Ty < ' hir > {
1261+ self . arena . alloc ( self . lower_ty ( t, itctx) )
12621262 }
12631263
12641264 fn lower_path_ty (
@@ -1322,11 +1322,11 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
13221322 self . ty ( span, hir:: TyKind :: Tup ( tys) )
13231323 }
13241324
1325- fn lower_ty_direct ( & mut self , t : & Ty , itctx : ImplTraitContext ) -> hir:: Ty < ' hir > {
1325+ fn lower_ty ( & mut self , t : & Ty , itctx : ImplTraitContext ) -> hir:: Ty < ' hir > {
13261326 let kind = match & t. kind {
13271327 TyKind :: Infer => hir:: TyKind :: Infer ( ( ) ) ,
13281328 TyKind :: Err ( guar) => hir:: TyKind :: Err ( * guar) ,
1329- TyKind :: Slice ( ty) => hir:: TyKind :: Slice ( self . lower_ty ( ty, itctx) ) ,
1329+ TyKind :: Slice ( ty) => hir:: TyKind :: Slice ( self . lower_ty_and_alloc ( ty, itctx) ) ,
13301330 TyKind :: Ptr ( mt) => hir:: TyKind :: Ptr ( self . lower_mt ( mt, itctx) ) ,
13311331 TyKind :: Ref ( region, mt) => {
13321332 let lifetime = self . lower_ty_direct_lifetime ( t, * region) ;
@@ -1360,15 +1360,15 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
13601360 let generic_params = self . lower_lifetime_binder ( t. id , & f. generic_params ) ;
13611361 hir:: TyKind :: UnsafeBinder ( self . arena . alloc ( hir:: UnsafeBinderTy {
13621362 generic_params,
1363- inner_ty : self . lower_ty ( & f. inner_ty , itctx) ,
1363+ inner_ty : self . lower_ty_and_alloc ( & f. inner_ty , itctx) ,
13641364 } ) )
13651365 }
13661366 TyKind :: Never => hir:: TyKind :: Never ,
13671367 TyKind :: Tup ( tys) => hir:: TyKind :: Tup (
1368- self . arena . alloc_from_iter ( tys. iter ( ) . map ( |ty| self . lower_ty_direct ( ty, itctx) ) ) ,
1368+ self . arena . alloc_from_iter ( tys. iter ( ) . map ( |ty| self . lower_ty ( ty, itctx) ) ) ,
13691369 ) ,
13701370 TyKind :: Paren ( ty) => {
1371- return self . lower_ty_direct ( ty, itctx) ;
1371+ return self . lower_ty ( ty, itctx) ;
13721372 }
13731373 TyKind :: Path ( qself, path) => {
13741374 return self . lower_path_ty ( t, qself, path, ParamMode :: Explicit , itctx) ;
@@ -1391,7 +1391,7 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
13911391 ) )
13921392 }
13931393 TyKind :: Array ( ty, length) => hir:: TyKind :: Array (
1394- self . lower_ty ( ty, itctx) ,
1394+ self . lower_ty_and_alloc ( ty, itctx) ,
13951395 self . lower_array_length_to_const_arg ( length) ,
13961396 ) ,
13971397 TyKind :: TraitObject ( bounds, kind) => {
@@ -1490,9 +1490,10 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
14901490 }
14911491 }
14921492 }
1493- TyKind :: Pat ( ty, pat) => {
1494- hir:: TyKind :: Pat ( self . lower_ty ( ty, itctx) , self . lower_ty_pat ( pat, ty. span ) )
1495- }
1493+ TyKind :: Pat ( ty, pat) => hir:: TyKind :: Pat (
1494+ self . lower_ty_and_alloc ( ty, itctx) ,
1495+ self . lower_ty_pat ( pat, ty. span ) ,
1496+ ) ,
14961497 TyKind :: MacCall ( _) => {
14971498 span_bug ! ( t. span, "`TyKind::MacCall` should have been expanded by now" )
14981499 }
@@ -1691,7 +1692,7 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
16911692 ImplTraitContext :: Disallowed ( ImplTraitPosition :: PointerParam )
16921693 }
16931694 } ;
1694- self . lower_ty_direct ( & param. ty , itctx)
1695+ self . lower_ty ( & param. ty , itctx)
16951696 } ) ) ;
16961697
16971698 let output = match coro {
@@ -1730,7 +1731,7 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
17301731 ImplTraitContext :: Disallowed ( ImplTraitPosition :: PointerReturn )
17311732 }
17321733 } ;
1733- hir:: FnRetTy :: Return ( self . lower_ty ( ty, itctx) )
1734+ hir:: FnRetTy :: Return ( self . lower_ty_and_alloc ( ty, itctx) )
17341735 }
17351736 FnRetTy :: Default ( span) => hir:: FnRetTy :: DefaultReturn ( self . lower_span ( * span) ) ,
17361737 } ,
@@ -1841,7 +1842,7 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
18411842 // Not `OpaqueTyOrigin::AsyncFn`: that's only used for the
18421843 // `impl Future` opaque type that `async fn` implicitly
18431844 // generates.
1844- self . lower_ty ( ty, itctx)
1845+ self . lower_ty_and_alloc ( ty, itctx)
18451846 }
18461847 FnRetTy :: Default ( ret_ty_span) => self . arena . alloc ( self . ty_tup ( * ret_ty_span, & [ ] ) ) ,
18471848 } ;
@@ -2034,7 +2035,7 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
20342035 }
20352036 } )
20362037 . map ( |def| {
2037- self . lower_ty (
2038+ self . lower_ty_and_alloc (
20382039 def,
20392040 ImplTraitContext :: Disallowed ( ImplTraitPosition :: GenericDefault ) ,
20402041 )
@@ -2045,8 +2046,10 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
20452046 ( hir:: ParamName :: Plain ( self . lower_ident ( param. ident ) ) , kind)
20462047 }
20472048 GenericParamKind :: Const { ty, span : _, default } => {
2048- let ty = self
2049- . lower_ty ( ty, ImplTraitContext :: Disallowed ( ImplTraitPosition :: GenericDefault ) ) ;
2049+ let ty = self . lower_ty_and_alloc (
2050+ ty,
2051+ ImplTraitContext :: Disallowed ( ImplTraitPosition :: GenericDefault ) ,
2052+ ) ;
20502053
20512054 // Not only do we deny const param defaults in binders but we also map them to `None`
20522055 // since later compiler stages cannot handle them (and shouldn't need to be able to).
@@ -2196,7 +2199,7 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
21962199 }
21972200
21982201 fn lower_mt ( & mut self , mt : & MutTy , itctx : ImplTraitContext ) -> hir:: MutTy < ' hir > {
2199- hir:: MutTy { ty : self . lower_ty ( & mt. ty , itctx) , mutbl : mt. mutbl }
2202+ hir:: MutTy { ty : self . lower_ty_and_alloc ( & mt. ty , itctx) , mutbl : mt. mutbl }
22002203 }
22012204
22022205 #[ instrument( level = "debug" , skip( self ) , ret) ]
0 commit comments