forked from rust-lang/rust
-
Notifications
You must be signed in to change notification settings - Fork 6
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#122152 - wutchzone:120892, r=fmease Improve diagnostics for parenthesized type arguments Fixes rust-lang#120892 r? fmease
- Loading branch information
Showing
7 changed files
with
160 additions
and
2 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
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 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 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 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 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); | ||
| ---------------------------------------^^^ 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 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 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 | ||
|