@@ -362,9 +362,6 @@ pub(super) struct PatCtxt<'a, 'p, 'tcx> {
362
362
pub ( super ) ty : Ty < ' tcx > ,
363
363
/// Span of the current pattern under investigation.
364
364
pub ( super ) span : Span ,
365
- /// Whether the current pattern is the whole pattern as found in a match arm, or if it's a
366
- /// subpattern.
367
- pub ( super ) is_top_level : bool ,
368
365
}
369
366
370
367
impl < ' a , ' p , ' tcx > fmt:: Debug for PatCtxt < ' a , ' p , ' tcx > {
@@ -791,10 +788,10 @@ fn compute_usefulness<'p, 'tcx>(
791
788
792
789
let ty = matrix. head_ty ( ) ;
793
790
debug ! ( "ty: {ty:?}" ) ;
794
- let pcx = & PatCtxt { cx, ty, span : DUMMY_SP , is_top_level } ;
791
+ let pcx = & PatCtxt { cx, ty, span : DUMMY_SP } ;
795
792
796
793
let ctors = matrix. heads ( ) . map ( |p| p. ctor ( ) ) ;
797
- let split_set = ConstructorSet :: for_ty ( pcx. cx , pcx. ty ) . split ( pcx, ctors) ;
794
+ let split_set = ConstructorSet :: for_ty ( pcx. cx , pcx. ty ) . split ( pcx, ctors, is_top_level ) ;
798
795
let mut split_ctors = split_set. present ;
799
796
let missing_ctors = split_set. missing ;
800
797
if !missing_ctors. is_empty ( ) {
@@ -842,7 +839,7 @@ fn compute_usefulness<'p, 'tcx>(
842
839
// usually prefer to report the full list of constructors.
843
840
let all_missing = split_ctors. is_empty ( ) ;
844
841
let report_when_all_missing =
845
- pcx . is_top_level && !super :: deconstruct_pat:: IntRange :: is_integral ( pcx. ty ) ;
842
+ is_top_level && !super :: deconstruct_pat:: IntRange :: is_integral ( pcx. ty ) ;
846
843
let ctor = if all_missing && !report_when_all_missing {
847
844
Constructor :: Wildcard
848
845
} else {
@@ -918,9 +915,10 @@ fn collect_nonexhaustive_missing_variants<'p, 'tcx>(
918
915
column : & [ & DeconstructedPat < ' p , ' tcx > ] ,
919
916
) -> Vec < WitnessPat < ' tcx > > {
920
917
let ty = column[ 0 ] . ty ( ) ;
921
- let pcx = & PatCtxt { cx, ty, span : DUMMY_SP , is_top_level : false } ;
918
+ let pcx = & PatCtxt { cx, ty, span : DUMMY_SP } ;
922
919
923
- let set = ConstructorSet :: for_ty ( pcx. cx , pcx. ty ) . split ( pcx, column. iter ( ) . map ( |p| p. ctor ( ) ) ) ;
920
+ let column_ctors = column. iter ( ) . map ( |p| p. ctor ( ) ) ;
921
+ let set = ConstructorSet :: for_ty ( pcx. cx , pcx. ty ) . split ( pcx, column_ctors, false ) ;
924
922
if set. present . is_empty ( ) {
925
923
// We can't consistently handle the case where no constructors are present (since this would
926
924
// require digging deep through any type in case there's a non_exhaustive enum somewhere),
0 commit comments