@@ -727,7 +727,7 @@ pub(crate) enum ItemKind {
727727 OpaqueTyItem ( OpaqueTy ) ,
728728 StaticItem ( Static ) ,
729729 ConstantItem ( Constant ) ,
730- TraitItem ( Trait ) ,
730+ TraitItem ( Box < Trait > ) ,
731731 TraitAliasItem ( TraitAlias ) ,
732732 ImplItem ( Box < Impl > ) ,
733733 /// A required method in a trait declaration meaning it's only a function signature.
@@ -1550,13 +1550,7 @@ pub(crate) enum Type {
15501550 BorrowedRef { lifetime : Option < Lifetime > , mutability : Mutability , type_ : Box < Type > } ,
15511551
15521552 /// A qualified path to an associated item: `<Type as Trait>::Name`
1553- QPath {
1554- assoc : Box < PathSegment > ,
1555- self_type : Box < Type > ,
1556- /// FIXME: compute this field on demand.
1557- should_show_cast : bool ,
1558- trait_ : Path ,
1559- } ,
1553+ QPath ( Box < QPathData > ) ,
15601554
15611555 /// A type that is inferred: `_`
15621556 Infer ,
@@ -1654,8 +1648,8 @@ impl Type {
16541648 }
16551649
16561650 pub ( crate ) fn projection ( & self ) -> Option < ( & Type , DefId , PathSegment ) > {
1657- if let QPath { self_type, trait_, assoc, .. } = self {
1658- Some ( ( self_type, trait_. def_id ( ) , * assoc. clone ( ) ) )
1651+ if let QPath ( box QPathData { self_type, trait_, assoc, .. } ) = self {
1652+ Some ( ( self_type, trait_. def_id ( ) , assoc. clone ( ) ) )
16591653 } else {
16601654 None
16611655 }
@@ -1679,7 +1673,7 @@ impl Type {
16791673 Slice ( ..) => PrimitiveType :: Slice ,
16801674 Array ( ..) => PrimitiveType :: Array ,
16811675 RawPointer ( ..) => PrimitiveType :: RawPointer ,
1682- QPath { ref self_type, .. } => return self_type. inner_def_id ( cache) ,
1676+ QPath ( box QPathData { ref self_type, .. } ) => return self_type. inner_def_id ( cache) ,
16831677 Generic ( _) | Infer | ImplTrait ( _) => return None ,
16841678 } ;
16851679 cache. and_then ( |c| Primitive ( t) . def_id ( c) )
@@ -1693,6 +1687,15 @@ impl Type {
16931687 }
16941688}
16951689
1690+ #[ derive( Clone , PartialEq , Eq , Debug , Hash ) ]
1691+ pub ( crate ) struct QPathData {
1692+ pub assoc : PathSegment ,
1693+ pub self_type : Type ,
1694+ /// FIXME: compute this field on demand.
1695+ pub should_show_cast : bool ,
1696+ pub trait_ : Path ,
1697+ }
1698+
16961699/// A primitive (aka, builtin) type.
16971700///
16981701/// This represents things like `i32`, `str`, etc.
@@ -2484,11 +2487,11 @@ mod size_asserts {
24842487 // These are in alphabetical order, which is easy to maintain.
24852488 static_assert_size ! ( Crate , 72 ) ; // frequently moved by-value
24862489 static_assert_size ! ( DocFragment , 32 ) ;
2487- static_assert_size ! ( GenericArg , 80 ) ;
2490+ static_assert_size ! ( GenericArg , 64 ) ;
24882491 static_assert_size ! ( GenericArgs , 32 ) ;
24892492 static_assert_size ! ( GenericParamDef , 56 ) ;
24902493 static_assert_size ! ( Item , 56 ) ;
2491- static_assert_size ! ( ItemKind , 112 ) ;
2494+ static_assert_size ! ( ItemKind , 96 ) ;
24922495 static_assert_size ! ( PathSegment , 40 ) ;
2493- static_assert_size ! ( Type , 72 ) ;
2496+ static_assert_size ! ( Type , 56 ) ;
24942497}
0 commit comments