File tree Expand file tree Collapse file tree 3 files changed +8
-9
lines changed
librustc_mir/hair/pattern
test/ui/pattern/usefulness Expand file tree Collapse file tree 3 files changed +8
-9
lines changed Original file line number Diff line number Diff line change @@ -180,11 +180,8 @@ impl<'tcx> MatchVisitor<'_, 'tcx> {
180
180
ty:: Never => true ,
181
181
ty:: Adt ( def, _) => {
182
182
def_span = self . tcx . hir ( ) . span_if_local ( def. did ) ;
183
- if def. variants . len ( ) < 4 && !def. variants . is_empty ( ) {
184
- // keep around to point at the definition of non-covered variants
185
- missing_variants =
186
- def. variants . iter ( ) . map ( |variant| variant. ident ) . collect ( ) ;
187
- }
183
+ missing_variants =
184
+ def. variants . iter ( ) . map ( |variant| variant. ident ) . collect ( ) ;
188
185
189
186
def. variants . is_empty ( ) && !cx. is_foreign_non_exhaustive_enum ( pat_ty)
190
187
}
@@ -219,8 +216,10 @@ impl<'tcx> MatchVisitor<'_, 'tcx> {
219
216
err. span_label ( sp, format ! ( "`{}` defined here" , pat_ty) ) ;
220
217
}
221
218
// point at the definition of non-covered enum variants
222
- for variant in & missing_variants {
223
- err. span_label ( variant. span , "variant not covered" ) ;
219
+ if missing_variants. len ( ) < 4 {
220
+ for variant in & missing_variants {
221
+ err. span_label ( variant. span , "variant not covered" ) ;
222
+ }
224
223
}
225
224
err. emit ( ) ;
226
225
}
Original file line number Diff line number Diff line change @@ -44,5 +44,5 @@ fn main() {
44
44
match NonEmptyEnum2 :: Foo ( true ) { }
45
45
//~^ ERROR multiple patterns of type `NonEmptyEnum2` are not handled
46
46
match NonEmptyEnum5 :: V1 { }
47
- //~^ ERROR type `NonEmptyEnum5` is non-empty
47
+ //~^ ERROR multiple patterns of type `NonEmptyEnum5` are not handled
48
48
}
Original file line number Diff line number Diff line change @@ -50,7 +50,7 @@ LL | match NonEmptyEnum2::Foo(true) {}
50
50
|
51
51
= help: ensure that all possible cases are being handled, possibly by adding wildcards or more match arms
52
52
53
- error[E0004]: non-exhaustive patterns: type `NonEmptyEnum5` is non-empty
53
+ error[E0004]: non-exhaustive patterns: multiple patterns of type `NonEmptyEnum5` are not handled
54
54
--> $DIR/match-empty.rs:46:11
55
55
|
56
56
LL | / enum NonEmptyEnum5 {
You can’t perform that action at this time.
0 commit comments