Add ui test for empty fields for omitted_patterns lint

This commit is contained in:
Devin Ragotzy 2021-10-01 21:20:29 -04:00
parent f7a8980347
commit 3d83ff6aa3
3 changed files with 15 additions and 3 deletions

View File

@ -31,3 +31,11 @@ pub struct NestedStruct {
pub foo: u16,
pub bar: NormalStruct,
}
#[derive(Default)]
#[non_exhaustive]
pub struct MixedVisFields {
pub a: u16,
pub b: bool,
pub(crate) foo: bool,
}

View File

@ -10,7 +10,7 @@ use enums::{
EmptyNonExhaustiveEnum, NestedNonExhaustive, NonExhaustiveEnum, NonExhaustiveSingleVariant,
VariantNonExhaustive,
};
use structs::{FunctionalRecord, NestedStruct, NormalStruct};
use structs::{FunctionalRecord, MixedVisFields, NestedStruct, NormalStruct};
#[non_exhaustive]
#[derive(Default)]
@ -141,6 +141,10 @@ fn main() {
//~^ 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
#[deny(non_exhaustive_omitted_patterns)]
match NonExhaustiveSingleVariant::A(true) {

View File

@ -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
error: some variants are not matched explicitly
--> $DIR/reachable-patterns.rs:153:9
--> $DIR/reachable-patterns.rs:157:9
|
LL | _ => {}
| ^ pattern `A(_)` not covered
|
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)]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^