-
Notifications
You must be signed in to change notification settings - Fork 13.5k
Closed
Labels
A-diagnosticsArea: Messages for errors, warnings, and lintsArea: Messages for errors, warnings, and lintsD-incorrectDiagnostics: A diagnostic that is giving misleading or incorrect information.Diagnostics: A diagnostic that is giving misleading or incorrect information.D-papercutDiagnostics: An error or lint that needs small tweaks.Diagnostics: An error or lint that needs small tweaks.T-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
Code
fn main() {
if true {
""
}
}
Current output
error[E0308]: mismatched types
--> src/main.rs:3:9
|
1 | fn main() {
| - expected `()` because of default return type
2 | if true {
3 | ""
| ^^ expected `()`, found `&str`
Desired output
error[E0308]: mismatched types
--> src/main.rs:3:9
|
2 | / if true {
3 | | ""
| | ^^ expected `()`, found `&str`
4 | | }
| |_____- expected this to be `()`
Rationale and extra context
When the if
is not the tail expression, we provide the right output. We might just have to change the order of operation when looking for additional context to print.
Other cases
if true { "" } else { "" }
as tail expression has the same problem.
Rust Version
All checked, current version 1.78.
Metadata
Metadata
Assignees
Labels
A-diagnosticsArea: Messages for errors, warnings, and lintsArea: Messages for errors, warnings, and lintsD-incorrectDiagnostics: A diagnostic that is giving misleading or incorrect information.Diagnostics: A diagnostic that is giving misleading or incorrect information.D-papercutDiagnostics: An error or lint that needs small tweaks.Diagnostics: An error or lint that needs small tweaks.T-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.