@@ -344,7 +344,7 @@ pub struct ParenthesizedArgs {
344344 pub span : Span ,
345345
346346 /// `(A, B)`
347- pub inputs : ThinVec < Box < Ty > > ,
347+ pub inputs : ThinVec < Ty > ,
348348
349349 /// ```text
350350 /// Foo(A, B) -> C
@@ -361,8 +361,7 @@ impl ParenthesizedArgs {
361361 let args = self
362362 . inputs
363363 . iter ( )
364- . cloned ( )
365- . map ( |input| AngleBracketedArg :: Arg ( GenericArg :: Type ( input) ) )
364+ . map ( |input| AngleBracketedArg :: Arg ( GenericArg :: Type ( Box :: new ( input. clone ( ) ) ) ) )
366365 . collect ( ) ;
367366 AngleBracketedArgs { span : self . inputs_span , args }
368367 }
@@ -632,37 +631,37 @@ pub struct Pat {
632631impl Pat {
633632 /// Attempt reparsing the pattern as a type.
634633 /// This is intended for use by diagnostics.
635- pub fn to_ty ( & self ) -> Option < Box < Ty > > {
636- let kind = match & self . kind {
634+ pub fn to_ty ( & self ) -> Option < Ty > {
635+ let kind = match self . kind {
637636 PatKind :: Missing => unreachable ! ( ) ,
638637 // In a type expression `_` is an inference variable.
639638 PatKind :: Wild => TyKind :: Infer ,
640639 // An IDENT pattern with no binding mode would be valid as path to a type. E.g. `u32`.
641640 PatKind :: Ident ( BindingMode :: NONE , ident, None ) => {
642- TyKind :: Path ( None , Path :: from_ident ( * ident) )
641+ TyKind :: Path ( None , Path :: from_ident ( ident) )
643642 }
644- PatKind :: Path ( qself, path) => TyKind :: Path ( qself. clone ( ) , path. clone ( ) ) ,
645- PatKind :: MacCall ( mac) => TyKind :: MacCall ( mac. clone ( ) ) ,
643+ PatKind :: Path ( ref qself, ref path) => TyKind :: Path ( qself. clone ( ) , path. clone ( ) ) ,
644+ PatKind :: MacCall ( ref mac) => TyKind :: MacCall ( mac. clone ( ) ) ,
646645 // `&mut? P` can be reinterpreted as `&mut? T` where `T` is `P` reparsed as a type.
647- PatKind :: Ref ( pat, pinned, mutbl) => pat. to_ty ( ) . map ( |ty| match pinned {
648- Pinnedness :: Not => TyKind :: Ref ( None , MutTy { ty, mutbl : * mutbl } ) ,
649- Pinnedness :: Pinned => TyKind :: PinnedRef ( None , MutTy { ty, mutbl : * mutbl } ) ,
646+ PatKind :: Ref ( ref pat, pinned, mutbl) => pat. to_ty ( ) . map ( |ty| match pinned {
647+ Pinnedness :: Not => TyKind :: Ref ( None , MutTy { ty : Box :: new ( ty ) , mutbl } ) ,
648+ Pinnedness :: Pinned => TyKind :: PinnedRef ( None , MutTy { ty : Box :: new ( ty ) , mutbl } ) ,
650649 } ) ?,
651650 // A slice/array pattern `[P]` can be reparsed as `[T]`, an unsized array,
652651 // when `P` can be reparsed as a type `T`.
653- PatKind :: Slice ( pats) if let [ pat] = pats. as_slice ( ) => {
654- pat. to_ty ( ) . map ( TyKind :: Slice ) ?
652+ PatKind :: Slice ( ref pats) if let [ pat] = pats. as_slice ( ) => {
653+ TyKind :: Slice ( Box :: new ( pat. to_ty ( ) ? ) )
655654 }
656655 // A tuple pattern `(P0, .., Pn)` can be reparsed as `(T0, .., Tn)`
657656 // assuming `T0` to `Tn` are all syntactically valid as types.
658- PatKind :: Tuple ( pats) => {
657+ PatKind :: Tuple ( ref pats) => {
659658 let tys = pats. iter ( ) . map ( |pat| pat. to_ty ( ) ) . collect :: < Option < ThinVec < _ > > > ( ) ?;
660659 TyKind :: Tup ( tys)
661660 }
662661 _ => return None ,
663662 } ;
664663
665- Some ( Box :: new ( Ty { kind, id : self . id , span : self . span , tokens : None } ) )
664+ Some ( Ty { kind, id : self . id , span : self . span , tokens : None } )
666665 }
667666
668667 /// Walk top-down and call `it` in each place where a pattern occurs
@@ -1501,24 +1500,24 @@ impl Expr {
15011500 }
15021501
15031502 /// Attempts to reparse as `Ty` (for diagnostic purposes).
1504- pub fn to_ty ( & self ) -> Option < Box < Ty > > {
1503+ pub fn to_ty ( & self ) -> Option < Ty > {
15051504 let kind = match & self . kind {
15061505 // Trivial conversions.
15071506 ExprKind :: Path ( qself, path) => TyKind :: Path ( qself. clone ( ) , path. clone ( ) ) ,
15081507 ExprKind :: MacCall ( mac) => TyKind :: MacCall ( mac. clone ( ) ) ,
15091508
1510- ExprKind :: Paren ( expr) => expr. to_ty ( ) . map ( TyKind :: Paren ) ? ,
1509+ ExprKind :: Paren ( expr) => TyKind :: Paren ( Box :: new ( expr. to_ty ( ) ? ) ) ,
15111510
1512- ExprKind :: AddrOf ( BorrowKind :: Ref , mutbl, expr) => {
1513- expr . to_ty ( ) . map ( |ty| TyKind :: Ref ( None , MutTy { ty , mutbl : * mutbl } ) ) ?
1514- }
1511+ ExprKind :: AddrOf ( BorrowKind :: Ref , mutbl, expr) => expr
1512+ . to_ty ( )
1513+ . map ( |ty| TyKind :: Ref ( None , MutTy { ty : Box :: new ( ty ) , mutbl : * mutbl } ) ) ? ,
15151514
15161515 ExprKind :: Repeat ( expr, expr_len) => {
1517- expr. to_ty ( ) . map ( |ty| TyKind :: Array ( ty , expr_len. clone ( ) ) ) ?
1516+ expr. to_ty ( ) . map ( |ty| TyKind :: Array ( Box :: new ( ty ) , expr_len. clone ( ) ) ) ?
15181517 }
15191518
15201519 ExprKind :: Array ( exprs) if let [ expr] = exprs. as_slice ( ) => {
1521- expr. to_ty ( ) . map ( TyKind :: Slice ) ?
1520+ TyKind :: Slice ( Box :: new ( expr. to_ty ( ) ? ) )
15221521 }
15231522
15241523 ExprKind :: Tup ( exprs) => {
@@ -1542,7 +1541,7 @@ impl Expr {
15421541 _ => return None ,
15431542 } ;
15441543
1545- Some ( Box :: new ( Ty { kind, id : self . id , span : self . span , tokens : None } ) )
1544+ Some ( Ty { kind, id : self . id , span : self . span , tokens : None } )
15461545 }
15471546
15481547 pub fn precedence ( & self ) -> ExprPrecedence {
@@ -1978,7 +1977,7 @@ pub enum UnsafeBinderCastKind {
19781977/// ```
19791978#[ derive( Clone , Encodable , Decodable , Debug , Walkable ) ]
19801979pub struct QSelf {
1981- pub ty : Box < Ty > ,
1980+ pub ty : Ty ,
19821981
19831982 /// The span of `a::b::Trait` in a path like `<Vec<T> as
19841983 /// a::b::Trait>::AssociatedItem`; in the case where `position ==
@@ -2409,18 +2408,6 @@ pub enum Term {
24092408 Const ( AnonConst ) ,
24102409}
24112410
2412- impl From < Box < Ty > > for Term {
2413- fn from ( v : Box < Ty > ) -> Self {
2414- Term :: Ty ( v)
2415- }
2416- }
2417-
2418- impl From < AnonConst > for Term {
2419- fn from ( v : AnonConst ) -> Self {
2420- Term :: Const ( v)
2421- }
2422- }
2423-
24242411/// The kind of [associated item constraint][AssocItemConstraint].
24252412#[ derive( Clone , Encodable , Decodable , Debug , Walkable ) ]
24262413pub enum AssocItemConstraintKind {
@@ -2496,7 +2483,7 @@ pub struct FnPtrTy {
24962483#[ derive( Clone , Encodable , Decodable , Debug , Walkable ) ]
24972484pub struct UnsafeBinderTy {
24982485 pub generic_params : ThinVec < GenericParam > ,
2499- pub inner_ty : Box < Ty > ,
2486+ pub inner_ty : Ty ,
25002487}
25012488
25022489/// The various kinds of type recognized by the compiler.
@@ -2523,7 +2510,7 @@ pub enum TyKind {
25232510 /// The never type (`!`).
25242511 Never ,
25252512 /// A tuple (`(A, B, C, D,...)`).
2526- Tup ( ThinVec < Box < Ty > > ) ,
2513+ Tup ( ThinVec < Ty > ) ,
25272514 /// A path (`module::module::...::Type`), optionally
25282515 /// "qualified", e.g., `<Vec<T> as SomeTrait>::SomeType`.
25292516 ///
@@ -2907,7 +2894,7 @@ pub struct InlineAsm {
29072894#[ derive( Clone , Encodable , Decodable , Debug , Walkable ) ]
29082895pub struct Param {
29092896 pub attrs : AttrVec ,
2910- pub ty : Box < Ty > ,
2897+ pub ty : Ty ,
29112898 pub pat : Box < Pat > ,
29122899 pub id : NodeId ,
29132900 pub span : Span ,
@@ -2926,7 +2913,7 @@ pub enum SelfKind {
29262913 /// `&'lt pin const self`, `&'lt pin mut self`
29272914 Pinned ( Option < Lifetime > , Mutability ) ,
29282915 /// `self: TYPE`, `mut self: TYPE`
2929- Explicit ( Box < Ty > , Mutability ) ,
2916+ Explicit ( Ty , Mutability ) ,
29302917}
29312918
29322919impl SelfKind {
@@ -2982,32 +2969,32 @@ impl Param {
29822969 /// Builds a `Param` object from `ExplicitSelf`.
29832970 pub fn from_self ( attrs : AttrVec , eself : ExplicitSelf , eself_ident : Ident ) -> Param {
29842971 let span = eself. span . to ( eself_ident. span ) ;
2985- let infer_ty = Box :: new ( Ty {
2972+ let infer_ty = Ty {
29862973 id : DUMMY_NODE_ID ,
29872974 kind : TyKind :: ImplicitSelf ,
29882975 span : eself_ident. span ,
29892976 tokens : None ,
2990- } ) ;
2977+ } ;
29912978 let ( mutbl, ty) = match eself. node {
29922979 SelfKind :: Explicit ( ty, mutbl) => ( mutbl, ty) ,
29932980 SelfKind :: Value ( mutbl) => ( mutbl, infer_ty) ,
29942981 SelfKind :: Region ( lt, mutbl) => (
29952982 Mutability :: Not ,
2996- Box :: new ( Ty {
2983+ Ty {
29972984 id : DUMMY_NODE_ID ,
2998- kind : TyKind :: Ref ( lt, MutTy { ty : infer_ty, mutbl } ) ,
2985+ kind : TyKind :: Ref ( lt, MutTy { ty : Box :: new ( infer_ty) , mutbl } ) ,
29992986 span,
30002987 tokens : None ,
3001- } ) ,
2988+ } ,
30022989 ) ,
30032990 SelfKind :: Pinned ( lt, mutbl) => (
30042991 mutbl,
3005- Box :: new ( Ty {
2992+ Ty {
30062993 id : DUMMY_NODE_ID ,
3007- kind : TyKind :: PinnedRef ( lt, MutTy { ty : infer_ty, mutbl } ) ,
2994+ kind : TyKind :: PinnedRef ( lt, MutTy { ty : Box :: new ( infer_ty) , mutbl } ) ,
30082995 span,
30092996 tokens : None ,
3010- } ) ,
2997+ } ,
30112998 ) ,
30122999 } ;
30133000 Param {
@@ -3554,7 +3541,7 @@ pub struct FieldDef {
35543541 pub safety : Safety ,
35553542 pub ident : Option < Ident > ,
35563543
3557- pub ty : Box < Ty > ,
3544+ pub ty : Ty ,
35583545 pub default : Option < AnonConst > ,
35593546 pub is_placeholder : bool ,
35603547}
@@ -3864,7 +3851,7 @@ pub struct DelegationMac {
38643851#[ derive( Clone , Encodable , Decodable , Debug , Walkable ) ]
38653852pub struct StaticItem {
38663853 pub ident : Ident ,
3867- pub ty : Box < Ty > ,
3854+ pub ty : Ty ,
38683855 pub safety : Safety ,
38693856 pub mutability : Mutability ,
38703857 pub expr : Option < Box < Expr > > ,
@@ -3876,7 +3863,7 @@ pub struct ConstItem {
38763863 pub defaultness : Defaultness ,
38773864 pub ident : Ident ,
38783865 pub generics : Generics ,
3879- pub ty : Box < Ty > ,
3866+ pub ty : Ty ,
38803867 pub rhs_kind : ConstItemRhsKind ,
38813868 pub define_opaque : Option < ThinVec < ( NodeId , Path ) > > ,
38823869}
@@ -4262,7 +4249,7 @@ mod size_asserts {
42624249 static_assert_size ! ( LitKind , 24 ) ;
42634250 static_assert_size ! ( Local , 96 ) ;
42644251 static_assert_size ! ( MetaItemLit , 40 ) ;
4265- static_assert_size ! ( Param , 40 ) ;
4252+ static_assert_size ! ( Param , 96 ) ;
42664253 static_assert_size ! ( Pat , 80 ) ;
42674254 static_assert_size ! ( PatKind , 56 ) ;
42684255 static_assert_size ! ( Path , 24 ) ;
0 commit comments