@@ -24,21 +24,19 @@ use crate::MatchCx;
2424
2525use crate :: constructor:: Constructor :: * ;
2626
27- pub type Constructor < ' p , ' tcx > = crate :: constructor:: Constructor < MatchCheckCtxt < ' p , ' tcx > > ;
28- pub type ConstructorSet < ' p , ' tcx > = crate :: constructor:: ConstructorSet < MatchCheckCtxt < ' p , ' tcx > > ;
29- pub type DeconstructedPat < ' p , ' tcx > = crate :: pat:: DeconstructedPat < ' p , MatchCheckCtxt < ' p , ' tcx > > ;
30- pub type MatchArm < ' p , ' tcx > = crate :: MatchArm < ' p , MatchCheckCtxt < ' p , ' tcx > > ;
31- pub ( crate ) type PatCtxt < ' a , ' p , ' tcx > =
32- crate :: usefulness:: PatCtxt < ' a , ' p , MatchCheckCtxt < ' p , ' tcx > > ;
27+ pub type Constructor < ' p , ' tcx > = crate :: constructor:: Constructor < RustcCtxt < ' p , ' tcx > > ;
28+ pub type ConstructorSet < ' p , ' tcx > = crate :: constructor:: ConstructorSet < RustcCtxt < ' p , ' tcx > > ;
29+ pub type DeconstructedPat < ' p , ' tcx > = crate :: pat:: DeconstructedPat < ' p , RustcCtxt < ' p , ' tcx > > ;
30+ pub type MatchArm < ' p , ' tcx > = crate :: MatchArm < ' p , RustcCtxt < ' p , ' tcx > > ;
31+ pub ( crate ) type PatCtxt < ' a , ' p , ' tcx > = crate :: usefulness:: PatCtxt < ' a , ' p , RustcCtxt < ' p , ' tcx > > ;
3332pub ( crate ) type SplitConstructorSet < ' p , ' tcx > =
34- crate :: constructor:: SplitConstructorSet < MatchCheckCtxt < ' p , ' tcx > > ;
33+ crate :: constructor:: SplitConstructorSet < RustcCtxt < ' p , ' tcx > > ;
3534pub type Usefulness = crate :: usefulness:: Usefulness < Span > ;
36- pub type UsefulnessReport < ' p , ' tcx > =
37- crate :: usefulness:: UsefulnessReport < ' p , MatchCheckCtxt < ' p , ' tcx > > ;
38- pub type WitnessPat < ' p , ' tcx > = crate :: pat:: WitnessPat < MatchCheckCtxt < ' p , ' tcx > > ;
35+ pub type UsefulnessReport < ' p , ' tcx > = crate :: usefulness:: UsefulnessReport < ' p , RustcCtxt < ' p , ' tcx > > ;
36+ pub type WitnessPat < ' p , ' tcx > = crate :: pat:: WitnessPat < RustcCtxt < ' p , ' tcx > > ;
3937
4038#[ derive( Clone ) ]
41- pub struct MatchCheckCtxt < ' p , ' tcx > {
39+ pub struct RustcCtxt < ' p , ' tcx > {
4240 pub tcx : TyCtxt < ' tcx > ,
4341 /// The module in which the match occurs. This is necessary for
4442 /// checking inhabited-ness of types because whether a type is (visibly)
@@ -62,13 +60,13 @@ pub struct MatchCheckCtxt<'p, 'tcx> {
6260 pub known_valid_scrutinee : bool ,
6361}
6462
65- impl < ' p , ' tcx > fmt:: Debug for MatchCheckCtxt < ' p , ' tcx > {
63+ impl < ' p , ' tcx > fmt:: Debug for RustcCtxt < ' p , ' tcx > {
6664 fn fmt ( & self , f : & mut fmt:: Formatter < ' _ > ) -> fmt:: Result {
67- f. debug_struct ( "MatchCheckCtxt " ) . finish ( )
65+ f. debug_struct ( "RustcCtxt " ) . finish ( )
6866 }
6967}
7068
71- impl < ' p , ' tcx > MatchCheckCtxt < ' p , ' tcx > {
69+ impl < ' p , ' tcx > RustcCtxt < ' p , ' tcx > {
7270 pub ( crate ) fn is_uninhabited ( & self , ty : Ty < ' tcx > ) -> bool {
7371 !ty. is_inhabited_from ( self . tcx , self . module , self . param_env )
7472 }
@@ -153,8 +151,7 @@ impl<'p, 'tcx> MatchCheckCtxt<'p, 'tcx> {
153151 // patterns. If we're here we can assume this is a box pattern.
154152 cx. dropless_arena . alloc_from_iter ( once ( args. type_at ( 0 ) ) )
155153 } else {
156- let variant =
157- & adt. variant ( MatchCheckCtxt :: variant_index_for_adt ( & ctor, * adt) ) ;
154+ let variant = & adt. variant ( RustcCtxt :: variant_index_for_adt ( & ctor, * adt) ) ;
158155 let tys = cx. list_variant_nonhidden_fields ( ty, variant) . map ( |( _, ty) | ty) ;
159156 cx. dropless_arena . alloc_from_iter ( tys)
160157 }
@@ -199,8 +196,7 @@ impl<'p, 'tcx> MatchCheckCtxt<'p, 'tcx> {
199196 // patterns. If we're here we can assume this is a box pattern.
200197 1
201198 } else {
202- let variant =
203- & adt. variant ( MatchCheckCtxt :: variant_index_for_adt ( & ctor, * adt) ) ;
199+ let variant = & adt. variant ( RustcCtxt :: variant_index_for_adt ( & ctor, * adt) ) ;
204200 self . list_variant_nonhidden_fields ( ty, variant) . count ( )
205201 }
206202 }
@@ -431,8 +427,7 @@ impl<'p, 'tcx> MatchCheckCtxt<'p, 'tcx> {
431427 PatKind :: Variant { variant_index, .. } => Variant ( variant_index) ,
432428 _ => bug ! ( ) ,
433429 } ;
434- let variant =
435- & adt. variant ( MatchCheckCtxt :: variant_index_for_adt ( & ctor, * adt) ) ;
430+ let variant = & adt. variant ( RustcCtxt :: variant_index_for_adt ( & ctor, * adt) ) ;
436431 // For each field in the variant, we store the relevant index into `self.fields` if any.
437432 let mut field_id_to_id: Vec < Option < usize > > =
438433 ( 0 ..variant. fields . len ( ) ) . map ( |_| None ) . collect ( ) ;
@@ -687,8 +682,7 @@ impl<'p, 'tcx> MatchCheckCtxt<'p, 'tcx> {
687682 PatKind :: Deref { subpattern : subpatterns. next ( ) . unwrap ( ) }
688683 }
689684 ty:: Adt ( adt_def, args) => {
690- let variant_index =
691- MatchCheckCtxt :: variant_index_for_adt ( & pat. ctor ( ) , * adt_def) ;
685+ let variant_index = RustcCtxt :: variant_index_for_adt ( & pat. ctor ( ) , * adt_def) ;
692686 let variant = & adt_def. variant ( variant_index) ;
693687 let subpatterns = cx
694688 . list_variant_nonhidden_fields ( pat. ty ( ) , variant)
@@ -784,9 +778,9 @@ impl<'p, 'tcx> MatchCheckCtxt<'p, 'tcx> {
784778 }
785779 ty:: Adt ( ..) | ty:: Tuple ( ..) => {
786780 let variant = match pat. ty ( ) . kind ( ) {
787- ty:: Adt ( adt, _) => Some (
788- adt. variant ( MatchCheckCtxt :: variant_index_for_adt ( pat. ctor ( ) , * adt) ) ,
789- ) ,
781+ ty:: Adt ( adt, _) => {
782+ Some ( adt. variant ( RustcCtxt :: variant_index_for_adt ( pat. ctor ( ) , * adt) ) )
783+ }
790784 ty:: Tuple ( _) => None ,
791785 _ => unreachable ! ( ) ,
792786 } ;
@@ -854,7 +848,7 @@ impl<'p, 'tcx> MatchCheckCtxt<'p, 'tcx> {
854848 }
855849}
856850
857- impl < ' p , ' tcx > MatchCx for MatchCheckCtxt < ' p , ' tcx > {
851+ impl < ' p , ' tcx > MatchCx for RustcCtxt < ' p , ' tcx > {
858852 type Ty = Ty < ' tcx > ;
859853 type Span = Span ;
860854 type VariantIdx = VariantIdx ;
0 commit comments