Skip to content

Commit c3132e7

Browse files
committed
allow irrefutable let patterns in feature gate test
1 parent 087b872 commit c3132e7

File tree

2 files changed

+10
-29
lines changed

2 files changed

+10
-29
lines changed

Diff for: tests/ui/feature-gates/feature-gate-guard-patterns.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
#![allow(irrefutable_let_patterns)]
2+
13
fn match_guards_still_work() {
24
match 0 {
35
0 if guard(0) => {},
@@ -24,11 +26,9 @@ fn other_guards_dont() {
2426

2527
if let (x if guard(x)) = 0 {}
2628
//~^ ERROR: guard patterns are experimental
27-
//~| WARN: irrefutable
2829

2930
while let (x if guard(x)) = 0 {}
3031
//~^ ERROR: guard patterns are experimental
31-
//~| WARN: irrefutable
3232

3333
#[cfg(FALSE)]
3434
while let (x if guard(x)) = 0 {}

Diff for: tests/ui/feature-gates/feature-gate-guard-patterns.stderr

+8-27
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
error: unexpected parentheses surrounding `match` arm pattern
2-
--> $DIR/feature-gate-guard-patterns.rs:10:9
2+
--> $DIR/feature-gate-guard-patterns.rs:12:9
33
|
44
LL | (0 if guard(0)) => {},
55
| ^ ^
@@ -11,7 +11,7 @@ LL + 0 if guard(0) => {},
1111
|
1212

1313
error[E0425]: cannot find value `x` in this scope
14-
--> $DIR/feature-gate-guard-patterns.rs:21:22
14+
--> $DIR/feature-gate-guard-patterns.rs:23:22
1515
|
1616
LL | let ((x if guard(x)) | x) = 0;
1717
| ^ not found in this scope
@@ -23,13 +23,13 @@ LL | fn even_as_function_parameters(((x if guard(x), _) | (_, x)): (i32, i32)) {
2323
| ^
2424
|
2525
help: the binding `x` is available in a different scope in the same function
26-
--> $DIR/feature-gate-guard-patterns.rs:21:11
26+
--> $DIR/feature-gate-guard-patterns.rs:23:11
2727
|
2828
LL | let ((x if guard(x)) | x) = 0;
2929
| ^
3030

3131
error[E0658]: guard patterns are experimental
32-
--> $DIR/feature-gate-guard-patterns.rs:16:15
32+
--> $DIR/feature-gate-guard-patterns.rs:18:15
3333
|
3434
LL | (0 if guard(0)) | 1 => {},
3535
| ^^^^^^^^
@@ -40,7 +40,7 @@ LL | (0 if guard(0)) | 1 => {},
4040
= help: consider using match arm guards
4141

4242
error[E0658]: guard patterns are experimental
43-
--> $DIR/feature-gate-guard-patterns.rs:21:16
43+
--> $DIR/feature-gate-guard-patterns.rs:23:16
4444
|
4545
LL | let ((x if guard(x)) | x) = 0;
4646
| ^^^^^^^^
@@ -51,7 +51,7 @@ LL | let ((x if guard(x)) | x) = 0;
5151
= help: consider using match arm guards
5252

5353
error[E0658]: guard patterns are experimental
54-
--> $DIR/feature-gate-guard-patterns.rs:25:18
54+
--> $DIR/feature-gate-guard-patterns.rs:27:18
5555
|
5656
LL | if let (x if guard(x)) = 0 {}
5757
| ^^^^^^^^
@@ -62,7 +62,7 @@ LL | if let (x if guard(x)) = 0 {}
6262
= help: consider using match arm guards
6363

6464
error[E0658]: guard patterns are experimental
65-
--> $DIR/feature-gate-guard-patterns.rs:29:21
65+
--> $DIR/feature-gate-guard-patterns.rs:30:21
6666
|
6767
LL | while let (x if guard(x)) = 0 {}
6868
| ^^^^^^^^
@@ -94,26 +94,7 @@ LL | fn even_as_function_parameters(((x if guard(x), _) | (_, x)): (i32, i32)) {
9494
= note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date
9595
= help: consider using match arm guards
9696

97-
warning: irrefutable `if let` pattern
98-
--> $DIR/feature-gate-guard-patterns.rs:25:8
99-
|
100-
LL | if let (x if guard(x)) = 0 {}
101-
| ^^^^^^^^^^^^^^^^^^^^^^^
102-
|
103-
= note: this pattern will always match, so the `if let` is useless
104-
= help: consider replacing the `if let` with a `let`
105-
= note: `#[warn(irrefutable_let_patterns)]` on by default
106-
107-
warning: irrefutable `while let` pattern
108-
--> $DIR/feature-gate-guard-patterns.rs:29:11
109-
|
110-
LL | while let (x if guard(x)) = 0 {}
111-
| ^^^^^^^^^^^^^^^^^^^^^^^
112-
|
113-
= note: this pattern will always match, so the loop will never exit
114-
= help: consider instead using a `loop { ... }` with a `let` inside it
115-
116-
error: aborting due to 9 previous errors; 2 warnings emitted
97+
error: aborting due to 9 previous errors
11798

11899
Some errors have detailed explanations: E0425, E0658.
119100
For more information about an error, try `rustc --explain E0425`.

0 commit comments

Comments
 (0)