@@ -180,7 +180,7 @@ pub enum StmtKind<'tcx> {
180180 /// `let <PAT> = ...`
181181 ///
182182 /// If a type annotation is included, it is added as an ascription pattern.
183- pattern : Pat < ' tcx > ,
183+ pattern : Box < Pat < ' tcx > > ,
184184
185185 /// `let pat: ty = <INIT>`
186186 initializer : Option < ExprId > ,
@@ -301,7 +301,7 @@ pub enum ExprKind<'tcx> {
301301 } ,
302302 Let {
303303 expr : ExprId ,
304- pat : Pat < ' tcx > ,
304+ pat : Box < Pat < ' tcx > > ,
305305 } ,
306306 /// A `match` expression.
307307 Match {
@@ -467,7 +467,7 @@ pub struct FruInfo<'tcx> {
467467/// A `match` arm.
468468#[ derive( Clone , Debug , HashStable ) ]
469469pub struct Arm < ' tcx > {
470- pub pattern : Pat < ' tcx > ,
470+ pub pattern : Box < Pat < ' tcx > > ,
471471 pub guard : Option < Guard < ' tcx > > ,
472472 pub body : ExprId ,
473473 pub lint_level : LintLevel ,
@@ -479,7 +479,7 @@ pub struct Arm<'tcx> {
479479#[ derive( Clone , Debug , HashStable ) ]
480480pub enum Guard < ' tcx > {
481481 If ( ExprId ) ,
482- IfLet ( Pat < ' tcx > , ExprId ) ,
482+ IfLet ( Box < Pat < ' tcx > > , ExprId ) ,
483483}
484484
485485#[ derive( Copy , Clone , Debug , HashStable ) ]
@@ -534,19 +534,19 @@ pub enum BindingMode {
534534#[ derive( Clone , Debug , HashStable ) ]
535535pub struct FieldPat < ' tcx > {
536536 pub field : Field ,
537- pub pattern : Pat < ' tcx > ,
537+ pub pattern : Box < Pat < ' tcx > > ,
538538}
539539
540540#[ derive( Clone , Debug , HashStable ) ]
541541pub struct Pat < ' tcx > {
542542 pub ty : Ty < ' tcx > ,
543543 pub span : Span ,
544- pub kind : Box < PatKind < ' tcx > > ,
544+ pub kind : PatKind < ' tcx > ,
545545}
546546
547547impl < ' tcx > Pat < ' tcx > {
548548 pub fn wildcard_from_ty ( ty : Ty < ' tcx > ) -> Self {
549- Pat { ty, span : DUMMY_SP , kind : Box :: new ( PatKind :: Wild ) }
549+ Pat { ty, span : DUMMY_SP , kind : PatKind :: Wild }
550550 }
551551}
552552
@@ -581,7 +581,7 @@ pub enum PatKind<'tcx> {
581581
582582 AscribeUserType {
583583 ascription : Ascription < ' tcx > ,
584- subpattern : Pat < ' tcx > ,
584+ subpattern : Box < Pat < ' tcx > > ,
585585 } ,
586586
587587 /// `x`, `ref x`, `x @ P`, etc.
@@ -591,7 +591,7 @@ pub enum PatKind<'tcx> {
591591 mode : BindingMode ,
592592 var : LocalVarId ,
593593 ty : Ty < ' tcx > ,
594- subpattern : Option < Pat < ' tcx > > ,
594+ subpattern : Option < Box < Pat < ' tcx > > > ,
595595 /// Is this the leftmost occurrence of the binding, i.e., is `var` the
596596 /// `HirId` of this pattern?
597597 is_primary : bool ,
@@ -614,7 +614,7 @@ pub enum PatKind<'tcx> {
614614
615615 /// `box P`, `&P`, `&mut P`, etc.
616616 Deref {
617- subpattern : Pat < ' tcx > ,
617+ subpattern : Box < Pat < ' tcx > > ,
618618 } ,
619619
620620 /// One of the following:
@@ -628,32 +628,32 @@ pub enum PatKind<'tcx> {
628628 value : mir:: ConstantKind < ' tcx > ,
629629 } ,
630630
631- Range ( PatRange < ' tcx > ) ,
631+ Range ( Box < PatRange < ' tcx > > ) ,
632632
633633 /// Matches against a slice, checking the length and extracting elements.
634634 /// irrefutable when there is a slice pattern and both `prefix` and `suffix` are empty.
635635 /// e.g., `&[ref xs @ ..]`.
636636 Slice {
637- prefix : Vec < Pat < ' tcx > > ,
638- slice : Option < Pat < ' tcx > > ,
639- suffix : Vec < Pat < ' tcx > > ,
637+ prefix : Box < [ Box < Pat < ' tcx > > ] > ,
638+ slice : Option < Box < Pat < ' tcx > > > ,
639+ suffix : Box < [ Box < Pat < ' tcx > > ] > ,
640640 } ,
641641
642642 /// Fixed match against an array; irrefutable.
643643 Array {
644- prefix : Vec < Pat < ' tcx > > ,
645- slice : Option < Pat < ' tcx > > ,
646- suffix : Vec < Pat < ' tcx > > ,
644+ prefix : Box < [ Box < Pat < ' tcx > > ] > ,
645+ slice : Option < Box < Pat < ' tcx > > > ,
646+ suffix : Box < [ Box < Pat < ' tcx > > ] > ,
647647 } ,
648648
649649 /// An or-pattern, e.g. `p | q`.
650650 /// Invariant: `pats.len() >= 2`.
651651 Or {
652- pats : Vec < Pat < ' tcx > > ,
652+ pats : Box < [ Box < Pat < ' tcx > > ] > ,
653653 } ,
654654}
655655
656- #[ derive( Copy , Clone , Debug , PartialEq , HashStable ) ]
656+ #[ derive( Clone , Debug , PartialEq , HashStable ) ]
657657pub struct PatRange < ' tcx > {
658658 pub lo : mir:: ConstantKind < ' tcx > ,
659659 pub hi : mir:: ConstantKind < ' tcx > ,
@@ -674,7 +674,7 @@ impl<'tcx> fmt::Display for Pat<'tcx> {
674674 } ;
675675 let mut start_or_comma = || start_or_continue ( ", " ) ;
676676
677- match * self . kind {
677+ match self . kind {
678678 PatKind :: Wild => write ! ( f, "_" ) ,
679679 PatKind :: AscribeUserType { ref subpattern, .. } => write ! ( f, "{}: _" , subpattern) ,
680680 PatKind :: Binding { mutability, name, mode, ref subpattern, .. } => {
@@ -695,7 +695,7 @@ impl<'tcx> fmt::Display for Pat<'tcx> {
695695 Ok ( ( ) )
696696 }
697697 PatKind :: Variant { ref subpatterns, .. } | PatKind :: Leaf { ref subpatterns } => {
698- let variant = match * self . kind {
698+ let variant = match self . kind {
699699 PatKind :: Variant { adt_def, variant_index, .. } => {
700700 Some ( adt_def. variant ( variant_index) )
701701 }
@@ -714,7 +714,7 @@ impl<'tcx> fmt::Display for Pat<'tcx> {
714714
715715 let mut printed = 0 ;
716716 for p in subpatterns {
717- if let PatKind :: Wild = * p. pattern . kind {
717+ if let PatKind :: Wild = p. pattern . kind {
718718 continue ;
719719 }
720720 let name = variant. fields [ p. field . index ( ) ] . name ;
@@ -767,32 +767,32 @@ impl<'tcx> fmt::Display for Pat<'tcx> {
767767 write ! ( f, "{}" , subpattern)
768768 }
769769 PatKind :: Constant { value } => write ! ( f, "{}" , value) ,
770- PatKind :: Range ( PatRange { lo, hi, end } ) => {
770+ PatKind :: Range ( box PatRange { lo, hi, end } ) => {
771771 write ! ( f, "{}" , lo) ?;
772772 write ! ( f, "{}" , end) ?;
773773 write ! ( f, "{}" , hi)
774774 }
775775 PatKind :: Slice { ref prefix, ref slice, ref suffix }
776776 | PatKind :: Array { ref prefix, ref slice, ref suffix } => {
777777 write ! ( f, "[" ) ?;
778- for p in prefix {
778+ for p in prefix. iter ( ) {
779779 write ! ( f, "{}{}" , start_or_comma( ) , p) ?;
780780 }
781781 if let Some ( ref slice) = * slice {
782782 write ! ( f, "{}" , start_or_comma( ) ) ?;
783- match * slice. kind {
783+ match slice. kind {
784784 PatKind :: Wild => { }
785785 _ => write ! ( f, "{}" , slice) ?,
786786 }
787787 write ! ( f, ".." ) ?;
788788 }
789- for p in suffix {
789+ for p in suffix. iter ( ) {
790790 write ! ( f, "{}{}" , start_or_comma( ) , p) ?;
791791 }
792792 write ! ( f, "]" )
793793 }
794794 PatKind :: Or { ref pats } => {
795- for pat in pats {
795+ for pat in pats. iter ( ) {
796796 write ! ( f, "{}{}" , start_or_continue( " | " ) , pat) ?;
797797 }
798798 Ok ( ( ) )
@@ -809,8 +809,8 @@ mod size_asserts {
809809 static_assert_size ! ( Block , 56 ) ;
810810 static_assert_size ! ( Expr <' _>, 64 ) ;
811811 static_assert_size ! ( ExprKind <' _>, 40 ) ;
812- static_assert_size ! ( Pat <' _>, 24 ) ;
813- static_assert_size ! ( PatKind <' _>, 112 ) ;
814- static_assert_size ! ( Stmt <' _>, 72 ) ;
815- static_assert_size ! ( StmtKind <' _>, 64 ) ;
812+ static_assert_size ! ( Pat <' _>, 72 ) ;
813+ static_assert_size ! ( PatKind <' _>, 56 ) ;
814+ static_assert_size ! ( Stmt <' _>, 56 ) ;
815+ static_assert_size ! ( StmtKind <' _>, 48 ) ;
816816}
0 commit comments