-
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 lintsA-suggestion-diagnosticsArea: Suggestions generated by the compiler applied by `cargo fix`Area: Suggestions generated by the compiler applied by `cargo fix`C-enhancementCategory: An issue proposing an enhancement or a PR with one.Category: An issue proposing an enhancement or a PR with one.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
Given
fn foo() -> i32 {
let s: i32 = 3usize;
s
}
we present
error[E0308]: mismatched types
--> src/lib.rs:2:18
|
2 | let s: i32 = 3usize;
| ^^^^^^ expected i32, found usize
help: change the type of the numeric literal from `usize` to `i32`
|
2 | let s: i32 = 3i32;
| ^^^^
We would ideally also point at the assignment's type in the same way we do for type mismatches against a return type:
error[E0308]: mismatched types
--> src/lib.rs:2:18
|
2 | let s: i32 = 3usize;
| --- ^^^^^^ expected i32, found usize
| |
| expected due to this
help: change the type of the numeric literal from `usize` to `i32`
|
2 | let s: i32 = 3i32;
| ^^^^
Metadata
Metadata
Assignees
Labels
A-diagnosticsArea: Messages for errors, warnings, and lintsArea: Messages for errors, warnings, and lintsA-suggestion-diagnosticsArea: Suggestions generated by the compiler applied by `cargo fix`Area: Suggestions generated by the compiler applied by `cargo fix`C-enhancementCategory: An issue proposing an enhancement or a PR with one.Category: An issue proposing an enhancement or a PR with one.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.