-
Notifications
You must be signed in to change notification settings - Fork 13.3k
Recover from Foo(a: 1, b: 2)
#88729
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
Recover from Foo(a: 1, b: 2)
#88729
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
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 | ||
|
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 | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,17 +9,25 @@ help: you can escape reserved keywords to use them as identifiers | |
LL | foo!(r#true); | ||
| ~~~~~~ | ||
|
||
error: expected type, found keyword `true` | ||
--> $DIR/issue-44406.rs:8:10 | ||
error: invalid `struct` delimiters or `fn` call arguments | ||
--> $DIR/issue-44406.rs:3:9 | ||
| | ||
LL | bar(baz: $rest) | ||
| - help: try using a semicolon: `;` | ||
| ^^^^^^^^^^^^^^^ | ||
... | ||
LL | foo!(true); | ||
| ^^^^ expected type | ||
| ----------- in this macro invocation | ||
| | ||
= note: this error originates in the macro `foo` (in Nightly builds, run with -Z macro-backtrace for more info) | ||
help: if `bar` is a struct, use braces as delimiters | ||
| | ||
LL | bar { } | ||
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. This seems messed up. Shouldn't it be 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. This is indeed "not correct", caused by the macro context of the spans involved. I could never show the suggestions if a macro is involved, but that would hide the suggestion even if the macro isn't mixing fragments coming from the caller with internal spans. Then again a middle point would be to give just a |
||
| ~ | ||
help: if `bar` is a function, use the arguments directly | ||
| | ||
= 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 | ||
LL - bar(baz: $rest) | ||
LL + bar(true); | ||
| | ||
|
||
error: aborting due to 2 previous errors | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please pull this out of the happy path into a separate function
r=me with that done
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
very rude of you to make me fix this while Mara is speaking :)