@@ -507,7 +507,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
507507 let new_id = this. lower_node_id ( new_node_id) ;
508508 let res = this. lower_res ( res) ;
509509 let path = this. lower_path_extra ( res, & path, ParamMode :: Explicit , None ) ;
510- let kind = hir:: ItemKind :: Use ( this . arena . alloc ( path) , hir:: UseKind :: Single ) ;
510+ let kind = hir:: ItemKind :: Use ( path, hir:: UseKind :: Single ) ;
511511 let vis = this. rebuild_vis ( & vis) ;
512512
513513 this. insert_item ( hir:: Item {
@@ -522,15 +522,11 @@ impl<'hir> LoweringContext<'_, 'hir> {
522522 }
523523
524524 let path = self . lower_path_extra ( ret_res, & path, ParamMode :: Explicit , None ) ;
525- let path = self . arena . alloc ( path) ;
526525 hir:: ItemKind :: Use ( path, hir:: UseKind :: Single )
527526 }
528527 UseTreeKind :: Glob => {
529- let path = self . arena . alloc ( self . lower_path (
530- id,
531- & Path { segments, span : path. span } ,
532- ParamMode :: Explicit ,
533- ) ) ;
528+ let path =
529+ self . lower_path ( id, & Path { segments, span : path. span } , ParamMode :: Explicit ) ;
534530 hir:: ItemKind :: Use ( path, hir:: UseKind :: Glob )
535531 }
536532 UseTreeKind :: Nested ( ref trees) => {
@@ -618,7 +614,6 @@ impl<'hir> LoweringContext<'_, 'hir> {
618614 let res = self . expect_full_res_from_use ( id) . next ( ) . unwrap_or ( Res :: Err ) ;
619615 let res = self . lower_res ( res) ;
620616 let path = self . lower_path_extra ( res, & prefix, ParamMode :: Explicit , None ) ;
621- let path = self . arena . alloc ( path) ;
622617 hir:: ItemKind :: Use ( path, hir:: UseKind :: ListStem )
623618 }
624619 }
@@ -627,7 +622,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
627622 /// Paths like the visibility path in `pub(super) use foo::{bar, baz}` are repeated
628623 /// many times in the HIR tree; for each occurrence, we need to assign distinct
629624 /// `NodeId`s. (See, e.g., #56128.)
630- fn rebuild_use_path ( & mut self , path : & hir:: Path < ' hir > ) -> hir:: Path < ' hir > {
625+ fn rebuild_use_path ( & mut self , path : & hir:: Path < ' hir > ) -> & ' hir hir:: Path < ' hir > {
631626 debug ! ( "rebuild_use_path(path = {:?})" , path) ;
632627 let segments =
633628 self . arena . alloc_from_iter ( path. segments . iter ( ) . map ( |seg| hir:: PathSegment {
@@ -637,7 +632,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
637632 args : None ,
638633 infer_args : seg. infer_args ,
639634 } ) ) ;
640- hir:: Path { span : path. span , res : path. res , segments }
635+ self . arena . alloc ( hir:: Path { span : path. span , res : path. res , segments } )
641636 }
642637
643638 fn rebuild_vis ( & mut self , vis : & hir:: Visibility < ' hir > ) -> hir:: Visibility < ' hir > {
@@ -647,7 +642,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
647642 hir:: VisibilityKind :: Inherited => hir:: VisibilityKind :: Inherited ,
648643 hir:: VisibilityKind :: Restricted { ref path, hir_id : _ } => {
649644 hir:: VisibilityKind :: Restricted {
650- path : self . arena . alloc ( self . rebuild_use_path ( path) ) ,
645+ path : self . rebuild_use_path ( path) ,
651646 hir_id : self . next_id ( ) ,
652647 }
653648 }
@@ -944,12 +939,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
944939 let res = self . expect_full_res ( id) ;
945940 let res = self . lower_res ( res) ;
946941 hir:: VisibilityKind :: Restricted {
947- path : self . arena . alloc ( self . lower_path_extra (
948- res,
949- path,
950- ParamMode :: Explicit ,
951- explicit_owner,
952- ) ) ,
942+ path : self . lower_path_extra ( res, path, ParamMode :: Explicit , explicit_owner) ,
953943 hir_id : lowered_id,
954944 }
955945 }
0 commit comments