@@ -507,7 +507,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
507
507
let new_id = this. lower_node_id ( new_node_id) ;
508
508
let res = this. lower_res ( res) ;
509
509
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 ) ;
511
511
let vis = this. rebuild_vis ( & vis) ;
512
512
513
513
this. insert_item ( hir:: Item {
@@ -522,15 +522,11 @@ impl<'hir> LoweringContext<'_, 'hir> {
522
522
}
523
523
524
524
let path = self . lower_path_extra ( ret_res, & path, ParamMode :: Explicit , None ) ;
525
- let path = self . arena . alloc ( path) ;
526
525
hir:: ItemKind :: Use ( path, hir:: UseKind :: Single )
527
526
}
528
527
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 ) ;
534
530
hir:: ItemKind :: Use ( path, hir:: UseKind :: Glob )
535
531
}
536
532
UseTreeKind :: Nested ( ref trees) => {
@@ -618,7 +614,6 @@ impl<'hir> LoweringContext<'_, 'hir> {
618
614
let res = self . expect_full_res_from_use ( id) . next ( ) . unwrap_or ( Res :: Err ) ;
619
615
let res = self . lower_res ( res) ;
620
616
let path = self . lower_path_extra ( res, & prefix, ParamMode :: Explicit , None ) ;
621
- let path = self . arena . alloc ( path) ;
622
617
hir:: ItemKind :: Use ( path, hir:: UseKind :: ListStem )
623
618
}
624
619
}
@@ -627,7 +622,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
627
622
/// Paths like the visibility path in `pub(super) use foo::{bar, baz}` are repeated
628
623
/// many times in the HIR tree; for each occurrence, we need to assign distinct
629
624
/// `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 > {
631
626
debug ! ( "rebuild_use_path(path = {:?})" , path) ;
632
627
let segments =
633
628
self . arena . alloc_from_iter ( path. segments . iter ( ) . map ( |seg| hir:: PathSegment {
@@ -637,7 +632,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
637
632
args : None ,
638
633
infer_args : seg. infer_args ,
639
634
} ) ) ;
640
- hir:: Path { span : path. span , res : path. res , segments }
635
+ self . arena . alloc ( hir:: Path { span : path. span , res : path. res , segments } )
641
636
}
642
637
643
638
fn rebuild_vis ( & mut self , vis : & hir:: Visibility < ' hir > ) -> hir:: Visibility < ' hir > {
@@ -647,7 +642,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
647
642
hir:: VisibilityKind :: Inherited => hir:: VisibilityKind :: Inherited ,
648
643
hir:: VisibilityKind :: Restricted { ref path, hir_id : _ } => {
649
644
hir:: VisibilityKind :: Restricted {
650
- path : self . arena . alloc ( self . rebuild_use_path ( path) ) ,
645
+ path : self . rebuild_use_path ( path) ,
651
646
hir_id : self . next_id ( ) ,
652
647
}
653
648
}
@@ -944,12 +939,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
944
939
let res = self . expect_full_res ( id) ;
945
940
let res = self . lower_res ( res) ;
946
941
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) ,
953
943
hir_id : lowered_id,
954
944
}
955
945
}
0 commit comments