@@ -25,24 +25,28 @@ use crate::TypeCx;
25
25
use crate :: constructor:: Constructor :: * ;
26
26
27
27
// Re-export rustc-specific versions of all these types.
28
- pub type Constructor < ' p , ' tcx > = crate :: constructor:: Constructor < RustcMatchCheckCtxt < ' p , ' tcx > > ;
29
- pub type ConstructorSet < ' p , ' tcx > =
30
- crate :: constructor:: ConstructorSet < RustcMatchCheckCtxt < ' p , ' tcx > > ;
31
- pub type DeconstructedPat < ' p , ' tcx > =
32
- crate :: pat:: DeconstructedPat < ' p , RustcMatchCheckCtxt < ' p , ' tcx > > ;
33
- pub type MatchArm < ' p , ' tcx > = crate :: MatchArm < ' p , RustcMatchCheckCtxt < ' p , ' tcx > > ;
34
- pub type MatchCtxt < ' a , ' p , ' tcx > = crate :: MatchCtxt < ' a , ' p , RustcMatchCheckCtxt < ' p , ' tcx > > ;
35
- pub ( crate ) type PlaceCtxt < ' a , ' p , ' tcx > =
36
- crate :: usefulness:: PlaceCtxt < ' a , ' p , RustcMatchCheckCtxt < ' p , ' tcx > > ;
37
- pub ( crate ) type SplitConstructorSet < ' p , ' tcx > =
38
- crate :: constructor:: SplitConstructorSet < RustcMatchCheckCtxt < ' p , ' tcx > > ;
39
- pub type Usefulness < ' p , ' tcx > = crate :: usefulness:: Usefulness < ' p , RustcMatchCheckCtxt < ' p , ' tcx > > ;
40
- pub type UsefulnessReport < ' p , ' tcx > =
41
- crate :: usefulness:: UsefulnessReport < ' p , RustcMatchCheckCtxt < ' p , ' tcx > > ;
42
- pub type WitnessPat < ' p , ' tcx > = crate :: pat:: WitnessPat < RustcMatchCheckCtxt < ' p , ' tcx > > ;
28
+ pub type Constructor < ' p , ' thir , ' tcx > =
29
+ crate :: constructor:: Constructor < RustcMatchCheckCtxt < ' p , ' thir , ' tcx > > ;
30
+ pub type ConstructorSet < ' p , ' thir , ' tcx > =
31
+ crate :: constructor:: ConstructorSet < RustcMatchCheckCtxt < ' p , ' thir , ' tcx > > ;
32
+ pub type DeconstructedPat < ' p , ' thir , ' tcx > =
33
+ crate :: pat:: DeconstructedPat < ' p , RustcMatchCheckCtxt < ' p , ' thir , ' tcx > > ;
34
+ pub type MatchArm < ' p , ' thir , ' tcx > = crate :: MatchArm < ' p , RustcMatchCheckCtxt < ' p , ' thir , ' tcx > > ;
35
+ pub type MatchCtxt < ' a , ' p , ' thir , ' tcx > =
36
+ crate :: MatchCtxt < ' a , ' p , RustcMatchCheckCtxt < ' p , ' thir , ' tcx > > ;
37
+ pub ( crate ) type PlaceCtxt < ' a , ' p , ' thir , ' tcx > =
38
+ crate :: usefulness:: PlaceCtxt < ' a , ' p , RustcMatchCheckCtxt < ' p , ' thir , ' tcx > > ;
39
+ pub ( crate ) type SplitConstructorSet < ' p , ' thir , ' tcx > =
40
+ crate :: constructor:: SplitConstructorSet < RustcMatchCheckCtxt < ' p , ' thir , ' tcx > > ;
41
+ pub type Usefulness < ' p , ' thir , ' tcx > =
42
+ crate :: usefulness:: Usefulness < ' p , RustcMatchCheckCtxt < ' p , ' thir , ' tcx > > ;
43
+ pub type UsefulnessReport < ' p , ' thir , ' tcx > =
44
+ crate :: usefulness:: UsefulnessReport < ' p , RustcMatchCheckCtxt < ' p , ' thir , ' tcx > > ;
45
+ pub type WitnessPat < ' p , ' thir , ' tcx > = crate :: pat:: WitnessPat < RustcMatchCheckCtxt < ' p , ' thir , ' tcx > > ;
43
46
44
47
#[ derive( Clone ) ]
45
- pub struct RustcMatchCheckCtxt < ' p , ' tcx > {
48
+ #[ allow( explicit_outlives_requirements) ] // FIXME #119228
49
+ pub struct RustcMatchCheckCtxt < ' p , ' thir , ' tcx : ' thir > {
46
50
pub tcx : TyCtxt < ' tcx > ,
47
51
pub typeck_results : & ' tcx ty:: TypeckResults < ' tcx > ,
48
52
/// The module in which the match occurs. This is necessary for
@@ -52,7 +56,7 @@ pub struct RustcMatchCheckCtxt<'p, 'tcx> {
52
56
/// outside its module and should not be matchable with an empty match statement.
53
57
pub module : DefId ,
54
58
pub param_env : ty:: ParamEnv < ' tcx > ,
55
- pub pattern_arena : & ' p TypedArena < DeconstructedPat < ' p , ' tcx > > ,
59
+ pub pattern_arena : & ' p TypedArena < DeconstructedPat < ' p , ' thir , ' tcx > > ,
56
60
pub dropless_arena : & ' p DroplessArena ,
57
61
/// Lint level at the match.
58
62
pub match_lint_level : HirId ,
@@ -67,13 +71,13 @@ pub struct RustcMatchCheckCtxt<'p, 'tcx> {
67
71
pub known_valid_scrutinee : bool ,
68
72
}
69
73
70
- impl < ' p , ' tcx > fmt:: Debug for RustcMatchCheckCtxt < ' p , ' tcx > {
74
+ impl < ' p , ' thir , ' tcx > fmt:: Debug for RustcMatchCheckCtxt < ' p , ' thir , ' tcx > {
71
75
fn fmt ( & self , f : & mut fmt:: Formatter < ' _ > ) -> fmt:: Result {
72
76
f. debug_struct ( "RustcMatchCheckCtxt" ) . finish ( )
73
77
}
74
78
}
75
79
76
- impl < ' p , ' tcx > RustcMatchCheckCtxt < ' p , ' tcx > {
80
+ impl < ' p , ' thir , ' tcx > RustcMatchCheckCtxt < ' p , ' thir , ' tcx > {
77
81
pub ( crate ) fn is_uninhabited ( & self , ty : Ty < ' tcx > ) -> bool {
78
82
!ty. is_inhabited_from ( self . tcx , self . module , self . param_env )
79
83
}
@@ -124,7 +128,8 @@ impl<'p, 'tcx> RustcMatchCheckCtxt<'p, 'tcx> {
124
128
& ' a self ,
125
129
ty : Ty < ' tcx > ,
126
130
variant : & ' a VariantDef ,
127
- ) -> impl Iterator < Item = ( FieldIdx , Ty < ' tcx > ) > + Captures < ' p > + Captures < ' a > {
131
+ ) -> impl Iterator < Item = ( FieldIdx , Ty < ' tcx > ) > + Captures < ' thir > + Captures < ' p > + Captures < ' a >
132
+ {
128
133
let cx = self ;
129
134
let ty:: Adt ( adt, args) = ty. kind ( ) else { bug ! ( ) } ;
130
135
// Whether we must not match the fields of this variant exhaustively.
@@ -146,7 +151,7 @@ impl<'p, 'tcx> RustcMatchCheckCtxt<'p, 'tcx> {
146
151
}
147
152
148
153
pub ( crate ) fn variant_index_for_adt (
149
- ctor : & Constructor < ' p , ' tcx > ,
154
+ ctor : & Constructor < ' p , ' thir , ' tcx > ,
150
155
adt : ty:: AdtDef < ' tcx > ,
151
156
) -> VariantIdx {
152
157
match * ctor {
@@ -162,7 +167,11 @@ impl<'p, 'tcx> RustcMatchCheckCtxt<'p, 'tcx> {
162
167
/// Returns the types of the fields for a given constructor. The result must have a length of
163
168
/// `ctor.arity()`.
164
169
#[ instrument( level = "trace" , skip( self ) ) ]
165
- pub ( crate ) fn ctor_sub_tys ( & self , ctor : & Constructor < ' p , ' tcx > , ty : Ty < ' tcx > ) -> & [ Ty < ' tcx > ] {
170
+ pub ( crate ) fn ctor_sub_tys (
171
+ & self ,
172
+ ctor : & Constructor < ' p , ' thir , ' tcx > ,
173
+ ty : Ty < ' tcx > ,
174
+ ) -> & [ Ty < ' tcx > ] {
166
175
let cx = self ;
167
176
match ctor {
168
177
Struct | Variant ( _) | UnionField => match ty. kind ( ) {
@@ -209,7 +218,7 @@ impl<'p, 'tcx> RustcMatchCheckCtxt<'p, 'tcx> {
209
218
}
210
219
211
220
/// The number of fields for this constructor.
212
- pub ( crate ) fn ctor_arity ( & self , ctor : & Constructor < ' p , ' tcx > , ty : Ty < ' tcx > ) -> usize {
221
+ pub ( crate ) fn ctor_arity ( & self , ctor : & Constructor < ' p , ' thir , ' tcx > , ty : Ty < ' tcx > ) -> usize {
213
222
match ctor {
214
223
Struct | Variant ( _) | UnionField => match ty. kind ( ) {
215
224
ty:: Tuple ( fs) => fs. len ( ) ,
@@ -246,7 +255,7 @@ impl<'p, 'tcx> RustcMatchCheckCtxt<'p, 'tcx> {
246
255
///
247
256
/// See [`crate::constructor`] for considerations of emptiness.
248
257
#[ instrument( level = "debug" , skip( self ) , ret) ]
249
- pub fn ctors_for_ty ( & self , ty : Ty < ' tcx > ) -> ConstructorSet < ' p , ' tcx > {
258
+ pub fn ctors_for_ty ( & self , ty : Ty < ' tcx > ) -> ConstructorSet < ' p , ' thir , ' tcx > {
250
259
let cx = self ;
251
260
let make_uint_range = |start, end| {
252
261
IntRange :: from_range (
@@ -389,7 +398,7 @@ impl<'p, 'tcx> RustcMatchCheckCtxt<'p, 'tcx> {
389
398
390
399
/// Note: the input patterns must have been lowered through
391
400
/// `rustc_mir_build::thir::pattern::check_match::MatchVisitor::lower_pattern`.
392
- pub fn lower_pat ( & self , pat : & Pat < ' tcx > ) -> DeconstructedPat < ' p , ' tcx > {
401
+ pub fn lower_pat ( & self , pat : & ' thir Pat < ' tcx > ) -> DeconstructedPat < ' p , ' thir , ' tcx > {
393
402
let singleton = |pat| std:: slice:: from_ref ( self . pattern_arena . alloc ( pat) ) ;
394
403
let cx = self ;
395
404
let ctor;
@@ -690,7 +699,7 @@ impl<'p, 'tcx> RustcMatchCheckCtxt<'p, 'tcx> {
690
699
}
691
700
/// Convert back to a `thir::Pat` for diagnostic purposes. This panics for patterns that don't
692
701
/// appear in diagnostics, like float ranges.
693
- pub fn hoist_witness_pat ( & self , pat : & WitnessPat < ' p , ' tcx > ) -> Pat < ' tcx > {
702
+ pub fn hoist_witness_pat ( & self , pat : & WitnessPat < ' p , ' thir , ' tcx > ) -> Pat < ' tcx > {
694
703
let cx = self ;
695
704
let is_wildcard = |pat : & Pat < ' _ > | matches ! ( pat. kind, PatKind :: Wild ) ;
696
705
let mut subpatterns = pat. iter_fields ( ) . map ( |p| Box :: new ( cx. hoist_witness_pat ( p) ) ) ;
@@ -879,7 +888,7 @@ impl<'p, 'tcx> RustcMatchCheckCtxt<'p, 'tcx> {
879
888
}
880
889
}
881
890
882
- impl < ' p , ' tcx > TypeCx for RustcMatchCheckCtxt < ' p , ' tcx > {
891
+ impl < ' p , ' thir , ' tcx > TypeCx for RustcMatchCheckCtxt < ' p , ' thir , ' tcx > {
883
892
type Ty = Ty < ' tcx > ;
884
893
type VariantIdx = VariantIdx ;
885
894
type StrLit = Const < ' tcx > ;
0 commit comments