This repository was archived by the owner on May 28, 2025. It is now read-only.
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 {
2
2
A ,
3
3
B ,
4
4
#[ doc( hidden) ]
5
5
C ,
6
6
}
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 2
2
3
3
extern crate hidden;
4
4
5
- use hidden:: Foo ;
5
+ use hidden:: HiddenEnum ;
6
6
7
7
fn main ( ) {
8
- match Foo :: A {
9
- Foo :: A => { }
10
- Foo :: B => { }
8
+ match HiddenEnum :: A {
9
+ HiddenEnum :: A => { }
10
+ HiddenEnum :: B => { }
11
11
}
12
12
//~^^^^ non-exhaustive patterns: `_` not covered
13
13
14
- match Foo :: A {
15
- Foo :: A => { }
16
- Foo :: C => { }
14
+ match HiddenEnum :: A {
15
+ HiddenEnum :: A => { }
16
+ HiddenEnum :: C => { }
17
17
}
18
18
//~^^^^ non-exhaustive patterns: `B` not covered
19
19
20
- match Foo :: A {
21
- Foo :: A => { }
20
+ match HiddenEnum :: A {
21
+ HiddenEnum :: A => { }
22
22
}
23
23
//~^^^ non-exhaustive patterns: `B` and `_` not covered
24
24
25
25
match None {
26
26
None => { }
27
- Some ( Foo :: A ) => { }
27
+ Some ( HiddenEnum :: A ) => { }
28
28
}
29
29
//~^^^^ non-exhaustive patterns: `Some(B)` and `Some(_)` not covered
30
30
}
You can’t perform that action at this time.
0 commit comments