1111use std:: cmp:: Ordering ;
1212use std:: fmt;
1313use std:: ops:: Index ;
14+ use std:: sync:: Arc ;
1415
1516use rustc_abi:: { FieldIdx , Integer , Size , VariantIdx } ;
1617use rustc_ast:: { AsmMacro , InlineAsmOptions , InlineAsmTemplatePiece } ;
@@ -108,7 +109,7 @@ pub enum BodyTy<'tcx> {
108109#[ derive( Clone , Debug , HashStable ) ]
109110pub struct Param < ' tcx > {
110111 /// 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 > > > ,
112113 /// The possibly inferred type.
113114 pub ty : Ty < ' tcx > ,
114115 /// Span of the explicitly provided type, or None if inferred for closures.
@@ -231,7 +232,7 @@ pub enum StmtKind<'tcx> {
231232 /// `let <PAT> = ...`
232233 ///
233234 /// If a type annotation is included, it is added as an ascription pattern.
234- pattern : Box < Pat < ' tcx > > ,
235+ pattern : Arc < Pat < ' tcx > > ,
235236
236237 /// `let pat: ty = <INIT>`
237238 initializer : Option < ExprId > ,
@@ -379,7 +380,7 @@ pub enum ExprKind<'tcx> {
379380 /// (Not to be confused with [`StmtKind::Let`], which is a normal `let` statement.)
380381 Let {
381382 expr : ExprId ,
382- pat : Box < Pat < ' tcx > > ,
383+ pat : Arc < Pat < ' tcx > > ,
383384 } ,
384385 /// A `match` expression.
385386 Match {
@@ -571,7 +572,7 @@ pub struct FruInfo<'tcx> {
571572/// A `match` arm.
572573#[ derive( Clone , Debug , HashStable ) ]
573574pub struct Arm < ' tcx > {
574- pub pattern : Box < Pat < ' tcx > > ,
575+ pub pattern : Arc < Pat < ' tcx > > ,
575576 pub guard : Option < ExprId > ,
576577 pub body : ExprId ,
577578 pub lint_level : LintLevel ,
@@ -628,7 +629,7 @@ pub enum InlineAsmOperand<'tcx> {
628629#[ derive( Clone , Debug , HashStable , TypeVisitable ) ]
629630pub struct FieldPat < ' tcx > {
630631 pub field : FieldIdx ,
631- pub pattern : Box < Pat < ' tcx > > ,
632+ pub pattern : Arc < Pat < ' tcx > > ,
632633}
633634
634635#[ derive( Clone , Debug , HashStable , TypeVisitable ) ]
@@ -778,7 +779,7 @@ pub enum PatKind<'tcx> {
778779
779780 AscribeUserType {
780781 ascription : Ascription < ' tcx > ,
781- subpattern : Box < Pat < ' tcx > > ,
782+ subpattern : Arc < Pat < ' tcx > > ,
782783 } ,
783784
784785 /// `x`, `ref x`, `x @ P`, etc.
@@ -789,7 +790,7 @@ pub enum PatKind<'tcx> {
789790 #[ type_visitable( ignore) ]
790791 var : LocalVarId ,
791792 ty : Ty < ' tcx > ,
792- subpattern : Option < Box < Pat < ' tcx > > > ,
793+ subpattern : Option < Arc < Pat < ' tcx > > > ,
793794 /// Is this the leftmost occurrence of the binding, i.e., is `var` the
794795 /// `HirId` of this pattern?
795796 is_primary : bool ,
@@ -812,12 +813,12 @@ pub enum PatKind<'tcx> {
812813
813814 /// `box P`, `&P`, `&mut P`, etc.
814815 Deref {
815- subpattern : Box < Pat < ' tcx > > ,
816+ subpattern : Arc < Pat < ' tcx > > ,
816817 } ,
817818
818819 /// Deref pattern, written `box P` for now.
819820 DerefPattern {
820- subpattern : Box < Pat < ' tcx > > ,
821+ subpattern : Arc < Pat < ' tcx > > ,
821822 mutability : hir:: Mutability ,
822823 } ,
823824
@@ -851,31 +852,31 @@ pub enum PatKind<'tcx> {
851852 /// Otherwise, the actual pattern that the constant lowered to. As with
852853 /// other constants, inline constants are matched structurally where
853854 /// possible.
854- subpattern : Box < Pat < ' tcx > > ,
855+ subpattern : Arc < Pat < ' tcx > > ,
855856 } ,
856857
857- Range ( Box < PatRange < ' tcx > > ) ,
858+ Range ( Arc < PatRange < ' tcx > > ) ,
858859
859860 /// Matches against a slice, checking the length and extracting elements.
860861 /// irrefutable when there is a slice pattern and both `prefix` and `suffix` are empty.
861862 /// e.g., `&[ref xs @ ..]`.
862863 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 > > ] > ,
866867 } ,
867868
868869 /// Fixed match against an array; irrefutable.
869870 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 > > ] > ,
873874 } ,
874875
875876 /// An or-pattern, e.g. `p | q`.
876877 /// Invariant: `pats.len() >= 2`.
877878 Or {
878- pats : Box < [ Box < Pat < ' tcx > > ] > ,
879+ pats : Box < [ Arc < Pat < ' tcx > > ] > ,
879880 } ,
880881
881882 /// A never pattern `!`.
0 commit comments