@@ -643,10 +643,26 @@ pub struct FieldPat<'tcx> {
643643 pub pattern : Pat < ' tcx > ,
644644}
645645
646+ /// Additional per-node data that is not present on most THIR pattern nodes.
647+ #[ derive( Clone , Debug , Default , HashStable , TypeVisitable ) ]
648+ pub struct PatExtra < ' tcx > {
649+ /// If present, this node represents a named constant that was lowered to
650+ /// a pattern using `const_to_pat`.
651+ ///
652+ /// This is used by some diagnostics for non-exhaustive matches, to map
653+ /// the pattern node back to the `DefId` of its original constant.
654+ pub expanded_const : Option < DefId > ,
655+
656+ /// User-written types that must be preserved into MIR so that they can be
657+ /// checked.
658+ pub ascriptions : Vec < Ascription < ' tcx > > ,
659+ }
660+
646661#[ derive( Clone , Debug , HashStable , TypeVisitable ) ]
647662pub struct Pat < ' tcx > {
648663 pub ty : Ty < ' tcx > ,
649664 pub span : Span ,
665+ pub extra : Option < Box < PatExtra < ' tcx > > > ,
650666 pub kind : PatKind < ' tcx > ,
651667}
652668
@@ -762,11 +778,6 @@ pub enum PatKind<'tcx> {
762778 /// A wildcard pattern: `_`.
763779 Wild ,
764780
765- AscribeUserType {
766- ascription : Ascription < ' tcx > ,
767- subpattern : Box < Pat < ' tcx > > ,
768- } ,
769-
770781 /// `x`, `ref x`, `x @ P`, etc.
771782 Binding {
772783 name : Symbol ,
@@ -831,21 +842,6 @@ pub enum PatKind<'tcx> {
831842 value : ty:: Value < ' tcx > ,
832843 } ,
833844
834- /// Wrapper node representing a named constant that was lowered to a pattern
835- /// using `const_to_pat`.
836- ///
837- /// This is used by some diagnostics for non-exhaustive matches, to map
838- /// the pattern node back to the `DefId` of its original constant.
839- ///
840- /// FIXME(#150498): Can we make this an `Option<DefId>` field on `Pat`
841- /// instead, so that non-diagnostic code can ignore it more easily?
842- ExpandedConstant {
843- /// [DefId] of the constant item.
844- def_id : DefId ,
845- /// The pattern that the constant lowered to.
846- subpattern : Box < Pat < ' tcx > > ,
847- } ,
848-
849845 Range ( Arc < PatRange < ' tcx > > ) ,
850846
851847 /// Matches against a slice, checking the length and extracting elements.
@@ -1119,7 +1115,7 @@ mod size_asserts {
11191115 static_assert_size ! ( Block , 48 ) ;
11201116 static_assert_size ! ( Expr <' _>, 64 ) ;
11211117 static_assert_size ! ( ExprKind <' _>, 40 ) ;
1122- static_assert_size ! ( Pat <' _>, 64 ) ;
1118+ static_assert_size ! ( Pat <' _>, 72 ) ;
11231119 static_assert_size ! ( PatKind <' _>, 48 ) ;
11241120 static_assert_size ! ( Stmt <' _>, 48 ) ;
11251121 static_assert_size ! ( StmtKind <' _>, 48 ) ;
0 commit comments