-
Notifications
You must be signed in to change notification settings - Fork 12.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
96 additions
and
0 deletions.
There are no files selected for viewing
30 changes: 30 additions & 0 deletions
30
tests/ui/rfcs/rfc-2008-non-exhaustive/omitted-patterns-dont-lint-on-arm.lint.stderr
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
error: some variants are not matched explicitly | ||
--> $DIR/omitted-patterns-dont-lint-on-arm.rs:15:11 | ||
| | ||
LL | match val { | ||
| ^^^ pattern `NonExhaustiveEnum::Struct { .. }` not covered | ||
| | ||
= help: ensure that all variants are matched explicitly by adding the suggested match arms | ||
= note: the matched value is of type `NonExhaustiveEnum` and the `non_exhaustive_omitted_patterns` attribute was found | ||
note: the lint level is defined here | ||
--> $DIR/omitted-patterns-dont-lint-on-arm.rs:14:12 | ||
| | ||
LL | #[deny(non_exhaustive_omitted_patterns)] | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ||
|
||
error: some variants are not matched explicitly | ||
--> $DIR/omitted-patterns-dont-lint-on-arm.rs:23:11 | ||
| | ||
LL | match val { | ||
| ^^^ pattern `NonExhaustiveEnum::Struct { .. }` not covered | ||
| | ||
= help: ensure that all variants are matched explicitly by adding the suggested match arms | ||
= note: the matched value is of type `NonExhaustiveEnum` and the `non_exhaustive_omitted_patterns` attribute was found | ||
note: the lint level is defined here | ||
--> $DIR/omitted-patterns-dont-lint-on-arm.rs:22:27 | ||
| | ||
LL | #[cfg_attr(lint, deny(non_exhaustive_omitted_patterns))] | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ||
|
||
error: aborting due to 2 previous errors | ||
|
16 changes: 16 additions & 0 deletions
16
tests/ui/rfcs/rfc-2008-non-exhaustive/omitted-patterns-dont-lint-on-arm.normal.stderr
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
error: some variants are not matched explicitly | ||
--> $DIR/omitted-patterns-dont-lint-on-arm.rs:15:11 | ||
| | ||
LL | match val { | ||
| ^^^ pattern `NonExhaustiveEnum::Struct { .. }` not covered | ||
| | ||
= help: ensure that all variants are matched explicitly by adding the suggested match arms | ||
= note: the matched value is of type `NonExhaustiveEnum` and the `non_exhaustive_omitted_patterns` attribute was found | ||
note: the lint level is defined here | ||
--> $DIR/omitted-patterns-dont-lint-on-arm.rs:14:12 | ||
| | ||
LL | #[deny(non_exhaustive_omitted_patterns)] | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ||
|
||
error: aborting due to previous error | ||
|
50 changes: 50 additions & 0 deletions
50
tests/ui/rfcs/rfc-2008-non-exhaustive/omitted-patterns-dont-lint-on-arm.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
// revisions: normal lint | ||
// Test that putting the lint level on a match arm emits a warning, as this was previously | ||
// meaningful and is no longer. | ||
#![feature(non_exhaustive_omitted_patterns_lint)] | ||
|
||
// aux-build:enums.rs | ||
extern crate enums; | ||
|
||
use enums::NonExhaustiveEnum; | ||
|
||
fn main() { | ||
let val = NonExhaustiveEnum::Unit; | ||
|
||
#[deny(non_exhaustive_omitted_patterns)] | ||
match val { | ||
//~^ ERROR some variants are not matched explicitly | ||
NonExhaustiveEnum::Unit => {} | ||
NonExhaustiveEnum::Tuple(_) => {} | ||
_ => {} | ||
} | ||
|
||
#[cfg_attr(lint, deny(non_exhaustive_omitted_patterns))] | ||
match val { | ||
//[lint]~^ ERROR some variants are not matched explicitly | ||
NonExhaustiveEnum::Unit => {} | ||
NonExhaustiveEnum::Tuple(_) => {} | ||
_ => {} | ||
} | ||
|
||
match val { | ||
NonExhaustiveEnum::Unit => {} | ||
NonExhaustiveEnum::Tuple(_) => {} | ||
#[deny(non_exhaustive_omitted_patterns)] | ||
_ => {} | ||
} | ||
|
||
match val { | ||
NonExhaustiveEnum::Unit => {} | ||
NonExhaustiveEnum::Tuple(_) => {} | ||
#[cfg_attr(lint, deny(non_exhaustive_omitted_patterns))] | ||
_ => {} | ||
} | ||
|
||
match val { | ||
NonExhaustiveEnum::Unit => {} | ||
NonExhaustiveEnum::Tuple(_) => {} | ||
#[cfg_attr(lint, warn(non_exhaustive_omitted_patterns))] | ||
_ => {} | ||
} | ||
} |