-
Notifications
You must be signed in to change notification settings - Fork 13.6k
Closed
Labels
A-diagnosticsArea: Messages for errors, warnings, and lintsArea: Messages for errors, warnings, and lintsT-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.
Description
Talking to some folks at RustConf recently a common point of confusion seemed to be "where are semicolons required?" The compiler seemingly has arcane restrictions at the beginning and this means that we can perhaps improve errors in this respect to help guide beginners!
For example, in this code:
pub fn foo() {
if true {
3
} else {
foo();
}
}
it yields the error:
error[E0308]: mismatched types
--> foo.rs:3:9
|
3 | 3
| ^ expected (), found integral variable
|
= note: expected type `()`
= note: found type `{integer}`
error: aborting due to previous error
Perhaps we could detect that the other branch of the if
has a semicolon, and as a result a semicolon here is probably also the fix?
Metadata
Metadata
Assignees
Labels
A-diagnosticsArea: Messages for errors, warnings, and lintsArea: Messages for errors, warnings, and lintsT-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.
Type
Projects
Milestone
Relationships
Development
Select code repository
Activity
estebank commentedon Sep 13, 2016
I believe PR #36409 would handle this case.
Mark-Simulacrum commentedon Jun 4, 2017
Closing as a duplicate of #41897.