11
11
use std:: cmp:: Ordering ;
12
12
use std:: fmt;
13
13
use std:: ops:: Index ;
14
+ use std:: sync:: Arc ;
14
15
15
16
use rustc_abi:: { FieldIdx , Integer , Size , VariantIdx } ;
16
17
use rustc_ast:: { AsmMacro , InlineAsmOptions , InlineAsmTemplatePiece } ;
@@ -108,7 +109,7 @@ pub enum BodyTy<'tcx> {
108
109
#[ derive( Clone , Debug , HashStable ) ]
109
110
pub struct Param < ' tcx > {
110
111
/// The pattern that appears in the parameter list, or None for implicit parameters.
111
- pub pat : Option < Box < Pat < ' tcx > > > ,
112
+ pub pat : Option < Arc < Pat < ' tcx > > > ,
112
113
/// The possibly inferred type.
113
114
pub ty : Ty < ' tcx > ,
114
115
/// Span of the explicitly provided type, or None if inferred for closures.
@@ -231,7 +232,7 @@ pub enum StmtKind<'tcx> {
231
232
/// `let <PAT> = ...`
232
233
///
233
234
/// If a type annotation is included, it is added as an ascription pattern.
234
- pattern : Box < Pat < ' tcx > > ,
235
+ pattern : Arc < Pat < ' tcx > > ,
235
236
236
237
/// `let pat: ty = <INIT>`
237
238
initializer : Option < ExprId > ,
@@ -379,7 +380,7 @@ pub enum ExprKind<'tcx> {
379
380
/// (Not to be confused with [`StmtKind::Let`], which is a normal `let` statement.)
380
381
Let {
381
382
expr : ExprId ,
382
- pat : Box < Pat < ' tcx > > ,
383
+ pat : Arc < Pat < ' tcx > > ,
383
384
} ,
384
385
/// A `match` expression.
385
386
Match {
@@ -571,7 +572,7 @@ pub struct FruInfo<'tcx> {
571
572
/// A `match` arm.
572
573
#[ derive( Clone , Debug , HashStable ) ]
573
574
pub struct Arm < ' tcx > {
574
- pub pattern : Box < Pat < ' tcx > > ,
575
+ pub pattern : Arc < Pat < ' tcx > > ,
575
576
pub guard : Option < ExprId > ,
576
577
pub body : ExprId ,
577
578
pub lint_level : LintLevel ,
@@ -628,7 +629,7 @@ pub enum InlineAsmOperand<'tcx> {
628
629
#[ derive( Clone , Debug , HashStable , TypeVisitable ) ]
629
630
pub struct FieldPat < ' tcx > {
630
631
pub field : FieldIdx ,
631
- pub pattern : Box < Pat < ' tcx > > ,
632
+ pub pattern : Arc < Pat < ' tcx > > ,
632
633
}
633
634
634
635
#[ derive( Clone , Debug , HashStable , TypeVisitable ) ]
@@ -778,7 +779,7 @@ pub enum PatKind<'tcx> {
778
779
779
780
AscribeUserType {
780
781
ascription : Ascription < ' tcx > ,
781
- subpattern : Box < Pat < ' tcx > > ,
782
+ subpattern : Arc < Pat < ' tcx > > ,
782
783
} ,
783
784
784
785
/// `x`, `ref x`, `x @ P`, etc.
@@ -789,7 +790,7 @@ pub enum PatKind<'tcx> {
789
790
#[ type_visitable( ignore) ]
790
791
var : LocalVarId ,
791
792
ty : Ty < ' tcx > ,
792
- subpattern : Option < Box < Pat < ' tcx > > > ,
793
+ subpattern : Option < Arc < Pat < ' tcx > > > ,
793
794
/// Is this the leftmost occurrence of the binding, i.e., is `var` the
794
795
/// `HirId` of this pattern?
795
796
is_primary : bool ,
@@ -812,12 +813,12 @@ pub enum PatKind<'tcx> {
812
813
813
814
/// `box P`, `&P`, `&mut P`, etc.
814
815
Deref {
815
- subpattern : Box < Pat < ' tcx > > ,
816
+ subpattern : Arc < Pat < ' tcx > > ,
816
817
} ,
817
818
818
819
/// Deref pattern, written `box P` for now.
819
820
DerefPattern {
820
- subpattern : Box < Pat < ' tcx > > ,
821
+ subpattern : Arc < Pat < ' tcx > > ,
821
822
mutability : hir:: Mutability ,
822
823
} ,
823
824
@@ -851,31 +852,31 @@ pub enum PatKind<'tcx> {
851
852
/// Otherwise, the actual pattern that the constant lowered to. As with
852
853
/// other constants, inline constants are matched structurally where
853
854
/// possible.
854
- subpattern : Box < Pat < ' tcx > > ,
855
+ subpattern : Arc < Pat < ' tcx > > ,
855
856
} ,
856
857
857
- Range ( Box < PatRange < ' tcx > > ) ,
858
+ Range ( Arc < PatRange < ' tcx > > ) ,
858
859
859
860
/// Matches against a slice, checking the length and extracting elements.
860
861
/// irrefutable when there is a slice pattern and both `prefix` and `suffix` are empty.
861
862
/// e.g., `&[ref xs @ ..]`.
862
863
Slice {
863
- prefix : Box < [ Box < Pat < ' tcx > > ] > ,
864
- slice : Option < Box < Pat < ' tcx > > > ,
865
- suffix : Box < [ Box < Pat < ' tcx > > ] > ,
864
+ prefix : Box < [ Arc < Pat < ' tcx > > ] > ,
865
+ slice : Option < Arc < Pat < ' tcx > > > ,
866
+ suffix : Box < [ Arc < Pat < ' tcx > > ] > ,
866
867
} ,
867
868
868
869
/// Fixed match against an array; irrefutable.
869
870
Array {
870
- prefix : Box < [ Box < Pat < ' tcx > > ] > ,
871
- slice : Option < Box < Pat < ' tcx > > > ,
872
- suffix : Box < [ Box < Pat < ' tcx > > ] > ,
871
+ prefix : Box < [ Arc < Pat < ' tcx > > ] > ,
872
+ slice : Option < Arc < Pat < ' tcx > > > ,
873
+ suffix : Box < [ Arc < Pat < ' tcx > > ] > ,
873
874
} ,
874
875
875
876
/// An or-pattern, e.g. `p | q`.
876
877
/// Invariant: `pats.len() >= 2`.
877
878
Or {
878
- pats : Box < [ Box < Pat < ' tcx > > ] > ,
879
+ pats : Box < [ Arc < Pat < ' tcx > > ] > ,
879
880
} ,
880
881
881
882
/// A never pattern `!`.
0 commit comments