This repository was archived by the owner on May 28, 2025. It is now read-only.
File tree Expand file tree Collapse file tree 3 files changed +96
-0
lines changed
tests/ui/rfcs/rfc-2008-non-exhaustive Expand file tree Collapse file tree 3 files changed +96
-0
lines changed Original file line number Diff line number Diff line change 1+ error: some variants are not matched explicitly
2+ --> $DIR/omitted-patterns-dont-lint-on-arm.rs:15:11
3+ |
4+ LL | match val {
5+ | ^^^ pattern `NonExhaustiveEnum::Struct { .. }` not covered
6+ |
7+ = help: ensure that all variants are matched explicitly by adding the suggested match arms
8+ = note: the matched value is of type `NonExhaustiveEnum` and the `non_exhaustive_omitted_patterns` attribute was found
9+ note: the lint level is defined here
10+ --> $DIR/omitted-patterns-dont-lint-on-arm.rs:14:12
11+ |
12+ LL | #[deny(non_exhaustive_omitted_patterns)]
13+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
14+
15+ error: some variants are not matched explicitly
16+ --> $DIR/omitted-patterns-dont-lint-on-arm.rs:23:11
17+ |
18+ LL | match val {
19+ | ^^^ pattern `NonExhaustiveEnum::Struct { .. }` not covered
20+ |
21+ = help: ensure that all variants are matched explicitly by adding the suggested match arms
22+ = note: the matched value is of type `NonExhaustiveEnum` and the `non_exhaustive_omitted_patterns` attribute was found
23+ note: the lint level is defined here
24+ --> $DIR/omitted-patterns-dont-lint-on-arm.rs:22:27
25+ |
26+ LL | #[cfg_attr(lint, deny(non_exhaustive_omitted_patterns))]
27+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
28+
29+ error: aborting due to 2 previous errors
30+
Original file line number Diff line number Diff line change 1+ error: some variants are not matched explicitly
2+ --> $DIR/omitted-patterns-dont-lint-on-arm.rs:15:11
3+ |
4+ LL | match val {
5+ | ^^^ pattern `NonExhaustiveEnum::Struct { .. }` not covered
6+ |
7+ = help: ensure that all variants are matched explicitly by adding the suggested match arms
8+ = note: the matched value is of type `NonExhaustiveEnum` and the `non_exhaustive_omitted_patterns` attribute was found
9+ note: the lint level is defined here
10+ --> $DIR/omitted-patterns-dont-lint-on-arm.rs:14:12
11+ |
12+ LL | #[deny(non_exhaustive_omitted_patterns)]
13+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
14+
15+ error: aborting due to previous error
16+
Original file line number Diff line number Diff line change 1+ // revisions: normal lint
2+ // Test that putting the lint level on a match arm emits a warning, as this was previously
3+ // meaningful and is no longer.
4+ #![ feature( non_exhaustive_omitted_patterns_lint) ]
5+
6+ // aux-build:enums.rs
7+ extern crate enums;
8+
9+ use enums:: NonExhaustiveEnum ;
10+
11+ fn main ( ) {
12+ let val = NonExhaustiveEnum :: Unit ;
13+
14+ #[ deny( non_exhaustive_omitted_patterns) ]
15+ match val {
16+ //~^ ERROR some variants are not matched explicitly
17+ NonExhaustiveEnum :: Unit => { }
18+ NonExhaustiveEnum :: Tuple ( _) => { }
19+ _ => { }
20+ }
21+
22+ #[ cfg_attr( lint, deny( non_exhaustive_omitted_patterns) ) ]
23+ match val {
24+ //[lint]~^ ERROR some variants are not matched explicitly
25+ NonExhaustiveEnum :: Unit => { }
26+ NonExhaustiveEnum :: Tuple ( _) => { }
27+ _ => { }
28+ }
29+
30+ match val {
31+ NonExhaustiveEnum :: Unit => { }
32+ NonExhaustiveEnum :: Tuple ( _) => { }
33+ #[ deny( non_exhaustive_omitted_patterns) ]
34+ _ => { }
35+ }
36+
37+ match val {
38+ NonExhaustiveEnum :: Unit => { }
39+ NonExhaustiveEnum :: Tuple ( _) => { }
40+ #[ cfg_attr( lint, deny( non_exhaustive_omitted_patterns) ) ]
41+ _ => { }
42+ }
43+
44+ match val {
45+ NonExhaustiveEnum :: Unit => { }
46+ NonExhaustiveEnum :: Tuple ( _) => { }
47+ #[ cfg_attr( lint, warn( non_exhaustive_omitted_patterns) ) ]
48+ _ => { }
49+ }
50+ }
You can’t perform that action at this time.
0 commit comments