-
Notifications
You must be signed in to change notification settings - Fork 13.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
150 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
// Test the suggestion to wrap an or-pattern as a function parameter in parens. | ||
|
||
// run-rustfix | ||
|
||
#![feature(or_patterns)] | ||
#![allow(warnings)] | ||
|
||
fn main() {} | ||
|
||
enum E { A, B } | ||
use E::*; | ||
|
||
#[cfg(FALSE)] | ||
fn fun1((A | B): E) {} //~ ERROR an or-pattern parameter must be wrapped in parenthesis |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
// Test the suggestion to wrap an or-pattern as a function parameter in parens. | ||
|
||
// run-rustfix | ||
|
||
#![feature(or_patterns)] | ||
#![allow(warnings)] | ||
|
||
fn main() {} | ||
|
||
enum E { A, B } | ||
use E::*; | ||
|
||
#[cfg(FALSE)] | ||
fn fun1(A | B: E) {} //~ ERROR an or-pattern parameter must be wrapped in parenthesis |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
error: an or-pattern parameter must be wrapped in parenthesis | ||
--> $DIR/fn-param-wrap-parens.rs:14:9 | ||
| | ||
LL | fn fun1(A | B: E) {} | ||
| ^^^^^ help: wrap the pattern in parenthesis: `(A | B)` | ||
|
||
error: aborting due to previous error | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
// Test the suggestion to remove a leading `|`. | ||
|
||
// run-rustfix | ||
|
||
#![feature(or_patterns)] | ||
#![allow(warnings)] | ||
|
||
fn main() {} | ||
|
||
#[cfg(FALSE)] | ||
fn leading_vert() { | ||
fn fun1( A: E) {} //~ ERROR a leading `|` is not allowed in a parameter pattern | ||
fn fun2( A: E) {} //~ ERROR a leading `|` is not allowed in a parameter pattern | ||
let ( A): E; //~ ERROR a leading `|` is only allowed in a top-level pattern | ||
let ( A): (E); //~ ERROR a leading `|` is only allowed in a top-level pattern | ||
let ( A,): (E,); //~ ERROR a leading `|` is only allowed in a top-level pattern | ||
let [ A ]: [E; 1]; //~ ERROR a leading `|` is only allowed in a top-level pattern | ||
let [ A ]: [E; 1]; //~ ERROR a leading `|` is only allowed in a top-level pattern | ||
let TS( A ): TS; //~ ERROR a leading `|` is only allowed in a top-level pattern | ||
let TS( A ): TS; //~ ERROR a leading `|` is only allowed in a top-level pattern | ||
let NS { f: A }: NS; //~ ERROR a leading `|` is only allowed in a top-level pattern | ||
let NS { f: A }: NS; //~ ERROR a leading `|` is only allowed in a top-level pattern | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
// Test the suggestion to remove a leading `|`. | ||
|
||
// run-rustfix | ||
|
||
#![feature(or_patterns)] | ||
#![allow(warnings)] | ||
|
||
fn main() {} | ||
|
||
#[cfg(FALSE)] | ||
fn leading_vert() { | ||
fn fun1( | A: E) {} //~ ERROR a leading `|` is not allowed in a parameter pattern | ||
fn fun2( || A: E) {} //~ ERROR a leading `|` is not allowed in a parameter pattern | ||
let ( | A): E; //~ ERROR a leading `|` is only allowed in a top-level pattern | ||
let ( || A): (E); //~ ERROR a leading `|` is only allowed in a top-level pattern | ||
let ( | A,): (E,); //~ ERROR a leading `|` is only allowed in a top-level pattern | ||
let [ | A ]: [E; 1]; //~ ERROR a leading `|` is only allowed in a top-level pattern | ||
let [ || A ]: [E; 1]; //~ ERROR a leading `|` is only allowed in a top-level pattern | ||
let TS( | A ): TS; //~ ERROR a leading `|` is only allowed in a top-level pattern | ||
let TS( || A ): TS; //~ ERROR a leading `|` is only allowed in a top-level pattern | ||
let NS { f: | A }: NS; //~ ERROR a leading `|` is only allowed in a top-level pattern | ||
let NS { f: || A }: NS; //~ ERROR a leading `|` is only allowed in a top-level pattern | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
error: a leading `|` is not allowed in a parameter pattern | ||
--> $DIR/remove-leading-vert.rs:12:14 | ||
| | ||
LL | fn fun1( | A: E) {} | ||
| ^ help: remove the `|` | ||
|
||
error: a leading `|` is not allowed in a parameter pattern | ||
--> $DIR/remove-leading-vert.rs:13:14 | ||
| | ||
LL | fn fun2( || A: E) {} | ||
| ^^ help: remove the `||` | ||
|
||
error: a leading `|` is only allowed in a top-level pattern | ||
--> $DIR/remove-leading-vert.rs:14:11 | ||
| | ||
LL | let ( | A): E; | ||
| ^ help: remove the `|` | ||
|
||
error: a leading `|` is only allowed in a top-level pattern | ||
--> $DIR/remove-leading-vert.rs:15:11 | ||
| | ||
LL | let ( || A): (E); | ||
| ^^ help: remove the `||` | ||
|
||
error: a leading `|` is only allowed in a top-level pattern | ||
--> $DIR/remove-leading-vert.rs:16:11 | ||
| | ||
LL | let ( | A,): (E,); | ||
| ^ help: remove the `|` | ||
|
||
error: a leading `|` is only allowed in a top-level pattern | ||
--> $DIR/remove-leading-vert.rs:17:11 | ||
| | ||
LL | let [ | A ]: [E; 1]; | ||
| ^ help: remove the `|` | ||
|
||
error: a leading `|` is only allowed in a top-level pattern | ||
--> $DIR/remove-leading-vert.rs:18:11 | ||
| | ||
LL | let [ || A ]: [E; 1]; | ||
| ^^ help: remove the `||` | ||
|
||
error: a leading `|` is only allowed in a top-level pattern | ||
--> $DIR/remove-leading-vert.rs:19:13 | ||
| | ||
LL | let TS( | A ): TS; | ||
| ^ help: remove the `|` | ||
|
||
error: a leading `|` is only allowed in a top-level pattern | ||
--> $DIR/remove-leading-vert.rs:20:13 | ||
| | ||
LL | let TS( || A ): TS; | ||
| ^^ help: remove the `||` | ||
|
||
error: a leading `|` is only allowed in a top-level pattern | ||
--> $DIR/remove-leading-vert.rs:21:17 | ||
| | ||
LL | let NS { f: | A }: NS; | ||
| ^ help: remove the `|` | ||
|
||
error: a leading `|` is only allowed in a top-level pattern | ||
--> $DIR/remove-leading-vert.rs:22:17 | ||
| | ||
LL | let NS { f: || A }: NS; | ||
| ^^ help: remove the `||` | ||
|
||
error: aborting due to 11 previous errors | ||
|