@@ -24,21 +24,19 @@ use crate::MatchCx;
24
24
25
25
use crate :: constructor:: Constructor :: * ;
26
26
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 > > ;
33
32
pub ( crate ) type SplitConstructorSet < ' p , ' tcx > =
34
- crate :: constructor:: SplitConstructorSet < MatchCheckCtxt < ' p , ' tcx > > ;
33
+ crate :: constructor:: SplitConstructorSet < RustcCtxt < ' p , ' tcx > > ;
35
34
pub 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 > > ;
39
37
40
38
#[ derive( Clone ) ]
41
- pub struct MatchCheckCtxt < ' p , ' tcx > {
39
+ pub struct RustcCtxt < ' p , ' tcx > {
42
40
pub tcx : TyCtxt < ' tcx > ,
43
41
/// The module in which the match occurs. This is necessary for
44
42
/// checking inhabited-ness of types because whether a type is (visibly)
@@ -62,13 +60,13 @@ pub struct MatchCheckCtxt<'p, 'tcx> {
62
60
pub known_valid_scrutinee : bool ,
63
61
}
64
62
65
- impl < ' p , ' tcx > fmt:: Debug for MatchCheckCtxt < ' p , ' tcx > {
63
+ impl < ' p , ' tcx > fmt:: Debug for RustcCtxt < ' p , ' tcx > {
66
64
fn fmt ( & self , f : & mut fmt:: Formatter < ' _ > ) -> fmt:: Result {
67
- f. debug_struct ( "MatchCheckCtxt " ) . finish ( )
65
+ f. debug_struct ( "RustcCtxt " ) . finish ( )
68
66
}
69
67
}
70
68
71
- impl < ' p , ' tcx > MatchCheckCtxt < ' p , ' tcx > {
69
+ impl < ' p , ' tcx > RustcCtxt < ' p , ' tcx > {
72
70
pub ( crate ) fn is_uninhabited ( & self , ty : Ty < ' tcx > ) -> bool {
73
71
!ty. is_inhabited_from ( self . tcx , self . module , self . param_env )
74
72
}
@@ -153,8 +151,7 @@ impl<'p, 'tcx> MatchCheckCtxt<'p, 'tcx> {
153
151
// patterns. If we're here we can assume this is a box pattern.
154
152
cx. dropless_arena . alloc_from_iter ( once ( args. type_at ( 0 ) ) )
155
153
} 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) ) ;
158
155
let tys = cx. list_variant_nonhidden_fields ( ty, variant) . map ( |( _, ty) | ty) ;
159
156
cx. dropless_arena . alloc_from_iter ( tys)
160
157
}
@@ -199,8 +196,7 @@ impl<'p, 'tcx> MatchCheckCtxt<'p, 'tcx> {
199
196
// patterns. If we're here we can assume this is a box pattern.
200
197
1
201
198
} 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) ) ;
204
200
self . list_variant_nonhidden_fields ( ty, variant) . count ( )
205
201
}
206
202
}
@@ -431,8 +427,7 @@ impl<'p, 'tcx> MatchCheckCtxt<'p, 'tcx> {
431
427
PatKind :: Variant { variant_index, .. } => Variant ( variant_index) ,
432
428
_ => bug ! ( ) ,
433
429
} ;
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) ) ;
436
431
// For each field in the variant, we store the relevant index into `self.fields` if any.
437
432
let mut field_id_to_id: Vec < Option < usize > > =
438
433
( 0 ..variant. fields . len ( ) ) . map ( |_| None ) . collect ( ) ;
@@ -687,8 +682,7 @@ impl<'p, 'tcx> MatchCheckCtxt<'p, 'tcx> {
687
682
PatKind :: Deref { subpattern : subpatterns. next ( ) . unwrap ( ) }
688
683
}
689
684
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) ;
692
686
let variant = & adt_def. variant ( variant_index) ;
693
687
let subpatterns = cx
694
688
. list_variant_nonhidden_fields ( pat. ty ( ) , variant)
@@ -784,9 +778,9 @@ impl<'p, 'tcx> MatchCheckCtxt<'p, 'tcx> {
784
778
}
785
779
ty:: Adt ( ..) | ty:: Tuple ( ..) => {
786
780
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
+ }
790
784
ty:: Tuple ( _) => None ,
791
785
_ => unreachable ! ( ) ,
792
786
} ;
@@ -854,7 +848,7 @@ impl<'p, 'tcx> MatchCheckCtxt<'p, 'tcx> {
854
848
}
855
849
}
856
850
857
- impl < ' p , ' tcx > MatchCx for MatchCheckCtxt < ' p , ' tcx > {
851
+ impl < ' p , ' tcx > MatchCx for RustcCtxt < ' p , ' tcx > {
858
852
type Ty = Ty < ' tcx > ;
859
853
type Span = Span ;
860
854
type VariantIdx = VariantIdx ;
0 commit comments