-
Notifications
You must be signed in to change notification settings - Fork 12.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Handle methodcalls & operators in patterns
- Loading branch information
Showing
11 changed files
with
295 additions
and
18 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
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
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
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
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
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 |
---|---|---|
@@ -1,5 +1,5 @@ | ||
// Parsing of range patterns | ||
|
||
fn main() { | ||
let 10 ..= 10 + 3 = 12; //~ expected one of `:`, `;`, `=`, or `|`, found `+` | ||
let 10 ..= 10 + 3 = 12; //~ expected pattern, found expression | ||
} |
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 |
---|---|---|
@@ -1,8 +1,8 @@ | ||
error: expected one of `:`, `;`, `=`, or `|`, found `+` | ||
--> $DIR/pat-ranges-3.rs:4:19 | ||
error: expected pattern, found expression | ||
--> $DIR/pat-ranges-3.rs:4:9 | ||
| | ||
LL | let 10 ..= 10 + 3 = 12; | ||
| ^ expected one of `:`, `;`, `=`, or `|` | ||
| ^^^^^^^^^^^^^ expressions are not allowed in patterns | ||
|
||
error: aborting due to 1 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
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 |
---|---|---|
@@ -1,8 +1,8 @@ | ||
error: expected one of `...`, `..=`, `..`, `:`, `;`, `=`, or `|`, found `-` | ||
--> $DIR/pat-ranges-4.rs:4:12 | ||
error: expected pattern, found expression | ||
--> $DIR/pat-ranges-4.rs:4:9 | ||
| | ||
LL | let 10 - 3 ..= 10 = 8; | ||
| ^ expected one of 7 possible tokens | ||
| ^^^^^^^^^^^^^ expressions are not allowed in patterns | ||
|
||
error: aborting due to 1 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,56 @@ | ||
struct Foo(String); | ||
struct Bar { baz: String } | ||
|
||
fn foo(foo: Foo) -> bool { | ||
match foo { | ||
Foo("hi".to_owned()) => true, | ||
//~^ ERROR expected pattern, found method call | ||
_ => false | ||
} | ||
} | ||
|
||
fn bar(bar: Bar) -> bool { | ||
match bar { | ||
Bar { baz: "hi".to_owned() } => true, | ||
//~^ ERROR expected pattern, found method call | ||
_ => false | ||
} | ||
} | ||
|
||
fn qux() { | ||
match u8::MAX { | ||
u8::MAX.abs() => (), | ||
//~^ ERROR expected pattern, found method call | ||
x.sqrt() @ .. => (), | ||
//~^ ERROR expected pattern, found method call | ||
//~| ERROR left-hand side of `@` must be a binding | ||
z @ w @ v.u() => (), | ||
//~^ ERROR expected pattern, found method call | ||
y.ilog(3) => (), | ||
//~^ ERROR expected pattern, found method call | ||
n + 1 => (), | ||
//~^ ERROR expected pattern, found expression | ||
"".f() + 14 * 8 => (), | ||
//~^ ERROR expected pattern, found expression | ||
_ => () | ||
} | ||
} | ||
|
||
fn quux() { | ||
let foo = vec!["foo".to_string()]; | ||
|
||
match foo.as_slice() { | ||
&["foo".to_string()] => {} | ||
//~^ ERROR expected pattern, found method call | ||
_ => {} | ||
}; | ||
} | ||
|
||
fn main() { | ||
if let (-1.some(4)) = (0, Some(4)) {} | ||
//~^ ERROR expected pattern, found method call | ||
|
||
if let (-1.Some(4)) = (0, Some(4)) {} | ||
//~^ ERROR expected one of `)`, `,`, `...`, `..=`, `..`, or `|`, found `.` | ||
//~| HELP missing `,` | ||
} |
Oops, something went wrong.