forked from rust-lang/rust
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Rollup merge of rust-lang#59453 - estebank:recover-tuple-parse, r=pet…
…rochenkov Recover from parse error in tuple syntax
- Loading branch information
Showing
13 changed files
with
228 additions
and
34 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,10 @@ | ||
fn main () { | ||
let sr: Vec<(u32, _, _) = vec![]; //~ ERROR expected one of `,` or `>`, found `=` | ||
let sr: Vec<(u32, _, _) = vec![]; | ||
//~^ ERROR expected one of `,` or `>`, found `=` | ||
//~| ERROR expected value, found struct `Vec` | ||
//~| ERROR mismatched types | ||
//~| ERROR invalid left-hand side expression | ||
//~| ERROR expected expression, found reserved identifier `_` | ||
let sr2: Vec<(u32, _, _)> = sr.iter().map(|(faction, th_sender, th_receiver)| {}).collect(); | ||
//~^ ERROR no method named `iter` found for type `()` in the current scope | ||
} |
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,10 +1,47 @@ | ||
error: expected expression, found reserved identifier `_` | ||
--> $DIR/issue-34334.rs:2:23 | ||
| | ||
LL | let sr: Vec<(u32, _, _) = vec![]; | ||
| ^ expected expression | ||
|
||
error: expected one of `,` or `>`, found `=` | ||
--> $DIR/issue-34334.rs:2:29 | ||
| | ||
LL | let sr: Vec<(u32, _, _) = vec![]; | ||
| -- ^ expected one of `,` or `>` here | ||
| | | ||
| --- ^ expected one of `,` or `>` here | ||
| | | | ||
| | help: use `=` if you meant to assign | ||
| while parsing the type for `sr` | ||
|
||
error: aborting due to previous error | ||
error[E0423]: expected value, found struct `Vec` | ||
--> $DIR/issue-34334.rs:2:13 | ||
| | ||
LL | let sr: Vec<(u32, _, _) = vec![]; | ||
| ^^^ did you mean `Vec { /* fields */ }`? | ||
|
||
error[E0308]: mismatched types | ||
--> $DIR/issue-34334.rs:2:31 | ||
| | ||
LL | let sr: Vec<(u32, _, _) = vec![]; | ||
| ^^^^^^ expected bool, found struct `std::vec::Vec` | ||
| | ||
= note: expected type `bool` | ||
found type `std::vec::Vec<_>` | ||
= note: this error originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info) | ||
|
||
error[E0070]: invalid left-hand side expression | ||
--> $DIR/issue-34334.rs:2:13 | ||
| | ||
LL | let sr: Vec<(u32, _, _) = vec![]; | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^ left-hand of expression not valid | ||
|
||
error[E0599]: no method named `iter` found for type `()` in the current scope | ||
--> $DIR/issue-34334.rs:8:36 | ||
| | ||
LL | let sr2: Vec<(u32, _, _)> = sr.iter().map(|(faction, th_sender, th_receiver)| {}).collect(); | ||
| ^^^^ | ||
|
||
error: aborting due to 6 previous errors | ||
|
||
Some errors occurred: E0070, E0308, E0423, E0599. | ||
For more information about an error, try `rustc --explain E0070`. |
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 @@ | ||
fn main() { | ||
match 0 { | ||
match (0, 1) { | ||
(, ..) => {} //~ ERROR expected pattern, found `,` | ||
} | ||
} |
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 @@ | ||
fn main() { | ||
match 0 { | ||
match (0, 1) { | ||
(pat ..) => {} //~ ERROR unexpected token: `)` | ||
} | ||
} |
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 @@ | ||
enum Enum { | ||
Foo { a: usize, b: usize }, | ||
Bar(usize, usize), | ||
} | ||
|
||
fn main() { | ||
let x = Enum::Foo(a: 3, b: 4); | ||
//~^ ERROR expected type, found `3` | ||
match x { | ||
Enum::Foo(a, b) => {} | ||
//~^ ERROR expected tuple struct/variant, found struct variant `Enum::Foo` | ||
Enum::Bar(a, b) => {} | ||
} | ||
} |
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 @@ | ||
error: expected type, found `3` | ||
--> $DIR/recover-from-bad-variant.rs:7:26 | ||
| | ||
LL | let x = Enum::Foo(a: 3, b: 4); | ||
| ^ expecting a type here because of type ascription | ||
| | ||
= note: type ascription is a nightly-only feature that lets you annotate an expression with a type: `<expr>: <type>` | ||
note: this expression expects an ascribed type after the colon | ||
--> $DIR/recover-from-bad-variant.rs:7:23 | ||
| | ||
LL | let x = Enum::Foo(a: 3, b: 4); | ||
| ^ | ||
= help: this might be indicative of a syntax error elsewhere | ||
|
||
error[E0532]: expected tuple struct/variant, found struct variant `Enum::Foo` | ||
--> $DIR/recover-from-bad-variant.rs:10:9 | ||
| | ||
LL | Enum::Foo(a, b) => {} | ||
| ^^^^^^^^^ did you mean `Enum::Foo { /* fields */ }`? | ||
|
||
error: aborting due to 2 previous errors | ||
|
||
For more information about this error, try `rustc --explain E0532`. |
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,12 @@ | ||
fn main() { | ||
let x = (1, 2, 3, 4); | ||
match x { | ||
(1, .., 4) => {} | ||
(1, .=., 4) => { let _: usize = ""; } | ||
//~^ ERROR expected pattern, found `.` | ||
//~| ERROR mismatched types | ||
(.=., 4) => {} | ||
//~^ ERROR expected pattern, found `.` | ||
(1, 2, 3, 4) => {} | ||
} | ||
} |
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,24 @@ | ||
error: expected pattern, found `.` | ||
--> $DIR/recover-tuple-pat.rs:5:13 | ||
| | ||
LL | (1, .=., 4) => { let _: usize = ""; } | ||
| ^ expected pattern | ||
|
||
error: expected pattern, found `.` | ||
--> $DIR/recover-tuple-pat.rs:8:10 | ||
| | ||
LL | (.=., 4) => {} | ||
| ^ expected pattern | ||
|
||
error[E0308]: mismatched types | ||
--> $DIR/recover-tuple-pat.rs:5:41 | ||
| | ||
LL | (1, .=., 4) => { let _: usize = ""; } | ||
| ^^ expected usize, found reference | ||
| | ||
= note: expected type `usize` | ||
found type `&'static str` | ||
|
||
error: aborting due to 3 previous errors | ||
|
||
For more information about this error, try `rustc --explain E0308`. |
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,11 @@ | ||
fn main() { | ||
// no complaints about the tuple not matching the expected type | ||
let x: (usize, usize, usize) = (3, .=.); | ||
//~^ ERROR expected expression, found `.` | ||
// verify that the parser recovers: | ||
let y: usize = ""; //~ ERROR mismatched types | ||
// no complaints about the type | ||
foo(x); | ||
} | ||
|
||
fn foo(_: (usize, usize, usize)) {} |
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,18 @@ | ||
error: expected expression, found `.` | ||
--> $DIR/recover-tuple.rs:3:40 | ||
| | ||
LL | let x: (usize, usize, usize) = (3, .=.); | ||
| ^ expected expression | ||
|
||
error[E0308]: mismatched types | ||
--> $DIR/recover-tuple.rs:6:20 | ||
| | ||
LL | let y: usize = ""; | ||
| ^^ expected usize, found reference | ||
| | ||
= note: expected type `usize` | ||
found type `&'static str` | ||
|
||
error: aborting due to 2 previous errors | ||
|
||
For more information about this error, try `rustc --explain E0308`. |
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