-
Notifications
You must be signed in to change notification settings - Fork 12.9k
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
Detect blocks that could be struct expr bodies #75470
Conversation
r? @davidtwco (rust_highfive has picked a reviewer for you, use r? to override) |
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.
Looks good, a couple comments.
☔ The latest upstream changes (presumably #75120) made this pull request unmergeable. Please resolve the merge conflicts. |
25a849f
to
8460f0d
Compare
Nevermind, looks like you already did that. |
@bors r+ |
📌 Commit 8460f0dbe73123036813fbe036c9d5b2e2ac3fcd has been approved by |
⌛ Testing commit 8460f0dbe73123036813fbe036c9d5b2e2ac3fcd with merge 5d754460711212fc385e4c257697dc8d85354356... |
💔 Test failed - checks-azure |
☔ The latest upstream changes (presumably #76171) made this pull request unmergeable. Please resolve the merge conflicts. Note that reviewers usually do not review pull requests until merge conflicts are resolved! Once you resolve the conflicts, you should change the labels applied by bors to indicate that your PR is ready for review. Post this as a comment to change the labels:
|
@estebank Can you fix the merge conflicts? |
This approach lives exclusively in the parser, so struct expr bodies that are syntactically correct on their own but are otherwise incorrect will still emit confusing errors, like in the following case: ```rust fn foo() -> Foo { bar: Vec::new() } ``` ``` error[E0425]: cannot find value `bar` in this scope --> src/file.rs:5:5 | 5 | bar: Vec::new() | ^^^ expecting a type here because of type ascription error[E0214]: parenthesized type parameters may only be used with a `Fn` trait --> src/file.rs:5:15 | 5 | bar: Vec::new() | ^^^^^ only `Fn` traits may use parentheses error[E0107]: wrong number of type arguments: expected 1, found 0 --> src/file.rs:5:10 | 5 | bar: Vec::new() | ^^^^^^^^^^ expected 1 type argument ``` If that field had a trailing comma, that would be a parse error and it would trigger the new, more targetted, error: ``` error: struct literal body without path --> file.rs:4:17 | 4 | fn foo() -> Foo { | _________________^ 5 | | bar: Vec::new(), 6 | | } | |_^ | help: you might have forgotten to add the struct literal inside the block | 4 | fn foo() -> Foo { Path { 5 | bar: Vec::new(), 6 | } } | ``` Partially address last part of rust-lang#34255.
8460f0d
to
e5f83bc
Compare
@bors r=davidtwco |
📌 Commit e5f83bc has been approved by |
☀️ Test successful - checks-actions, checks-azure |
This approach lives exclusively in the parser, so struct expr bodies
that are syntactically correct on their own but are otherwise incorrect
will still emit confusing errors, like in the following case:
If that field had a trailing comma, that would be a parse error and it
would trigger the new, more targetted, error:
Partially address last remaining part of #34255.