-
Notifications
You must be signed in to change notification settings - Fork 13.4k
Improve diagnostics for parenthesized type arguments #122152
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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
14 changes: 14 additions & 0 deletions
14
tests/ui/parser/issues/diagnostics-parenthesized-type-arguments-issue-120892-1.rs
This file contains hidden or 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 @@ | ||
fn main() { | ||
foo::( //~ HELP: consider removing the `::` here to call the expression | ||
//~^ NOTE: while parsing this parenthesized list of type arguments starting | ||
bar(x, y, z), | ||
bar(x, y, z), | ||
bar(x, y, z), | ||
bar(x, y, z), | ||
bar(x, y, z), | ||
bar(x, y, z), | ||
bar(x, y, z), | ||
baz("test"), //~ ERROR: expected type, found `"test"` | ||
//~^ NOTE: expected type | ||
) | ||
} |
17 changes: 17 additions & 0 deletions
17
tests/ui/parser/issues/diagnostics-parenthesized-type-arguments-issue-120892-1.stderr
This file contains hidden or 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,17 @@ | ||
error: expected type, found `"test"` | ||
--> $DIR/diagnostics-parenthesized-type-arguments-issue-120892-1.rs:11:9 | ||
| | ||
LL | foo::( | ||
| --- while parsing this parenthesized list of type arguments starting here | ||
... | ||
LL | baz("test"), | ||
| ^^^^^^ expected type | ||
| | ||
help: consider removing the `::` here to call the expression | ||
| | ||
LL - foo::( | ||
LL + foo( | ||
| | ||
|
||
error: aborting due to 1 previous error | ||
|
5 changes: 5 additions & 0 deletions
5
tests/ui/parser/issues/diagnostics-parenthesized-type-arguments-issue-120892-2.rs
This file contains hidden or 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 main() { | ||
foo::/* definitely not harmful comment */(123, "foo") -> (u32); //~ ERROR: expected type, found `123` | ||
//~^ NOTE: while parsing this parenthesized list of type arguments starting | ||
//~^^ NOTE: expected type | ||
} |
10 changes: 10 additions & 0 deletions
10
tests/ui/parser/issues/diagnostics-parenthesized-type-arguments-issue-120892-2.stderr
This file contains hidden or 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,10 @@ | ||
error: expected type, found `123` | ||
--> $DIR/diagnostics-parenthesized-type-arguments-issue-120892-2.rs:2:45 | ||
| | ||
LL | foo::/* definitely not harmful comment */(123, "foo") -> (u32); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 😆 |
||
| ---------------------------------------^^^ expected type | ||
| | | ||
| while parsing this parenthesized list of type arguments starting here | ||
|
||
error: aborting due to 1 previous error | ||
|
14 changes: 14 additions & 0 deletions
14
tests/ui/parser/issues/diagnostics-parenthesized-type-arguments-issue-120892-3.rs
This file contains hidden or 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 @@ | ||
struct Foo(u32, u32); | ||
impl Foo { | ||
fn foo(&self) { | ||
match *self { | ||
Foo::(1, 2) => {}, //~ HELP: consider removing the `::` here to turn this into a tuple struct pattern | ||
//~^ NOTE: while parsing this parenthesized list of type arguments starting | ||
//~^^ ERROR: expected type, found `1` | ||
//~^^^ NOTE: expected type | ||
_ => {}, | ||
} | ||
} | ||
} | ||
|
||
fn main() {} |
16 changes: 16 additions & 0 deletions
16
tests/ui/parser/issues/diagnostics-parenthesized-type-arguments-issue-120892-3.stderr
This file contains hidden or 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,16 @@ | ||
error: expected type, found `1` | ||
--> $DIR/diagnostics-parenthesized-type-arguments-issue-120892-3.rs:5:19 | ||
| | ||
LL | Foo::(1, 2) => {}, | ||
| ---^ expected type | ||
| | | ||
| while parsing this parenthesized list of type arguments starting here | ||
| | ||
help: consider removing the `::` here to turn this into a tuple struct pattern | ||
| | ||
LL - Foo::(1, 2) => {}, | ||
LL + Foo(1, 2) => {}, | ||
| | ||
|
||
error: aborting due to 1 previous error | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.