-
Notifications
You must be signed in to change notification settings - Fork 12.7k
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 #78379 - estebank:fn-signature-parse, r=varkor
Tweak invalid `fn` header and body parsing * Rely on regular "expected"/"found" parser error for `fn`, fix #77115 * Recover empty `fn` bodies when encountering `}` * Recover trailing `>` in return types * Recover from non-type in array type `[<BAD TOKEN>; LEN]`
- Loading branch information
Showing
16 changed files
with
79 additions
and
48 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,3 @@ | ||
fn foo(a: [0; 1]) {} //~ ERROR expected type, found `0` | ||
//~| ERROR expected `;` or `{`, found `]` | ||
|
||
fn main() {} |
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 |
---|---|---|
@@ -0,0 +1,5 @@ | ||
fn foo(x: i32): i32 { //~ ERROR expected one of `->`, `;`, `where`, or `{`, found `:` | ||
x | ||
} | ||
|
||
fn main() {} |
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: expected one of `->`, `;`, `where`, or `{`, found `:` | ||
--> $DIR/fn-colon-return-type.rs:1:15 | ||
| | ||
LL | fn foo(x: i32): i32 { | ||
| ^ expected one of `->`, `;`, `where`, or `{` | ||
|
||
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 |
---|---|---|
@@ -1,8 +1,9 @@ | ||
// Verify that '>' is not both expected and found at the same time, as it used | ||
// to happen in #24780. For example, following should be an error: | ||
// expected one of ..., `>`, ... found `>` | ||
// expected one of ..., `>`, ... found `>`. No longer exactly this, but keeping for posterity. | ||
|
||
fn foo() -> Vec<usize>> { | ||
//~^ ERROR expected `;` or `{`, found `>` | ||
fn foo() -> Vec<usize>> { //~ ERROR unmatched angle bracket | ||
Vec::new() | ||
} | ||
|
||
fn main() {} |
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 `;` or `{`, found `>` | ||
error: unmatched angle bracket | ||
--> $DIR/issue-24780.rs:5:23 | ||
| | ||
LL | fn foo() -> Vec<usize>> { | ||
| ^ expected `;` or `{` | ||
| ^^ help: remove extra angle bracket | ||
|
||
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 |
---|---|---|
@@ -1,3 +1,3 @@ | ||
trait Foo { fn a() } //~ ERROR expected `;` or `{`, found `}` | ||
trait Foo { fn a() } //~ ERROR expected one of `->`, `;`, `where`, or `{`, found `}` | ||
|
||
fn main() {} |
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,12 +1,10 @@ | ||
error: expected `;` or `{`, found `}` | ||
error: expected one of `->`, `;`, `where`, or `{`, found `}` | ||
--> $DIR/issue-6610.rs:1:20 | ||
| | ||
LL | trait Foo { fn a() } | ||
| - ^ | ||
| | | | ||
| | expected `;` or `{` | ||
| | the item list ends here | ||
| while parsing this item list starting here | ||
| - ^ expected one of `->`, `;`, `where`, or `{` | ||
| | | ||
| while parsing this `fn` | ||
|
||
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
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 `;` or `{`, found `:` | ||
--> $DIR/not-a-pred.rs:3:26 | ||
error: expected one of `->`, `;`, `where`, or `{`, found `:` | ||
--> $DIR/not-a-pred.rs:1:26 | ||
| | ||
LL | fn f(a: isize, b: isize) : lt(a, b) { } | ||
| ^ expected `;` or `{` | ||
| ^ expected one of `->`, `;`, `where`, or `{` | ||
|
||
error: aborting due to previous error | ||
|