forked from rust-lang/rust
-
Notifications
You must be signed in to change notification settings - Fork 1
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#88729 - estebank:struct-literal-using-paren…
…s, r=oli-obk Recover from `Foo(a: 1, b: 2)` Detect likely `struct` literal using parentheses as delimiters and emit targeted suggestion instead of type ascription parse error. Fix rust-lang#61326.
- Loading branch information
Showing
7 changed files
with
133 additions
and
34 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,18 @@ | ||
error: expected type, found `42` | ||
--> $DIR/issue-34255-1.rs:8:24 | ||
error: invalid `struct` delimiters or `fn` call arguments | ||
--> $DIR/issue-34255-1.rs:8:5 | ||
| | ||
LL | Test::Drill(field: 42); | ||
| - ^^ expected type | ||
| | | ||
| tried to parse a type due to this type ascription | ||
| ^^^^^^^^^^^^^^^^^^^^^^ | ||
| | ||
= note: `#![feature(type_ascription)]` lets you annotate an expression with a type: `<expr>: <type>` | ||
= note: see issue #23416 <https://github.com/rust-lang/rust/issues/23416> for more information | ||
help: if `Test::Drill` is a struct, use braces as delimiters | ||
| | ||
LL | Test::Drill { field: 42 }; | ||
| ~ ~ | ||
help: if `Test::Drill` is a function, use the arguments directly | ||
| | ||
LL - Test::Drill(field: 42); | ||
LL + Test::Drill(42); | ||
| | ||
|
||
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,10 +1,10 @@ | ||
macro_rules! foo { | ||
($rest: tt) => { | ||
bar(baz: $rest) | ||
bar(baz: $rest) //~ ERROR invalid `struct` delimiters or `fn` call arguments | ||
} | ||
} | ||
|
||
fn main() { | ||
foo!(true); //~ ERROR expected type, found keyword | ||
foo!(true); | ||
//~^ ERROR expected identifier, found keyword | ||
} |
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