Add tests
This commit is contained in:
parent
2db26d3d55
commit
7b19fb88be
3 changed files with 96 additions and 0 deletions
|
@ -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
|
||||||
|
|
|
@ -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
|
||||||
|
|
|
@ -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))]
|
||||||
|
_ => {}
|
||||||
|
}
|
||||||
|
}
|
Loading…
Add table
Add a link
Reference in a new issue