-
Notifications
You must be signed in to change notification settings - Fork 12.8k
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
Recover from Foo(a: 1, b: 2)
#88729
Conversation
Detect likely `struct` literal using parentheses as delimiters and emit targeted suggestion instead of type ascription parse error. Fix rust-lang#61326.
r? @oli-obk (rust-highfive has picked a reviewer for you, use r? to override) |
= 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 comment
The reason will be displayed to describe this comment to others. Learn more.
This seems messed up. Shouldn't it be bar { baz: $rest }
?
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.
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
without a suggestion for things in macros now that I think about it 🤔
self.mk_expr(lo.to(self.prev_token.span), self.mk_call(fun, args), AttrVec::new()) | ||
}); | ||
match (seq.as_mut(), snapshot) { |
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 :)
@bors r=oli-obk |
📌 Commit ffc623a has been approved by |
…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.
…arth Rollup of 10 pull requests Successful merges: - rust-lang#88292 (Enable --generate-link-to-definition for rustc's docs) - rust-lang#88729 (Recover from `Foo(a: 1, b: 2)`) - rust-lang#88875 (cleanup(rustc_trait_selection): remove vestigial code from rustc_on_unimplemented) - rust-lang#88892 (Move object safety suggestions to the end of the error) - rust-lang#88928 (Document the closure arguments for `reduce`.) - rust-lang#88976 (Clean up and add doc comments for CStr) - rust-lang#88983 (Allow calling `get_body_with_borrowck_facts` without `-Z polonius`) - rust-lang#88985 (Update clobber_abi list to include k[1-7] regs) - rust-lang#88986 (Update the backtrace crate) - rust-lang#89009 (Fix typo in `break` docs) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
Detect likely
struct
literal using parentheses as delimiters and emittargeted suggestion instead of type ascription parse error.
Fix #61326.