@@ -8,45 +8,59 @@ fn main() {}
88// The classic use for empty types.
99fn safe_unwrap_result < T > ( res : Result < T , Void > ) {
1010 let Ok ( _x) = res;
11+ // FIXME(never_patterns): These should be allowed
1112 let ( Ok ( _x) | Err ( !) ) = & res;
1213 //~^ ERROR: is not bound in all patterns
1314 let ( Ok ( _x) | Err ( & !) ) = res. as_ref ( ) ;
1415 //~^ ERROR: is not bound in all patterns
1516}
1617
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.
2021 match Some ( 0 ) {
2122 None => { }
2223 Some ( !) => { }
2324 }
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.
2526 match ( ) {
2627 ( ) => { }
2728 ! => { }
2829 }
29- // Don't accept even on an empty branch.
30+ // FIXME(never_patterns): Don't accept even on an empty branch.
3031 match None :: < Void > {
3132 None => { }
3233 ! => { }
3334 }
34- // Let alone if the emptiness is behind a reference.
35+ // FIXME(never_patterns): Let alone if the emptiness is behind a reference.
3536 match None :: < & Void > {
3637 None => { }
3738 ! => { }
3839 }
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+ }
4054 match None :: < & Void > {
4155 None => { }
4256 Some ( !) => { }
4357 }
44- // Accept on a nested empty type.
58+ // Accept on a composite empty type.
4559 match None :: < & ( u32 , Void ) > {
4660 None => { }
4761 Some ( & !) => { }
4862 }
49- // Accept on an basic empty type.
63+ // Accept on an simple empty type.
5064 match None :: < Void > {
5165 None => { }
5266 Some ( !) => { }
@@ -64,15 +78,15 @@ fn never_pattern_location() {
6478fn never_and_bindings ( ) {
6579 let x: Result < bool , & ( u32 , Void ) > = Ok ( false ) ;
6680
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.
6882 match x {
6983 Ok ( _x) | Err ( & !) => { }
7084 //~^ ERROR: is not bound in all patterns
7185 }
7286 let ( Ok ( _x) | Err ( & !) ) = x;
7387 //~^ ERROR: is not bound in all patterns
7488
75- // A never pattern mustn't have bindings.
89+ // FIXME(never_patterns): A never pattern mustn't have bindings.
7690 match x {
7791 Ok ( _) => { }
7892 Err ( & ( _b, !) ) => { }
0 commit comments