Add ui test for empty fields for omitted_patterns lint
This commit is contained in:
parent
f7a8980347
commit
3d83ff6aa3
@ -31,3 +31,11 @@ pub struct NestedStruct {
|
|||||||
pub foo: u16,
|
pub foo: u16,
|
||||||
pub bar: NormalStruct,
|
pub bar: NormalStruct,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[derive(Default)]
|
||||||
|
#[non_exhaustive]
|
||||||
|
pub struct MixedVisFields {
|
||||||
|
pub a: u16,
|
||||||
|
pub b: bool,
|
||||||
|
pub(crate) foo: bool,
|
||||||
|
}
|
||||||
|
@ -10,7 +10,7 @@ use enums::{
|
|||||||
EmptyNonExhaustiveEnum, NestedNonExhaustive, NonExhaustiveEnum, NonExhaustiveSingleVariant,
|
EmptyNonExhaustiveEnum, NestedNonExhaustive, NonExhaustiveEnum, NonExhaustiveSingleVariant,
|
||||||
VariantNonExhaustive,
|
VariantNonExhaustive,
|
||||||
};
|
};
|
||||||
use structs::{FunctionalRecord, NestedStruct, NormalStruct};
|
use structs::{FunctionalRecord, MixedVisFields, NestedStruct, NormalStruct};
|
||||||
|
|
||||||
#[non_exhaustive]
|
#[non_exhaustive]
|
||||||
#[derive(Default)]
|
#[derive(Default)]
|
||||||
@ -141,6 +141,10 @@ fn main() {
|
|||||||
//~^ some fields are not explicitly listed
|
//~^ some fields are not explicitly listed
|
||||||
//~^^ some fields are not explicitly listed
|
//~^^ some fields are not explicitly listed
|
||||||
|
|
||||||
|
// Ok: this tests https://github.com/rust-lang/rust/issues/89382
|
||||||
|
#[warn(non_exhaustive_omitted_patterns)]
|
||||||
|
let MixedVisFields { a, b, .. } = MixedVisFields::default();
|
||||||
|
|
||||||
// Ok: because this only has 1 variant
|
// Ok: because this only has 1 variant
|
||||||
#[deny(non_exhaustive_omitted_patterns)]
|
#[deny(non_exhaustive_omitted_patterns)]
|
||||||
match NonExhaustiveSingleVariant::A(true) {
|
match NonExhaustiveSingleVariant::A(true) {
|
||||||
|
@ -129,13 +129,13 @@ LL | #[deny(non_exhaustive_omitted_patterns)]
|
|||||||
= note: the matched value is of type `ErrorKind` and the `non_exhaustive_omitted_patterns` attribute was found
|
= note: the matched value is of type `ErrorKind` and the `non_exhaustive_omitted_patterns` attribute was found
|
||||||
|
|
||||||
error: some variants are not matched explicitly
|
error: some variants are not matched explicitly
|
||||||
--> $DIR/reachable-patterns.rs:153:9
|
--> $DIR/reachable-patterns.rs:157:9
|
||||||
|
|
|
|
||||||
LL | _ => {}
|
LL | _ => {}
|
||||||
| ^ pattern `A(_)` not covered
|
| ^ pattern `A(_)` not covered
|
||||||
|
|
|
|
||||||
note: the lint level is defined here
|
note: the lint level is defined here
|
||||||
--> $DIR/reachable-patterns.rs:151:12
|
--> $DIR/reachable-patterns.rs:155:12
|
||||||
|
|
|
|
||||||
LL | #[deny(non_exhaustive_omitted_patterns)]
|
LL | #[deny(non_exhaustive_omitted_patterns)]
|
||||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||||
|
Loading…
x
Reference in New Issue
Block a user