Skip to content

clarify why we're suggesting removing semicolon after braced items #51955

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

Merged
merged 1 commit into from
Jul 8, 2018

Conversation

zackmdavis
Copy link
Member

Previously (issue #46186, pull-request #46258), a suggestion was added
to remove the semicolon after we fail to parse an item, but issue #51603
complains that it's still insufficiently obvious why. Let's add a note.

Resolves #51603.

Previously (issue rust-lang#46186, pull-request rust-lang#46258), a suggestion was added
to remove the semicolon after we fail to parse an item, but issue rust-lang#51603
complains that it's still insufficiently obvious why. Let's add a note.

Resolves rust-lang#51603.
@rust-highfive
Copy link
Contributor

r? @michaelwoerister

(rust_highfive has picked a reviewer for you, use r? to override)

@rust-highfive rust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Jun 30, 2018
@zackmdavis
Copy link
Member Author

r? @oli-obk

_ => None,
};
if let Some(name) = previous_item_kind_name {
err.help(&format!("{} declarations are not followed by a semicolon",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is of course very opinionated, but what do you think about replacing the expected item, found ; message with this message?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm negatively disposed. We're trying to make inferences about the user's state of mind and helpfully remind them how the language works (in contrast to other languages that we think they might be confusing us with). It's a good magical thing to do, but I think it would be overstepping the mandate of the parser to make it the top-line message rather than an ancillary note.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it's a question of numbers. If most ppl add semicolons because they think the definitions need one, then the error should reflect that. Sadly we don't have numbers...

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And the issue was about changing the error message ;)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@oli-obk

I think it's a question of numbers.

While I'm happy to defer to the authority of you or other team members, I don't think numbers are very relevant to the distinction I was trying to draw in my previous comment.

For a perhaps clearer-cut case, consider what we emit when someone tries to destructure a tuple using comma-separated values and no parentheses (e.g., let a, b = (1, 2);). In that case, I think it's appropriate that the top-line error is "unexpected , in pattern", and only the ancillary suggestion suggests adding parentheses: the former message says what went wrong with parsing (there's nothing in the grammar that lets you put a comma there) while being agnostic about what could have motivated someone to write that code, and then, that having been established, we go on to provide a helpful suggestion that maybe you meant to use parentheses. Even if (as seems likely), among people who encounter this error, a solid majority of them geniunely wanted a tuple-unpacking and didn't think parens were necessary, and only a tiny minority just happened to have their fingers slip and insert a comma for no reason, it still makes sense to have both messages in that order, because they're serving different functions: flagging the parsing error is distinct from pointing out what misunderstanding of the language might have motivated that error, and the former should come first because it's an analytic truth, whereas the latter is fundamentally only a guess, though a very high-probability guess it may be. I think the same phenomenon is going on here.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well we definitely err on the safe side by keeping the "expected,found" error. You're right that it would be a major change to diagnostics and should not be done lightly

@stokhos
Copy link

stokhos commented Jul 6, 2018

Ping from triage @zackmdavis we have heard from you for a while, any progress on this PR?

@zackmdavis
Copy link
Member Author

zackmdavis commented Jul 7, 2018

@stokhos

we have [sic] heard from you for a while

Indeed, a whole four days, one hour, and forty-two minutes elapsed between oli-obk's reply to my last comment, and your ping: what shameful negligence on my part!

(edit: in retrospect, the sarcasm was uncalled-for; I apologize.)

@oli-obk
Copy link
Contributor

oli-obk commented Jul 8, 2018

@bors r+

@bors
Copy link
Collaborator

bors commented Jul 8, 2018

📌 Commit db2f3d7 has been approved by oli-obk

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Jul 8, 2018
@bors
Copy link
Collaborator

bors commented Jul 8, 2018

⌛ Testing commit db2f3d7 with merge 0c0315c...

bors added a commit that referenced this pull request Jul 8, 2018
clarify why we're suggesting removing semicolon after braced items

Previously (issue #46186, pull-request #46258), a suggestion was added
to remove the semicolon after we fail to parse an item, but issue #51603
complains that it's still insufficiently obvious why. Let's add a note.

Resolves #51603.
@bors
Copy link
Collaborator

bors commented Jul 8, 2018

☀️ Test successful - status-appveyor, status-travis
Approved by: oli-obk
Pushing 0c0315c to master...

@bors bors merged commit db2f3d7 into rust-lang:master Jul 8, 2018
@zackmdavis zackmdavis deleted the item_semi branch July 8, 2018 18:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants