@@ -180,7 +180,7 @@ pub enum StmtKind<'tcx> {
180
180
/// `let <PAT> = ...`
181
181
///
182
182
/// If a type annotation is included, it is added as an ascription pattern.
183
- pattern : Pat < ' tcx > ,
183
+ pattern : Box < Pat < ' tcx > > ,
184
184
185
185
/// `let pat: ty = <INIT>`
186
186
initializer : Option < ExprId > ,
@@ -301,7 +301,7 @@ pub enum ExprKind<'tcx> {
301
301
} ,
302
302
Let {
303
303
expr : ExprId ,
304
- pat : Pat < ' tcx > ,
304
+ pat : Box < Pat < ' tcx > > ,
305
305
} ,
306
306
/// A `match` expression.
307
307
Match {
@@ -467,7 +467,7 @@ pub struct FruInfo<'tcx> {
467
467
/// A `match` arm.
468
468
#[ derive( Clone , Debug , HashStable ) ]
469
469
pub struct Arm < ' tcx > {
470
- pub pattern : Pat < ' tcx > ,
470
+ pub pattern : Box < Pat < ' tcx > > ,
471
471
pub guard : Option < Guard < ' tcx > > ,
472
472
pub body : ExprId ,
473
473
pub lint_level : LintLevel ,
@@ -479,7 +479,7 @@ pub struct Arm<'tcx> {
479
479
#[ derive( Clone , Debug , HashStable ) ]
480
480
pub enum Guard < ' tcx > {
481
481
If ( ExprId ) ,
482
- IfLet ( Pat < ' tcx > , ExprId ) ,
482
+ IfLet ( Box < Pat < ' tcx > > , ExprId ) ,
483
483
}
484
484
485
485
#[ derive( Copy , Clone , Debug , HashStable ) ]
@@ -534,19 +534,19 @@ pub enum BindingMode {
534
534
#[ derive( Clone , Debug , HashStable ) ]
535
535
pub struct FieldPat < ' tcx > {
536
536
pub field : Field ,
537
- pub pattern : Pat < ' tcx > ,
537
+ pub pattern : Box < Pat < ' tcx > > ,
538
538
}
539
539
540
540
#[ derive( Clone , Debug , HashStable ) ]
541
541
pub struct Pat < ' tcx > {
542
542
pub ty : Ty < ' tcx > ,
543
543
pub span : Span ,
544
- pub kind : Box < PatKind < ' tcx > > ,
544
+ pub kind : PatKind < ' tcx > ,
545
545
}
546
546
547
547
impl < ' tcx > Pat < ' tcx > {
548
548
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 }
550
550
}
551
551
}
552
552
@@ -581,7 +581,7 @@ pub enum PatKind<'tcx> {
581
581
582
582
AscribeUserType {
583
583
ascription : Ascription < ' tcx > ,
584
- subpattern : Pat < ' tcx > ,
584
+ subpattern : Box < Pat < ' tcx > > ,
585
585
} ,
586
586
587
587
/// `x`, `ref x`, `x @ P`, etc.
@@ -591,7 +591,7 @@ pub enum PatKind<'tcx> {
591
591
mode : BindingMode ,
592
592
var : LocalVarId ,
593
593
ty : Ty < ' tcx > ,
594
- subpattern : Option < Pat < ' tcx > > ,
594
+ subpattern : Option < Box < Pat < ' tcx > > > ,
595
595
/// Is this the leftmost occurrence of the binding, i.e., is `var` the
596
596
/// `HirId` of this pattern?
597
597
is_primary : bool ,
@@ -614,7 +614,7 @@ pub enum PatKind<'tcx> {
614
614
615
615
/// `box P`, `&P`, `&mut P`, etc.
616
616
Deref {
617
- subpattern : Pat < ' tcx > ,
617
+ subpattern : Box < Pat < ' tcx > > ,
618
618
} ,
619
619
620
620
/// One of the following:
@@ -628,32 +628,32 @@ pub enum PatKind<'tcx> {
628
628
value : mir:: ConstantKind < ' tcx > ,
629
629
} ,
630
630
631
- Range ( PatRange < ' tcx > ) ,
631
+ Range ( Box < PatRange < ' tcx > > ) ,
632
632
633
633
/// Matches against a slice, checking the length and extracting elements.
634
634
/// irrefutable when there is a slice pattern and both `prefix` and `suffix` are empty.
635
635
/// e.g., `&[ref xs @ ..]`.
636
636
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 > > ] > ,
640
640
} ,
641
641
642
642
/// Fixed match against an array; irrefutable.
643
643
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 > > ] > ,
647
647
} ,
648
648
649
649
/// An or-pattern, e.g. `p | q`.
650
650
/// Invariant: `pats.len() >= 2`.
651
651
Or {
652
- pats : Vec < Pat < ' tcx > > ,
652
+ pats : Box < [ Box < Pat < ' tcx > > ] > ,
653
653
} ,
654
654
}
655
655
656
- #[ derive( Copy , Clone , Debug , PartialEq , HashStable ) ]
656
+ #[ derive( Clone , Debug , PartialEq , HashStable ) ]
657
657
pub struct PatRange < ' tcx > {
658
658
pub lo : mir:: ConstantKind < ' tcx > ,
659
659
pub hi : mir:: ConstantKind < ' tcx > ,
@@ -674,7 +674,7 @@ impl<'tcx> fmt::Display for Pat<'tcx> {
674
674
} ;
675
675
let mut start_or_comma = || start_or_continue ( ", " ) ;
676
676
677
- match * self . kind {
677
+ match self . kind {
678
678
PatKind :: Wild => write ! ( f, "_" ) ,
679
679
PatKind :: AscribeUserType { ref subpattern, .. } => write ! ( f, "{}: _" , subpattern) ,
680
680
PatKind :: Binding { mutability, name, mode, ref subpattern, .. } => {
@@ -695,7 +695,7 @@ impl<'tcx> fmt::Display for Pat<'tcx> {
695
695
Ok ( ( ) )
696
696
}
697
697
PatKind :: Variant { ref subpatterns, .. } | PatKind :: Leaf { ref subpatterns } => {
698
- let variant = match * self . kind {
698
+ let variant = match self . kind {
699
699
PatKind :: Variant { adt_def, variant_index, .. } => {
700
700
Some ( adt_def. variant ( variant_index) )
701
701
}
@@ -714,7 +714,7 @@ impl<'tcx> fmt::Display for Pat<'tcx> {
714
714
715
715
let mut printed = 0 ;
716
716
for p in subpatterns {
717
- if let PatKind :: Wild = * p. pattern . kind {
717
+ if let PatKind :: Wild = p. pattern . kind {
718
718
continue ;
719
719
}
720
720
let name = variant. fields [ p. field . index ( ) ] . name ;
@@ -767,32 +767,32 @@ impl<'tcx> fmt::Display for Pat<'tcx> {
767
767
write ! ( f, "{}" , subpattern)
768
768
}
769
769
PatKind :: Constant { value } => write ! ( f, "{}" , value) ,
770
- PatKind :: Range ( PatRange { lo, hi, end } ) => {
770
+ PatKind :: Range ( box PatRange { lo, hi, end } ) => {
771
771
write ! ( f, "{}" , lo) ?;
772
772
write ! ( f, "{}" , end) ?;
773
773
write ! ( f, "{}" , hi)
774
774
}
775
775
PatKind :: Slice { ref prefix, ref slice, ref suffix }
776
776
| PatKind :: Array { ref prefix, ref slice, ref suffix } => {
777
777
write ! ( f, "[" ) ?;
778
- for p in prefix {
778
+ for p in prefix. iter ( ) {
779
779
write ! ( f, "{}{}" , start_or_comma( ) , p) ?;
780
780
}
781
781
if let Some ( ref slice) = * slice {
782
782
write ! ( f, "{}" , start_or_comma( ) ) ?;
783
- match * slice. kind {
783
+ match slice. kind {
784
784
PatKind :: Wild => { }
785
785
_ => write ! ( f, "{}" , slice) ?,
786
786
}
787
787
write ! ( f, ".." ) ?;
788
788
}
789
- for p in suffix {
789
+ for p in suffix. iter ( ) {
790
790
write ! ( f, "{}{}" , start_or_comma( ) , p) ?;
791
791
}
792
792
write ! ( f, "]" )
793
793
}
794
794
PatKind :: Or { ref pats } => {
795
- for pat in pats {
795
+ for pat in pats. iter ( ) {
796
796
write ! ( f, "{}{}" , start_or_continue( " | " ) , pat) ?;
797
797
}
798
798
Ok ( ( ) )
@@ -809,8 +809,8 @@ mod size_asserts {
809
809
static_assert_size ! ( Block , 56 ) ;
810
810
static_assert_size ! ( Expr <' _>, 64 ) ;
811
811
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 ) ;
816
816
}
0 commit comments