@@ -48,22 +48,14 @@ impl<'a, 'p, 'tcx> PatternColumn<'a, 'p, 'tcx> {
48
48
fn is_empty ( & self ) -> bool {
49
49
self . patterns . is_empty ( )
50
50
}
51
- fn head_ty ( & self ) -> Option < Ty < ' tcx > > {
51
+ fn head_ty ( & self , cx : MatchCtxt < ' a , ' p , ' tcx > ) -> Option < Ty < ' tcx > > {
52
52
if self . patterns . len ( ) == 0 {
53
53
return None ;
54
54
}
55
- // If the type is opaque and it is revealed anywhere in the column, we take the revealed
56
- // version. Otherwise we could encounter constructors for the revealed type and crash.
57
- let first_ty = self . patterns [ 0 ] . ty ( ) ;
58
- if RustcMatchCheckCtxt :: is_opaque_ty ( first_ty) {
59
- for pat in & self . patterns {
60
- let ty = pat. ty ( ) ;
61
- if !RustcMatchCheckCtxt :: is_opaque_ty ( ty) {
62
- return Some ( ty) ;
63
- }
64
- }
65
- }
66
- Some ( first_ty)
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) )
67
59
}
68
60
69
61
/// Do constructor splitting on the constructors of the column.
@@ -125,7 +117,7 @@ fn collect_nonexhaustive_missing_variants<'a, 'p, 'tcx>(
125
117
cx : MatchCtxt < ' a , ' p , ' tcx > ,
126
118
column : & PatternColumn < ' a , ' p , ' tcx > ,
127
119
) -> Vec < WitnessPat < ' p , ' tcx > > {
128
- let Some ( ty) = column. head_ty ( ) else {
120
+ let Some ( ty) = column. head_ty ( cx ) else {
129
121
return Vec :: new ( ) ;
130
122
} ;
131
123
let pcx = & PlaceCtxt :: new_dummy ( cx, ty) ;
@@ -226,7 +218,7 @@ pub(crate) fn lint_overlapping_range_endpoints<'a, 'p, 'tcx>(
226
218
cx : MatchCtxt < ' a , ' p , ' tcx > ,
227
219
column : & PatternColumn < ' a , ' p , ' tcx > ,
228
220
) {
229
- let Some ( ty) = column. head_ty ( ) else {
221
+ let Some ( ty) = column. head_ty ( cx ) else {
230
222
return ;
231
223
} ;
232
224
let pcx = & PlaceCtxt :: new_dummy ( cx, ty) ;
0 commit comments