@@ -107,7 +107,7 @@ impl<'a, 'lowering, 'hir> Visitor<'a> for ItemLowerer<'a, 'lowering, 'hir> {
107107 }
108108}
109109
110- impl LoweringContext < ' _ , ' _ > {
110+ impl LoweringContext < ' _ , ' hir > {
111111 // Same as the method above, but accepts `hir::GenericParam`s
112112 // instead of `ast::GenericParam`s.
113113 // This should only be used with generics that have already had their
@@ -225,7 +225,7 @@ impl LoweringContext<'_, '_> {
225225 }
226226 }
227227
228- pub fn lower_item ( & mut self , i : & Item ) -> Option < hir:: Item > {
228+ pub fn lower_item ( & mut self , i : & Item ) -> Option < hir:: Item < ' hir > > {
229229 let mut ident = i. ident ;
230230 let mut vis = self . lower_visibility ( & i. vis , None ) ;
231231 let attrs = self . lower_attrs ( & i. attrs ) ;
@@ -269,7 +269,7 @@ impl LoweringContext<'_, '_> {
269269 attrs : & hir:: HirVec < Attribute > ,
270270 vis : & mut hir:: Visibility ,
271271 i : & ItemKind ,
272- ) -> hir:: ItemKind {
272+ ) -> hir:: ItemKind < ' hir > {
273273 match * i {
274274 ItemKind :: ExternCrate ( orig_name) => hir:: ItemKind :: ExternCrate ( orig_name) ,
275275 ItemKind :: Use ( ref use_tree) => {
@@ -282,29 +282,31 @@ impl LoweringContext<'_, '_> {
282282 self . lower_use_tree ( use_tree, & prefix, id, vis, ident, attrs)
283283 }
284284 ItemKind :: Static ( ref t, m, ref e) => {
285+ let ty = self . lower_ty (
286+ t,
287+ if self . sess . features_untracked ( ) . impl_trait_in_bindings {
288+ ImplTraitContext :: OpaqueTy ( None )
289+ } else {
290+ ImplTraitContext :: Disallowed ( ImplTraitPosition :: Binding )
291+ }
292+ ) ;
285293 hir:: ItemKind :: Static (
286- self . lower_ty (
287- t,
288- if self . sess . features_untracked ( ) . impl_trait_in_bindings {
289- ImplTraitContext :: OpaqueTy ( None )
290- } else {
291- ImplTraitContext :: Disallowed ( ImplTraitPosition :: Binding )
292- }
293- ) ,
294+ self . arena . alloc ( ty. into_inner ( ) ) ,
294295 m,
295296 self . lower_const_body ( span, Some ( e) ) ,
296297 )
297298 }
298299 ItemKind :: Const ( ref t, ref e) => {
300+ let ty = self . lower_ty (
301+ t,
302+ if self . sess . features_untracked ( ) . impl_trait_in_bindings {
303+ ImplTraitContext :: OpaqueTy ( None )
304+ } else {
305+ ImplTraitContext :: Disallowed ( ImplTraitPosition :: Binding )
306+ }
307+ ) ;
299308 hir:: ItemKind :: Const (
300- self . lower_ty (
301- t,
302- if self . sess . features_untracked ( ) . impl_trait_in_bindings {
303- ImplTraitContext :: OpaqueTy ( None )
304- } else {
305- ImplTraitContext :: Disallowed ( ImplTraitPosition :: Binding )
306- }
307- ) ,
309+ self . arena . alloc ( ty. into_inner ( ) ) ,
308310 self . lower_const_body ( span, Some ( e) )
309311 )
310312 }
@@ -346,7 +348,7 @@ impl LoweringContext<'_, '_> {
346348 None => {
347349 let ty = self . lower_ty ( ty, ImplTraitContext :: disallowed ( ) ) ;
348350 let generics = self . lower_generics ( generics, ImplTraitContext :: disallowed ( ) ) ;
349- hir:: ItemKind :: TyAlias ( ty , generics)
351+ hir:: ItemKind :: TyAlias ( self . arena . alloc ( ty . into_inner ( ) ) , generics)
350352 } ,
351353 Some ( bounds) => {
352354 let ty = hir:: OpaqueTy {
@@ -434,10 +436,11 @@ impl LoweringContext<'_, '_> {
434436 let new_impl_items = self . with_in_scope_lifetime_defs (
435437 & ast_generics. params ,
436438 |this| {
437- impl_items
438- . iter ( )
439- . map ( |item| this. lower_impl_item_ref ( item) )
440- . collect ( )
439+ this. arena . alloc_from_iter (
440+ impl_items
441+ . iter ( )
442+ . map ( |item| this. lower_impl_item_ref ( item) )
443+ )
441444 } ,
442445 ) ;
443446
@@ -447,16 +450,16 @@ impl LoweringContext<'_, '_> {
447450 self . lower_defaultness ( defaultness, true /* [1] */ ) ,
448451 generics,
449452 trait_ref,
450- lowered_ty,
453+ self . arena . alloc ( lowered_ty. into_inner ( ) ) ,
451454 new_impl_items,
452455 )
453456 }
454457 ItemKind :: Trait ( is_auto, unsafety, ref generics, ref bounds, ref items) => {
455458 let bounds = self . lower_param_bounds ( bounds, ImplTraitContext :: disallowed ( ) ) ;
456- let items = items
459+ let items = self . arena . alloc_from_iter ( items
457460 . iter ( )
458461 . map ( |item| self . lower_trait_item_ref ( item) )
459- . collect ( ) ;
462+ ) ;
460463 hir:: ItemKind :: Trait (
461464 is_auto,
462465 unsafety,
@@ -485,7 +488,7 @@ impl LoweringContext<'_, '_> {
485488 vis : & mut hir:: Visibility ,
486489 ident : & mut Ident ,
487490 attrs : & hir:: HirVec < Attribute > ,
488- ) -> hir:: ItemKind {
491+ ) -> hir:: ItemKind < ' hir > {
489492 debug ! ( "lower_use_tree(tree={:?})" , tree) ;
490493 debug ! ( "lower_use_tree: vis = {:?}" , vis) ;
491494
@@ -540,7 +543,7 @@ impl LoweringContext<'_, '_> {
540543 let res = this. lower_res ( res) ;
541544 let path =
542545 this. lower_path_extra ( res, & path, ParamMode :: Explicit , None ) ;
543- let kind = hir:: ItemKind :: Use ( P ( path) , hir:: UseKind :: Single ) ;
546+ let kind = hir:: ItemKind :: Use ( this . arena . alloc ( path) , hir:: UseKind :: Single ) ;
544547 let vis = this. rebuild_vis ( & vis) ;
545548
546549 this. insert_item (
@@ -556,11 +559,11 @@ impl LoweringContext<'_, '_> {
556559 } ) ;
557560 }
558561
559- let path = P ( self . lower_path_extra ( ret_res, & path, ParamMode :: Explicit , None ) ) ;
562+ let path = self . arena . alloc ( self . lower_path_extra ( ret_res, & path, ParamMode :: Explicit , None ) ) ;
560563 hir:: ItemKind :: Use ( path, hir:: UseKind :: Single )
561564 }
562565 UseTreeKind :: Glob => {
563- let path = P ( self . lower_path (
566+ let path = self . arena . alloc ( self . lower_path (
564567 id,
565568 & Path {
566569 segments,
@@ -663,7 +666,7 @@ impl LoweringContext<'_, '_> {
663666
664667 let res = self . expect_full_res_from_use ( id) . next ( ) . unwrap_or ( Res :: Err ) ;
665668 let res = self . lower_res ( res) ;
666- let path = P ( self . lower_path_extra ( res, & prefix, ParamMode :: Explicit , None ) ) ;
669+ let path = self . arena . alloc ( self . lower_path_extra ( res, & prefix, ParamMode :: Explicit , None ) ) ;
667670 hir:: ItemKind :: Use ( path, hir:: UseKind :: ListStem )
668671 }
669672 }
@@ -748,8 +751,8 @@ impl LoweringContext<'_, '_> {
748751 }
749752 }
750753
751- fn lower_global_asm ( & mut self , ga : & GlobalAsm ) -> P < hir:: GlobalAsm > {
752- P ( hir:: GlobalAsm { asm : ga. asm } )
754+ fn lower_global_asm ( & mut self , ga : & GlobalAsm ) -> & ' hir hir :: GlobalAsm {
755+ self . arena . alloc ( hir:: GlobalAsm { asm : ga. asm } )
753756 }
754757
755758 fn lower_variant ( & mut self , v : & Variant ) -> hir:: Variant {
0 commit comments