@@ -8,45 +8,59 @@ fn main() {}
8
8
// The classic use for empty types.
9
9
fn safe_unwrap_result < T > ( res : Result < T , Void > ) {
10
10
let Ok ( _x) = res;
11
+ // FIXME(never_patterns): These should be allowed
11
12
let ( Ok ( _x) | Err ( !) ) = & res;
12
13
//~^ ERROR: is not bound in all patterns
13
14
let ( Ok ( _x) | Err ( & !) ) = res. as_ref ( ) ;
14
15
//~^ ERROR: is not bound in all patterns
15
16
}
16
17
17
- // Check we only accept `!` where we want.
18
- fn never_pattern_location ( ) {
19
- // Don't accept on a non-empty type.
18
+ // Check we only accept `!` where we want to .
19
+ fn never_pattern_location ( void : Void ) {
20
+ // FIXME(never_patterns): Don't accept on a non-empty type.
20
21
match Some ( 0 ) {
21
22
None => { }
22
23
Some ( !) => { }
23
24
}
24
- // Don't accept on an arbitrary type, even if there are no more branches.
25
+ // FIXME(never_patterns): Don't accept on an arbitrary type, even if there are no more branches.
25
26
match ( ) {
26
27
( ) => { }
27
28
! => { }
28
29
}
29
- // Don't accept even on an empty branch.
30
+ // FIXME(never_patterns): Don't accept even on an empty branch.
30
31
match None :: < Void > {
31
32
None => { }
32
33
! => { }
33
34
}
34
- // Let alone if the emptiness is behind a reference.
35
+ // FIXME(never_patterns): Let alone if the emptiness is behind a reference.
35
36
match None :: < & Void > {
36
37
None => { }
37
38
! => { }
38
39
}
39
- // Don't participate in match ergonomics.
40
+ // Participate in match ergonomics.
41
+ match & void {
42
+ ! => { }
43
+ }
44
+ match & & void {
45
+ ! => { }
46
+ }
47
+ match & & void {
48
+ & ! => { }
49
+ }
50
+ match & None :: < Void > {
51
+ None => { }
52
+ Some ( !) => { }
53
+ }
40
54
match None :: < & Void > {
41
55
None => { }
42
56
Some ( !) => { }
43
57
}
44
- // Accept on a nested empty type.
58
+ // Accept on a composite empty type.
45
59
match None :: < & ( u32 , Void ) > {
46
60
None => { }
47
61
Some ( & !) => { }
48
62
}
49
- // Accept on an basic empty type.
63
+ // Accept on an simple empty type.
50
64
match None :: < Void > {
51
65
None => { }
52
66
Some ( !) => { }
@@ -64,15 +78,15 @@ fn never_pattern_location() {
64
78
fn never_and_bindings ( ) {
65
79
let x: Result < bool , & ( u32 , Void ) > = Ok ( false ) ;
66
80
67
- // Never patterns in or-patterns don't need to share the same bindings.
81
+ // FIXME(never_patterns): Never patterns in or-patterns don't need to share the same bindings.
68
82
match x {
69
83
Ok ( _x) | Err ( & !) => { }
70
84
//~^ ERROR: is not bound in all patterns
71
85
}
72
86
let ( Ok ( _x) | Err ( & !) ) = x;
73
87
//~^ ERROR: is not bound in all patterns
74
88
75
- // A never pattern mustn't have bindings.
89
+ // FIXME(never_patterns): A never pattern mustn't have bindings.
76
90
match x {
77
91
Ok ( _) => { }
78
92
Err ( & ( _b, !) ) => { }
0 commit comments