diff --git a/src/test/ui/pattern/usefulness/auxiliary/hidden.rs b/src/test/ui/pattern/usefulness/auxiliary/hidden.rs index 742b7e82c16..364514ba1d3 100644 --- a/src/test/ui/pattern/usefulness/auxiliary/hidden.rs +++ b/src/test/ui/pattern/usefulness/auxiliary/hidden.rs @@ -1,6 +1,14 @@ -pub enum Foo { +pub enum HiddenEnum { A, B, #[doc(hidden)] C, } + +#[derive(Default)] +pub struct HiddenStruct { + pub one: u8, + pub two: bool, + #[doc(hidden)] + pub hide: usize, +} diff --git a/src/test/ui/pattern/usefulness/doc-hidden-fields.rs b/src/test/ui/pattern/usefulness/doc-hidden-fields.rs new file mode 100644 index 00000000000..e947c223ede --- /dev/null +++ b/src/test/ui/pattern/usefulness/doc-hidden-fields.rs @@ -0,0 +1,16 @@ +// aux-build:hidden.rs + +extern crate hidden; + +use hidden::HiddenStruct; + +fn main() { + let HiddenStruct { one, two, } = HiddenStruct::default(); + //~^ pattern requires `..` due to inaccessible fields + + let HiddenStruct { one, } = HiddenStruct::default(); + //~^ pattern does not mention field `two` and inaccessible fields + + let HiddenStruct { one, hide } = HiddenStruct::default(); + //~^ pattern does not mention field `two` +} diff --git a/src/test/ui/pattern/usefulness/doc-hidden-non-exhaustive.rs b/src/test/ui/pattern/usefulness/doc-hidden-non-exhaustive.rs index a1dcab09314..23c57f2bc6a 100644 --- a/src/test/ui/pattern/usefulness/doc-hidden-non-exhaustive.rs +++ b/src/test/ui/pattern/usefulness/doc-hidden-non-exhaustive.rs @@ -2,29 +2,29 @@ extern crate hidden; -use hidden::Foo; +use hidden::HiddenEnum; fn main() { - match Foo::A { - Foo::A => {} - Foo::B => {} + match HiddenEnum::A { + HiddenEnum::A => {} + HiddenEnum::B => {} } //~^^^^ non-exhaustive patterns: `_` not covered - match Foo::A { - Foo::A => {} - Foo::C => {} + match HiddenEnum::A { + HiddenEnum::A => {} + HiddenEnum::C => {} } //~^^^^ non-exhaustive patterns: `B` not covered - match Foo::A { - Foo::A => {} + match HiddenEnum::A { + HiddenEnum::A => {} } //~^^^ non-exhaustive patterns: `B` and `_` not covered match None { None => {} - Some(Foo::A) => {} + Some(HiddenEnum::A) => {} } //~^^^^ non-exhaustive patterns: `Some(B)` and `Some(_)` not covered }