File tree Expand file tree Collapse file tree 3 files changed +35
-11
lines changed
src/test/ui/pattern/usefulness Expand file tree Collapse file tree 3 files changed +35
-11
lines changed Original file line number Diff line number Diff line change 1- pub enum Foo {
1+ pub enum HiddenEnum {
22 A ,
33 B ,
44 #[ doc( hidden) ]
55 C ,
66}
7+
8+ #[ derive( Default ) ]
9+ pub struct HiddenStruct {
10+ pub one : u8 ,
11+ pub two : bool ,
12+ #[ doc( hidden) ]
13+ pub hide : usize ,
14+ }
Original file line number Diff line number Diff line change 1+ // aux-build:hidden.rs
2+
3+ extern crate hidden;
4+
5+ use hidden:: HiddenStruct ;
6+
7+ fn main ( ) {
8+ let HiddenStruct { one, two, } = HiddenStruct :: default ( ) ;
9+ //~^ pattern requires `..` due to inaccessible fields
10+
11+ let HiddenStruct { one, } = HiddenStruct :: default ( ) ;
12+ //~^ pattern does not mention field `two` and inaccessible fields
13+
14+ let HiddenStruct { one, hide } = HiddenStruct :: default ( ) ;
15+ //~^ pattern does not mention field `two`
16+ }
Original file line number Diff line number Diff line change 22
33extern crate hidden;
44
5- use hidden:: Foo ;
5+ use hidden:: HiddenEnum ;
66
77fn main ( ) {
8- match Foo :: A {
9- Foo :: A => { }
10- Foo :: B => { }
8+ match HiddenEnum :: A {
9+ HiddenEnum :: A => { }
10+ HiddenEnum :: B => { }
1111 }
1212 //~^^^^ non-exhaustive patterns: `_` not covered
1313
14- match Foo :: A {
15- Foo :: A => { }
16- Foo :: C => { }
14+ match HiddenEnum :: A {
15+ HiddenEnum :: A => { }
16+ HiddenEnum :: C => { }
1717 }
1818 //~^^^^ non-exhaustive patterns: `B` not covered
1919
20- match Foo :: A {
21- Foo :: A => { }
20+ match HiddenEnum :: A {
21+ HiddenEnum :: A => { }
2222 }
2323 //~^^^ non-exhaustive patterns: `B` and `_` not covered
2424
2525 match None {
2626 None => { }
27- Some ( Foo :: A ) => { }
27+ Some ( HiddenEnum :: A ) => { }
2828 }
2929 //~^^^^ non-exhaustive patterns: `Some(B)` and `Some(_)` not covered
3030}
You can’t perform that action at this time.
0 commit comments