-
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.
Auto merge of #117297 - clubby789:fn-trait-missing-paren, r=TaKO8Ki
Give a better diagnostic for missing parens in Fn* bounds Fixes #108109 It would be nice to try and recover here, but I'm not sure it's worth the effort, especially as the bounds on the recovered function would be incorrect.
- Loading branch information
Showing
7 changed files
with
73 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
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 |
---|---|---|
|
@@ -194,6 +194,9 @@ symbols! { | |
Error, | ||
File, | ||
FileType, | ||
Fn, | ||
FnMut, | ||
FnOnce, | ||
FormatSpec, | ||
Formatter, | ||
From, | ||
|
8 changes: 8 additions & 0 deletions
8
tests/ui/parser/issues/issue-108109-fn-trait-missing-paren.fixed
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 @@ | ||
// run-rustfix | ||
|
||
pub fn func<F>() where F: FnOnce() -> () {} | ||
//~^ ERROR expected one of | ||
//~| NOTE expected one of | ||
//~| NOTE `Fn` bounds require arguments in parentheses | ||
|
||
fn main() {} |
8 changes: 8 additions & 0 deletions
8
tests/ui/parser/issues/issue-108109-fn-trait-missing-paren.rs
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 @@ | ||
// run-rustfix | ||
|
||
pub fn func<F>() where F: FnOnce -> () {} | ||
//~^ ERROR expected one of | ||
//~| NOTE expected one of | ||
//~| NOTE `Fn` bounds require arguments in parentheses | ||
|
||
fn main() {} |
11 changes: 11 additions & 0 deletions
11
tests/ui/parser/issues/issue-108109-fn-trait-missing-paren.stderr
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 @@ | ||
error: expected one of `(`, `+`, `,`, `::`, `<`, or `{`, found `->` | ||
--> $DIR/issue-108109-fn-trait-missing-paren.rs:3:34 | ||
| | ||
LL | pub fn func<F>() where F: FnOnce -> () {} | ||
| -------^^ expected one of `(`, `+`, `,`, `::`, `<`, or `{` | ||
| | | | ||
| | help: try adding parentheses | ||
| `Fn` bounds require arguments in parentheses | ||
|
||
error: aborting due to previous error | ||
|