@@ -1121,7 +1121,7 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
11211121 let kind = match & constraint. kind {
11221122 AssocItemConstraintKind :: Equality { term } => {
11231123 let term = match term {
1124- Term :: Ty ( ty) => self . lower_ty ( ty, itctx) . into ( ) ,
1124+ Term :: Ty ( ty) => self . lower_ty_and_intern ( ty, itctx) . into ( ) ,
11251125 Term :: Const ( c) => self . lower_anon_const_to_const_arg ( c) . into ( ) ,
11261126 } ;
11271127 hir:: AssocItemConstraintKind :: Equality { term }
@@ -1246,7 +1246,7 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
12461246 }
12471247 _ => { }
12481248 }
1249- GenericArg :: Type ( self . lower_ty ( ty, itctx) . try_as_ambig_ty ( ) . unwrap ( ) )
1249+ GenericArg :: Type ( self . lower_ty_and_intern ( ty, itctx) . try_as_ambig_ty ( ) . unwrap ( ) )
12501250 }
12511251 ast:: GenericArg :: Const ( ct) => {
12521252 GenericArg :: Const ( self . lower_anon_const_to_const_arg ( ct) . try_as_ambig_ct ( ) . unwrap ( ) )
@@ -1255,8 +1255,8 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
12551255 }
12561256
12571257 #[ instrument( level = "debug" , skip( self ) ) ]
1258- fn lower_ty ( & mut self , t : & Ty , itctx : ImplTraitContext ) -> & ' hir hir:: Ty < ' hir > {
1259- self . arena . alloc ( self . lower_ty_direct ( t, itctx) )
1258+ fn lower_ty_and_intern ( & mut self , t : & Ty , itctx : ImplTraitContext ) -> & ' hir hir:: Ty < ' hir > {
1259+ self . arena . alloc ( self . lower_ty ( t, itctx) )
12601260 }
12611261
12621262 fn lower_path_ty (
@@ -1320,11 +1320,11 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
13201320 self . ty ( span, hir:: TyKind :: Tup ( tys) )
13211321 }
13221322
1323- fn lower_ty_direct ( & mut self , t : & Ty , itctx : ImplTraitContext ) -> hir:: Ty < ' hir > {
1323+ fn lower_ty ( & mut self , t : & Ty , itctx : ImplTraitContext ) -> hir:: Ty < ' hir > {
13241324 let kind = match & t. kind {
13251325 TyKind :: Infer => hir:: TyKind :: Infer ( ( ) ) ,
13261326 TyKind :: Err ( guar) => hir:: TyKind :: Err ( * guar) ,
1327- TyKind :: Slice ( ty) => hir:: TyKind :: Slice ( self . lower_ty ( ty, itctx) ) ,
1327+ TyKind :: Slice ( ty) => hir:: TyKind :: Slice ( self . lower_ty_and_intern ( ty, itctx) ) ,
13281328 TyKind :: Ptr ( mt) => hir:: TyKind :: Ptr ( self . lower_mt ( mt, itctx) ) ,
13291329 TyKind :: Ref ( region, mt) => {
13301330 let lifetime = self . lower_ty_direct_lifetime ( t, * region) ;
@@ -1358,15 +1358,15 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
13581358 let generic_params = self . lower_lifetime_binder ( t. id , & f. generic_params ) ;
13591359 hir:: TyKind :: UnsafeBinder ( self . arena . alloc ( hir:: UnsafeBinderTy {
13601360 generic_params,
1361- inner_ty : self . lower_ty ( & f. inner_ty , itctx) ,
1361+ inner_ty : self . lower_ty_and_intern ( & f. inner_ty , itctx) ,
13621362 } ) )
13631363 }
13641364 TyKind :: Never => hir:: TyKind :: Never ,
13651365 TyKind :: Tup ( tys) => hir:: TyKind :: Tup (
1366- self . arena . alloc_from_iter ( tys. iter ( ) . map ( |ty| self . lower_ty_direct ( ty, itctx) ) ) ,
1366+ self . arena . alloc_from_iter ( tys. iter ( ) . map ( |ty| self . lower_ty ( ty, itctx) ) ) ,
13671367 ) ,
13681368 TyKind :: Paren ( ty) => {
1369- return self . lower_ty_direct ( ty, itctx) ;
1369+ return self . lower_ty ( ty, itctx) ;
13701370 }
13711371 TyKind :: Path ( qself, path) => {
13721372 return self . lower_path_ty ( t, qself, path, ParamMode :: Explicit , itctx) ;
@@ -1389,7 +1389,7 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
13891389 ) )
13901390 }
13911391 TyKind :: Array ( ty, length) => hir:: TyKind :: Array (
1392- self . lower_ty ( ty, itctx) ,
1392+ self . lower_ty_and_intern ( ty, itctx) ,
13931393 self . lower_array_length_to_const_arg ( length) ,
13941394 ) ,
13951395 TyKind :: TraitObject ( bounds, kind) => {
@@ -1488,9 +1488,10 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
14881488 }
14891489 }
14901490 }
1491- TyKind :: Pat ( ty, pat) => {
1492- hir:: TyKind :: Pat ( self . lower_ty ( ty, itctx) , self . lower_ty_pat ( pat, ty. span ) )
1493- }
1491+ TyKind :: Pat ( ty, pat) => hir:: TyKind :: Pat (
1492+ self . lower_ty_and_intern ( ty, itctx) ,
1493+ self . lower_ty_pat ( pat, ty. span ) ,
1494+ ) ,
14941495 TyKind :: MacCall ( _) => {
14951496 span_bug ! ( t. span, "`TyKind::MacCall` should have been expanded by now" )
14961497 }
@@ -1689,7 +1690,7 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
16891690 ImplTraitContext :: Disallowed ( ImplTraitPosition :: PointerParam )
16901691 }
16911692 } ;
1692- self . lower_ty_direct ( & param. ty , itctx)
1693+ self . lower_ty ( & param. ty , itctx)
16931694 } ) ) ;
16941695
16951696 let output = match coro {
@@ -1728,7 +1729,7 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
17281729 ImplTraitContext :: Disallowed ( ImplTraitPosition :: PointerReturn )
17291730 }
17301731 } ;
1731- hir:: FnRetTy :: Return ( self . lower_ty ( ty, itctx) )
1732+ hir:: FnRetTy :: Return ( self . lower_ty_and_intern ( ty, itctx) )
17321733 }
17331734 FnRetTy :: Default ( span) => hir:: FnRetTy :: DefaultReturn ( self . lower_span ( * span) ) ,
17341735 } ,
@@ -1839,7 +1840,7 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
18391840 // Not `OpaqueTyOrigin::AsyncFn`: that's only used for the
18401841 // `impl Future` opaque type that `async fn` implicitly
18411842 // generates.
1842- self . lower_ty ( ty, itctx)
1843+ self . lower_ty_and_intern ( ty, itctx)
18431844 }
18441845 FnRetTy :: Default ( ret_ty_span) => self . arena . alloc ( self . ty_tup ( * ret_ty_span, & [ ] ) ) ,
18451846 } ;
@@ -2032,7 +2033,7 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
20322033 }
20332034 } )
20342035 . map ( |def| {
2035- self . lower_ty (
2036+ self . lower_ty_and_intern (
20362037 def,
20372038 ImplTraitContext :: Disallowed ( ImplTraitPosition :: GenericDefault ) ,
20382039 )
@@ -2043,8 +2044,10 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
20432044 ( hir:: ParamName :: Plain ( self . lower_ident ( param. ident ) ) , kind)
20442045 }
20452046 GenericParamKind :: Const { ty, span : _, default } => {
2046- let ty = self
2047- . lower_ty ( ty, ImplTraitContext :: Disallowed ( ImplTraitPosition :: GenericDefault ) ) ;
2047+ let ty = self . lower_ty_and_intern (
2048+ ty,
2049+ ImplTraitContext :: Disallowed ( ImplTraitPosition :: GenericDefault ) ,
2050+ ) ;
20482051
20492052 // Not only do we deny const param defaults in binders but we also map them to `None`
20502053 // since later compiler stages cannot handle them (and shouldn't need to be able to).
@@ -2194,7 +2197,7 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
21942197 }
21952198
21962199 fn lower_mt ( & mut self , mt : & MutTy , itctx : ImplTraitContext ) -> hir:: MutTy < ' hir > {
2197- hir:: MutTy { ty : self . lower_ty ( & mt. ty , itctx) , mutbl : mt. mutbl }
2200+ hir:: MutTy { ty : self . lower_ty_and_intern ( & mt. ty , itctx) , mutbl : mt. mutbl }
21982201 }
21992202
22002203 #[ instrument( level = "debug" , skip( self ) , ret) ]
0 commit comments