@@ -48,22 +48,14 @@ impl<'a, 'p, 'tcx> PatternColumn<'a, 'p, 'tcx> {
4848 fn is_empty ( & self ) -> bool {
4949 self . patterns . is_empty ( )
5050 }
51- fn head_ty ( & self ) -> Option < Ty < ' tcx > > {
51+ fn head_ty ( & self , cx : MatchCtxt < ' a , ' p , ' tcx > ) -> Option < Ty < ' tcx > > {
5252 if self . patterns . len ( ) == 0 {
5353 return None ;
5454 }
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) )
6759 }
6860
6961 /// Do constructor splitting on the constructors of the column.
@@ -125,7 +117,7 @@ fn collect_nonexhaustive_missing_variants<'a, 'p, 'tcx>(
125117 cx : MatchCtxt < ' a , ' p , ' tcx > ,
126118 column : & PatternColumn < ' a , ' p , ' tcx > ,
127119) -> Vec < WitnessPat < ' p , ' tcx > > {
128- let Some ( ty) = column. head_ty ( ) else {
120+ let Some ( ty) = column. head_ty ( cx ) else {
129121 return Vec :: new ( ) ;
130122 } ;
131123 let pcx = & PlaceCtxt :: new_dummy ( cx, ty) ;
@@ -226,7 +218,7 @@ pub(crate) fn lint_overlapping_range_endpoints<'a, 'p, 'tcx>(
226218 cx : MatchCtxt < ' a , ' p , ' tcx > ,
227219 column : & PatternColumn < ' a , ' p , ' tcx > ,
228220) {
229- let Some ( ty) = column. head_ty ( ) else {
221+ let Some ( ty) = column. head_ty ( cx ) else {
230222 return ;
231223 } ;
232224 let pcx = & PlaceCtxt :: new_dummy ( cx, ty) ;
0 commit comments