@@ -259,7 +259,7 @@ impl InferArg {
259259
260260#[ derive( Debug , HashStable_Generic ) ]
261261pub enum GenericArg < ' hir > {
262- Lifetime ( Lifetime ) ,
262+ Lifetime ( & ' hir Lifetime ) ,
263263 Type ( & ' hir Ty < ' hir > ) ,
264264 Const ( ConstArg ) ,
265265 Infer ( InferArg ) ,
@@ -430,7 +430,7 @@ pub enum GenericBound<'hir> {
430430 Trait ( PolyTraitRef < ' hir > , TraitBoundModifier ) ,
431431 // FIXME(davidtwco): Introduce `PolyTraitRef::LangItem`
432432 LangItemTrait ( LangItem , Span , HirId , & ' hir GenericArgs < ' hir > ) ,
433- Outlives ( Lifetime ) ,
433+ Outlives ( & ' hir Lifetime ) ,
434434}
435435
436436impl GenericBound < ' _ > {
@@ -756,7 +756,7 @@ impl<'hir> WhereBoundPredicate<'hir> {
756756pub struct WhereRegionPredicate < ' hir > {
757757 pub span : Span ,
758758 pub in_where_clause : bool ,
759- pub lifetime : Lifetime ,
759+ pub lifetime : & ' hir Lifetime ,
760760 pub bounds : GenericBounds < ' hir > ,
761761}
762762
@@ -1059,6 +1059,35 @@ impl fmt::Display for RangeEnd {
10591059 }
10601060}
10611061
1062+ // Equivalent to `Option<usize>`. That type takes up 16 bytes on 64-bit, but
1063+ // this type only takes up 4 bytes, at the cost of being restricted to a
1064+ // maximum value of `u32::MAX - 1`. In practice, this is more than enough.
1065+ #[ derive( Clone , Copy , PartialEq , Eq , Hash , HashStable_Generic ) ]
1066+ pub struct DotDotPos ( u32 ) ;
1067+
1068+ impl DotDotPos {
1069+ // Panics if n >= u32::MAX.
1070+ pub fn new ( n : Option < usize > ) -> Self {
1071+ match n {
1072+ Some ( n) => {
1073+ assert ! ( n < u32 :: MAX as usize ) ;
1074+ Self ( n as u32 )
1075+ }
1076+ None => Self ( u32:: MAX ) ,
1077+ }
1078+ }
1079+
1080+ pub fn as_opt_usize ( & self ) -> Option < usize > {
1081+ if self . 0 == u32:: MAX { None } else { Some ( self . 0 as usize ) }
1082+ }
1083+ }
1084+
1085+ impl fmt:: Debug for DotDotPos {
1086+ fn fmt ( & self , f : & mut fmt:: Formatter < ' _ > ) -> fmt:: Result {
1087+ self . as_opt_usize ( ) . fmt ( f)
1088+ }
1089+ }
1090+
10621091#[ derive( Debug , HashStable_Generic ) ]
10631092pub enum PatKind < ' hir > {
10641093 /// Represents a wildcard pattern (i.e., `_`).
@@ -1075,9 +1104,9 @@ pub enum PatKind<'hir> {
10751104 Struct ( QPath < ' hir > , & ' hir [ PatField < ' hir > ] , bool ) ,
10761105
10771106 /// A tuple struct/variant pattern `Variant(x, y, .., z)`.
1078- /// If the `..` pattern fragment is present, then `Option<usize> ` denotes its position.
1107+ /// If the `..` pattern fragment is present, then `DotDotPos ` denotes its position.
10791108 /// `0 <= position <= subpats.len()`
1080- TupleStruct ( QPath < ' hir > , & ' hir [ Pat < ' hir > ] , Option < usize > ) ,
1109+ TupleStruct ( QPath < ' hir > , & ' hir [ Pat < ' hir > ] , DotDotPos ) ,
10811110
10821111 /// An or-pattern `A | B | C`.
10831112 /// Invariant: `pats.len() >= 2`.
@@ -1089,7 +1118,7 @@ pub enum PatKind<'hir> {
10891118 /// A tuple pattern (e.g., `(a, b)`).
10901119 /// If the `..` pattern fragment is present, then `Option<usize>` denotes its position.
10911120 /// `0 <= position <= subpats.len()`
1092- Tuple ( & ' hir [ Pat < ' hir > ] , Option < usize > ) ,
1121+ Tuple ( & ' hir [ Pat < ' hir > ] , DotDotPos ) ,
10931122
10941123 /// A `box` pattern.
10951124 Box ( & ' hir Pat < ' hir > ) ,
@@ -2499,7 +2528,7 @@ pub enum TyKind<'hir> {
24992528 /// A raw pointer (i.e., `*const T` or `*mut T`).
25002529 Ptr ( MutTy < ' hir > ) ,
25012530 /// A reference (i.e., `&'a T` or `&'a mut T`).
2502- Rptr ( Lifetime , MutTy < ' hir > ) ,
2531+ Rptr ( & ' hir Lifetime , MutTy < ' hir > ) ,
25032532 /// A bare function (e.g., `fn(usize) -> bool`).
25042533 BareFn ( & ' hir BareFnTy < ' hir > ) ,
25052534 /// The never type (`!`).
@@ -2518,7 +2547,7 @@ pub enum TyKind<'hir> {
25182547 OpaqueDef ( ItemId , & ' hir [ GenericArg < ' hir > ] ) ,
25192548 /// A trait object type `Bound1 + Bound2 + Bound3`
25202549 /// where `Bound` is a trait or a lifetime.
2521- TraitObject ( & ' hir [ PolyTraitRef < ' hir > ] , Lifetime , TraitObjectSyntax ) ,
2550+ TraitObject ( & ' hir [ PolyTraitRef < ' hir > ] , & ' hir Lifetime , TraitObjectSyntax ) ,
25222551 /// Unused for now.
25232552 Typeof ( AnonConst ) ,
25242553 /// `TyKind::Infer` means the type should be inferred instead of it having been
@@ -3474,7 +3503,7 @@ mod size_asserts {
34743503 static_assert_size ! ( ForeignItem <' _>, 72 ) ;
34753504 static_assert_size ! ( ForeignItemKind <' _>, 40 ) ;
34763505 #[ cfg( not( bootstrap) ) ]
3477- static_assert_size ! ( GenericArg <' _>, 32 ) ;
3506+ static_assert_size ! ( GenericArg <' _>, 24 ) ;
34783507 static_assert_size ! ( GenericBound <' _>, 48 ) ;
34793508 static_assert_size ! ( Generics <' _>, 56 ) ;
34803509 static_assert_size ! ( Impl <' _>, 80 ) ;
@@ -3486,17 +3515,17 @@ mod size_asserts {
34863515 static_assert_size ! ( ItemKind <' _>, 48 ) ;
34873516 static_assert_size ! ( Local <' _>, 64 ) ;
34883517 static_assert_size ! ( Param <' _>, 32 ) ;
3489- static_assert_size ! ( Pat <' _>, 88 ) ;
3490- static_assert_size ! ( PatKind <' _>, 64 ) ;
3518+ static_assert_size ! ( Pat <' _>, 72 ) ;
3519+ static_assert_size ! ( PatKind <' _>, 48 ) ;
34913520 static_assert_size ! ( Path <' _>, 48 ) ;
34923521 static_assert_size ! ( PathSegment <' _>, 56 ) ;
34933522 static_assert_size ! ( QPath <' _>, 24 ) ;
34943523 static_assert_size ! ( Stmt <' _>, 32 ) ;
34953524 static_assert_size ! ( StmtKind <' _>, 16 ) ;
34963525 #[ cfg( not( bootstrap) ) ]
3497- static_assert_size ! ( TraitItem <' static >, 88 ) ;
3526+ static_assert_size ! ( TraitItem <' _ >, 88 ) ;
34983527 #[ cfg( not( bootstrap) ) ]
34993528 static_assert_size ! ( TraitItemKind <' _>, 48 ) ;
3500- static_assert_size ! ( Ty <' _>, 72 ) ;
3501- static_assert_size ! ( TyKind <' _>, 56 ) ;
3529+ static_assert_size ! ( Ty <' _>, 48 ) ;
3530+ static_assert_size ! ( TyKind <' _>, 32 ) ;
35023531}
0 commit comments