@@ -20,7 +20,8 @@ use const_eval::{const_field, const_variant_index};
2020
2121use hair:: util:: UserAnnotatedTyHelpers ;
2222
23- use rustc:: mir:: { fmt_const_val, Field , BorrowKind , Mutability , UserTypeAnnotation } ;
23+ use rustc:: mir:: { fmt_const_val, Field , BorrowKind , Mutability } ;
24+ use rustc:: mir:: { UserTypeAnnotation , UserTypeProjection } ;
2425use rustc:: mir:: interpret:: { Scalar , GlobalId , ConstValue , sign_extend} ;
2526use rustc:: ty:: { self , Region , TyCtxt , AdtDef , Ty } ;
2627use rustc:: ty:: subst:: { Substs , Kind } ;
@@ -65,25 +66,30 @@ pub struct Pattern<'tcx> {
6566}
6667
6768#[ derive( Copy , Clone , Debug ) ]
68- pub struct PatternTypeAnnotation < ' tcx > ( UserTypeAnnotation < ' tcx > ) ;
69+ pub struct PatternTypeProjection < ' tcx > ( UserTypeProjection < ' tcx > ) ;
6970
70- impl < ' tcx > PatternTypeAnnotation < ' tcx > {
71- pub ( crate ) fn from_c_ty ( c_ty : ty:: CanonicalTy < ' tcx > ) -> Self {
72- Self :: from_u_ty ( UserTypeAnnotation :: Ty ( c_ty) )
71+ impl < ' tcx > PatternTypeProjection < ' tcx > {
72+ pub ( crate ) fn from_canonical_ty ( c_ty : ty:: CanonicalTy < ' tcx > ) -> Self {
73+ Self :: from_user_type ( UserTypeAnnotation :: Ty ( c_ty) )
7374 }
74- pub ( crate ) fn from_u_ty ( u_ty : UserTypeAnnotation < ' tcx > ) -> Self {
75- PatternTypeAnnotation ( u_ty)
75+
76+ pub ( crate ) fn from_user_type ( u_ty : UserTypeAnnotation < ' tcx > ) -> Self {
77+ Self :: from_user_type_proj ( UserTypeProjection { base : u_ty } )
78+ }
79+
80+ pub ( crate ) fn from_user_type_proj ( u_ty : UserTypeProjection < ' tcx > ) -> Self {
81+ PatternTypeProjection ( u_ty)
7682 }
7783
78- pub ( crate ) fn user_ty ( self ) -> UserTypeAnnotation < ' tcx > { self . 0 }
84+ pub ( crate ) fn user_ty ( self ) -> UserTypeProjection < ' tcx > { self . 0 }
7985}
8086
8187#[ derive( Clone , Debug ) ]
8288pub enum PatternKind < ' tcx > {
8389 Wild ,
8490
8591 AscribeUserType {
86- user_ty : PatternTypeAnnotation < ' tcx > ,
92+ user_ty : PatternTypeProjection < ' tcx > ,
8793 subpattern : Pattern < ' tcx > ,
8894 user_ty_span : Span ,
8995 } ,
@@ -704,7 +710,7 @@ impl<'a, 'tcx> PatternContext<'a, 'tcx> {
704710
705711 debug ! ( "pattern user_ty = {:?} for pattern at {:?}" , user_ty, span) ;
706712
707- let pat_ty = PatternTypeAnnotation :: from_u_ty ( user_ty) ;
713+ let pat_ty = PatternTypeProjection :: from_user_type ( user_ty) ;
708714 kind = PatternKind :: AscribeUserType {
709715 subpattern,
710716 user_ty : pat_ty,
@@ -995,7 +1001,8 @@ macro_rules! CloneImpls {
9951001CloneImpls ! { <' tcx>
9961002 Span , Field , Mutability , ast:: Name , ast:: NodeId , usize , & ' tcx ty:: Const <' tcx>,
9971003 Region <' tcx>, Ty <' tcx>, BindingMode <' tcx>, & ' tcx AdtDef ,
998- & ' tcx Substs <' tcx>, & ' tcx Kind <' tcx>, UserTypeAnnotation <' tcx>, PatternTypeAnnotation <' tcx>
1004+ & ' tcx Substs <' tcx>, & ' tcx Kind <' tcx>, UserTypeAnnotation <' tcx>,
1005+ UserTypeProjection <' tcx>, PatternTypeProjection <' tcx>
9991006}
10001007
10011008impl < ' tcx > PatternFoldable < ' tcx > for FieldPattern < ' tcx > {
0 commit comments