Conversation
|
r? @wesleywiser rustbot has assigned @wesleywiser. Use |
SparrowLii
left a comment
There was a problem hiding this comment.
I don't think this PR solves #101622 :(
| .dcx() | ||
| .struct_span_err(self.token.span, format!("expected item, found {token_str}")); | ||
|
|
||
| match self.parse_full_stmt(AttemptLocalParseRecovery::No) { |
There was a problem hiding this comment.
We'd be better doing more analysis to figure out what went wrong here, rather than treating them all as statements. For example, whether it contains ; in [] can be used to distinguish whether it is an attribute or an array.
There was a problem hiding this comment.
I gave up on trying to detect kinds of expressions as it's very unreliable.
It addresses the main point raised in the issue, right? |
9a129e5 to
06a1ccf
Compare
|
@rustbot ready |
|
☔ The latest upstream changes (presumably #126049) made this pull request unmergeable. Please resolve the merge conflicts. |
06a1ccf to
1d326d5
Compare
This comment has been minimized.
This comment has been minimized.
|
@rustbot author |
3f2ccd7 to
b9ddf53
Compare
b9ddf53 to
c66b446
Compare
This comment has been minimized.
This comment has been minimized.
|
☔ The latest upstream changes (presumably #127906) made this pull request unmergeable. Please resolve the merge conflicts. |
|
@dev-ardi |
|
It was left unreviewed for a while so it became full of conflicts. I intend to finish it at some point though... |
57d1590 to
faf1c5f
Compare
|
@rustbot ready |
This comment has been minimized.
This comment has been minimized.
faf1c5f to
b40be9d
Compare
|
r? @SparrowLii (but feel free to roll the review assignment to someone else) |
|
r? diagnostics |
|
r? diagnostics |
| "Should have been handled by maybe_consume_incorrect_semicolon" | ||
| ); | ||
| } | ||
| StmtKind::Item(_) | StmtKind::MacCall(_) => { |
There was a problem hiding this comment.
Item should be unreachable, right?
| } | ||
| StmtKind::Semi(expr) => { | ||
| err.span_label(span, "unexpected expression").help(format!( | ||
| "consider putting it inside a function: fn foo() {{ {}; }}", |
There was a problem hiding this comment.
This diagnostic can potentially become very big. Either use structured suggestions, or do not put a suggestion into the diagnostic message itself.
| @@ -2,8 +2,11 @@ error: expected item, found `[` | |||
| --> $DIR/shebang-doc-comment.rs:2:1 | |||
| | | |||
| LL | [allow(unused_variables)] | |||
There was a problem hiding this comment.
Maybe add a code path for array expressions and suggest adding a # instead?
|
@rustbot author |
|
Reminder, once the PR becomes ready for a review, use |
|
@oriongonza any updates on this? thanks |
|
@oriongonza |
Closes #92615 and closes #101622
Please review the new diagnostics cafefully.
This PR also adds a few more comments to the parser.