11use smallvec:: SmallVec ;
22
33use rustc_data_structures:: captures:: Captures ;
4- use rustc_middle:: ty:: { self , Ty } ;
4+ use rustc_middle:: ty;
55use rustc_session:: lint;
66use rustc_session:: lint:: builtin:: NON_EXHAUSTIVE_OMITTED_PATTERNS ;
77use rustc_span:: Span ;
@@ -12,10 +12,9 @@ use crate::errors::{
1212 OverlappingRangeEndpoints , Uncovered ,
1313} ;
1414use crate :: rustc:: {
15- Constructor , DeconstructedPat , MatchArm , MatchCtxt , PlaceCtxt , RustcMatchCheckCtxt ,
15+ Constructor , DeconstructedPat , MatchArm , MatchCtxt , PlaceCtxt , RevealedTy , RustcMatchCheckCtxt ,
1616 SplitConstructorSet , WitnessPat ,
1717} ;
18- use crate :: TypeCx ;
1918
2019/// A column of patterns in the matrix, where a column is the intuitive notion of "subpatterns that
2120/// inspect the same subvalue/place".
@@ -48,14 +47,8 @@ impl<'p, 'tcx> PatternColumn<'p, 'tcx> {
4847 fn is_empty ( & self ) -> bool {
4948 self . patterns . is_empty ( )
5049 }
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 ( ) )
5952 }
6053
6154 /// Do constructor splitting on the constructors of the column.
@@ -117,7 +110,7 @@ fn collect_nonexhaustive_missing_variants<'a, 'p, 'tcx>(
117110 cx : MatchCtxt < ' a , ' p , ' tcx > ,
118111 column : & PatternColumn < ' p , ' tcx > ,
119112) -> Vec < WitnessPat < ' p , ' tcx > > {
120- let Some ( ty) = column. head_ty ( cx ) else {
113+ let Some ( ty) = column. head_ty ( ) else {
121114 return Vec :: new ( ) ;
122115 } ;
123116 let pcx = & PlaceCtxt :: new_dummy ( cx, ty) ;
@@ -164,7 +157,7 @@ pub(crate) fn lint_nonexhaustive_missing_variants<'a, 'p, 'tcx>(
164157 cx : MatchCtxt < ' a , ' p , ' tcx > ,
165158 arms : & [ MatchArm < ' p , ' tcx > ] ,
166159 pat_column : & PatternColumn < ' p , ' tcx > ,
167- scrut_ty : Ty < ' tcx > ,
160+ scrut_ty : RevealedTy < ' tcx > ,
168161) {
169162 let rcx: & RustcMatchCheckCtxt < ' _ , ' _ > = cx. tycx ;
170163 if !matches ! (
@@ -182,7 +175,7 @@ pub(crate) fn lint_nonexhaustive_missing_variants<'a, 'p, 'tcx>(
182175 rcx. match_lint_level ,
183176 rcx. scrut_span ,
184177 NonExhaustiveOmittedPattern {
185- scrut_ty,
178+ scrut_ty : scrut_ty . inner ( ) ,
186179 uncovered : Uncovered :: new ( rcx. scrut_span , rcx, witnesses) ,
187180 } ,
188181 ) ;
@@ -218,7 +211,7 @@ pub(crate) fn lint_overlapping_range_endpoints<'a, 'p, 'tcx>(
218211 cx : MatchCtxt < ' a , ' p , ' tcx > ,
219212 column : & PatternColumn < ' p , ' tcx > ,
220213) {
221- let Some ( ty) = column. head_ty ( cx ) else {
214+ let Some ( ty) = column. head_ty ( ) else {
222215 return ;
223216 } ;
224217 let pcx = & PlaceCtxt :: new_dummy ( cx, ty) ;
0 commit comments