1
1
use smallvec:: SmallVec ;
2
2
3
3
use rustc_data_structures:: captures:: Captures ;
4
- use rustc_middle:: ty:: { self , Ty } ;
4
+ use rustc_middle:: ty;
5
5
use rustc_session:: lint;
6
6
use rustc_session:: lint:: builtin:: NON_EXHAUSTIVE_OMITTED_PATTERNS ;
7
7
use rustc_span:: Span ;
@@ -12,10 +12,9 @@ use crate::errors::{
12
12
OverlappingRangeEndpoints , Uncovered ,
13
13
} ;
14
14
use crate :: rustc:: {
15
- Constructor , DeconstructedPat , MatchArm , MatchCtxt , PlaceCtxt , RustcMatchCheckCtxt ,
15
+ Constructor , DeconstructedPat , MatchArm , MatchCtxt , PlaceCtxt , RevealedTy , RustcMatchCheckCtxt ,
16
16
SplitConstructorSet , WitnessPat ,
17
17
} ;
18
- use crate :: TypeCx ;
19
18
20
19
/// A column of patterns in the matrix, where a column is the intuitive notion of "subpatterns that
21
20
/// inspect the same subvalue/place".
@@ -48,14 +47,8 @@ impl<'p, 'tcx> PatternColumn<'p, 'tcx> {
48
47
fn is_empty ( & self ) -> bool {
49
48
self . patterns . is_empty ( )
50
49
}
51
- fn head_ty ( & self , cx : MatchCtxt < ' _ , ' p , ' tcx > ) -> Option < Ty < ' tcx > > {
52
- if self . patterns . len ( ) == 0 {
53
- return None ;
54
- }
55
-
56
- let ty = self . patterns [ 0 ] . ty ( ) ;
57
- // FIXME(Nadrieril): `Cx` should only give us revealed types.
58
- Some ( cx. tycx . reveal_opaque_ty ( ty) )
50
+ fn head_ty ( & self ) -> Option < RevealedTy < ' tcx > > {
51
+ self . patterns . first ( ) . map ( |pat| pat. ty ( ) )
59
52
}
60
53
61
54
/// Do constructor splitting on the constructors of the column.
@@ -117,7 +110,7 @@ fn collect_nonexhaustive_missing_variants<'a, 'p, 'tcx>(
117
110
cx : MatchCtxt < ' a , ' p , ' tcx > ,
118
111
column : & PatternColumn < ' p , ' tcx > ,
119
112
) -> Vec < WitnessPat < ' p , ' tcx > > {
120
- let Some ( ty) = column. head_ty ( cx ) else {
113
+ let Some ( ty) = column. head_ty ( ) else {
121
114
return Vec :: new ( ) ;
122
115
} ;
123
116
let pcx = & PlaceCtxt :: new_dummy ( cx, ty) ;
@@ -164,7 +157,7 @@ pub(crate) fn lint_nonexhaustive_missing_variants<'a, 'p, 'tcx>(
164
157
cx : MatchCtxt < ' a , ' p , ' tcx > ,
165
158
arms : & [ MatchArm < ' p , ' tcx > ] ,
166
159
pat_column : & PatternColumn < ' p , ' tcx > ,
167
- scrut_ty : Ty < ' tcx > ,
160
+ scrut_ty : RevealedTy < ' tcx > ,
168
161
) {
169
162
let rcx: & RustcMatchCheckCtxt < ' _ , ' _ > = cx. tycx ;
170
163
if !matches ! (
@@ -182,7 +175,7 @@ pub(crate) fn lint_nonexhaustive_missing_variants<'a, 'p, 'tcx>(
182
175
rcx. match_lint_level ,
183
176
rcx. scrut_span ,
184
177
NonExhaustiveOmittedPattern {
185
- scrut_ty,
178
+ scrut_ty : scrut_ty . inner ( ) ,
186
179
uncovered : Uncovered :: new ( rcx. scrut_span , rcx, witnesses) ,
187
180
} ,
188
181
) ;
@@ -218,7 +211,7 @@ pub(crate) fn lint_overlapping_range_endpoints<'a, 'p, 'tcx>(
218
211
cx : MatchCtxt < ' a , ' p , ' tcx > ,
219
212
column : & PatternColumn < ' p , ' tcx > ,
220
213
) {
221
- let Some ( ty) = column. head_ty ( cx ) else {
214
+ let Some ( ty) = column. head_ty ( ) else {
222
215
return ;
223
216
} ;
224
217
let pcx = & PlaceCtxt :: new_dummy ( cx, ty) ;
0 commit comments