-
Notifications
You must be signed in to change notification settings - Fork 12.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Improve diagnostics for parenthesized type arguments
- Loading branch information
Showing
7 changed files
with
123 additions
and
1 deletion.
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
14 changes: 14 additions & 0 deletions
14
tests/ui/parser/issues/diagnostics-parenthesized-type-arguments-issue-120892-1.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,14 @@ | ||
fn main() { | ||
foo::( //~ HELP: consider removing `::` | ||
//~^ NOTE: while parsing this list of parenthesized type arguments starting here | ||
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 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/issue-120892-1.rs:11:9 | ||
| | ||
LL | foo::( | ||
| --- while parsing this list of parenthesized type arguments starting here | ||
... | ||
LL | baz("test"), | ||
| ^^^^^^ expected type | ||
| | ||
help: consider removing `::` | ||
| | ||
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 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::(123, "foo") -> (u32); //~ ERROR: expected type, found `123` | ||
//~^ NOTE: while parsing this list of parenthesized type arguments starting here | ||
//~^^ 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 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/issue-120892-2.rs:2:9 | ||
| | ||
LL | foo::(123, "foo") -> (u32); | ||
| ---^^^ expected type | ||
| | | ||
| while parsing this list of parenthesized 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 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 `::` | ||
//~^ NOTE: while parsing this list of parenthesized type arguments starting here | ||
//~^^ 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 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/issue-120892-3.rs:5:19 | ||
| | ||
LL | Foo::(1, 2) => {}, | ||
| ---^ expected type | ||
| | | ||
| while parsing this list of parenthesized type arguments starting here | ||
| | ||
help: consider removing `::` | ||
| | ||
LL - Foo::(1, 2) => {}, | ||
LL + Foo(1, 2) => {}, | ||
| | ||
|
||
error: aborting due to 1 previous error | ||
|