@@ -835,17 +835,16 @@ pub struct OwnerNodes<'tcx> {
835
835
// The zeroth node's parent should never be accessed: the owner's parent is computed by the
836
836
// hir_owner_parent query. It is set to `ItemLocalId::INVALID` to force an ICE if accidentally
837
837
// used.
838
- pub nodes : IndexVec < ItemLocalId , Option < ParentedNode < ' tcx > > > ,
838
+ pub nodes : IndexVec < ItemLocalId , ParentedNode < ' tcx > > ,
839
839
/// Content of local bodies.
840
840
pub bodies : SortedMap < ItemLocalId , & ' tcx Body < ' tcx > > ,
841
841
}
842
842
843
843
impl < ' tcx > OwnerNodes < ' tcx > {
844
844
pub fn node ( & self ) -> OwnerNode < ' tcx > {
845
845
use rustc_index:: Idx ;
846
- let node = self . nodes [ ItemLocalId :: new ( 0 ) ] . as_ref ( ) . unwrap ( ) . node ;
847
- let node = node. as_owner ( ) . unwrap ( ) ; // Indexing must ensure it is an OwnerNode.
848
- node
846
+ // Indexing must ensure it is an OwnerNode.
847
+ self . nodes [ ItemLocalId :: new ( 0 ) ] . node . as_owner ( ) . unwrap ( )
849
848
}
850
849
}
851
850
@@ -860,9 +859,7 @@ impl fmt::Debug for OwnerNodes<'_> {
860
859
. nodes
861
860
. iter_enumerated ( )
862
861
. map ( |( id, parented_node) | {
863
- let parented_node = parented_node. as_ref ( ) . map ( |node| node. parent ) ;
864
-
865
- debug_fn ( move |f| write ! ( f, "({id:?}, {parented_node:?})" ) )
862
+ debug_fn ( move |f| write ! ( f, "({id:?}, {:?})" , parented_node. parent) )
866
863
} )
867
864
. collect :: < Vec < _ > > ( ) ,
868
865
)
@@ -3356,13 +3353,14 @@ impl<'hir> OwnerNode<'hir> {
3356
3353
}
3357
3354
}
3358
3355
3359
- pub fn span ( & self ) -> Span {
3356
+ #[ allow( rustc:: pass_by_value) ]
3357
+ pub fn span ( & self ) -> & ' hir Span {
3360
3358
match self {
3361
3359
OwnerNode :: Item ( Item { span, .. } )
3362
3360
| OwnerNode :: ForeignItem ( ForeignItem { span, .. } )
3363
3361
| OwnerNode :: ImplItem ( ImplItem { span, .. } )
3364
- | OwnerNode :: TraitItem ( TraitItem { span, .. } ) => * span,
3365
- OwnerNode :: Crate ( Mod { spans : ModSpans { inner_span, .. } , .. } ) => * inner_span,
3362
+ | OwnerNode :: TraitItem ( TraitItem { span, .. } ) => span,
3363
+ OwnerNode :: Crate ( Mod { spans : ModSpans { inner_span, .. } , .. } ) => inner_span,
3366
3364
}
3367
3365
}
3368
3366
@@ -3491,17 +3489,20 @@ pub enum Node<'hir> {
3491
3489
Arm ( & ' hir Arm < ' hir > ) ,
3492
3490
Block ( & ' hir Block < ' hir > ) ,
3493
3491
Local ( & ' hir Local < ' hir > ) ,
3494
-
3495
3492
/// `Ctor` refers to the constructor of an enum variant or struct. Only tuple or unit variants
3496
3493
/// with synthesized constructors.
3497
3494
Ctor ( & ' hir VariantData < ' hir > ) ,
3498
-
3499
3495
Lifetime ( & ' hir Lifetime ) ,
3500
3496
GenericParam ( & ' hir GenericParam < ' hir > ) ,
3501
-
3502
3497
Crate ( & ' hir Mod < ' hir > ) ,
3503
-
3504
3498
Infer ( & ' hir InferArg ) ,
3499
+ WhereBoundPredicate ( & ' hir WhereBoundPredicate < ' hir > ) ,
3500
+ Let ( & ' hir Let < ' hir > ) ,
3501
+ // Span by reference to minimize `Node`'s size
3502
+ #[ allow( rustc:: pass_by_value) ]
3503
+ ArrayLenInfer ( & ' hir Span ) ,
3504
+ #[ allow( rustc:: pass_by_value) ]
3505
+ Err ( & ' hir Span ) ,
3505
3506
}
3506
3507
3507
3508
impl < ' hir > Node < ' hir > {
@@ -3546,7 +3547,11 @@ impl<'hir> Node<'hir> {
3546
3547
| Node :: Crate ( ..)
3547
3548
| Node :: Ty ( ..)
3548
3549
| Node :: TraitRef ( ..)
3549
- | Node :: Infer ( ..) => None ,
3550
+ | Node :: Infer ( ..)
3551
+ | Node :: WhereBoundPredicate ( ..)
3552
+ | Node :: Let ( ..)
3553
+ | Node :: ArrayLenInfer ( ..)
3554
+ | Node :: Err ( ..) => None ,
3550
3555
}
3551
3556
}
3552
3557
0 commit comments