- 
                Notifications
    You must be signed in to change notification settings 
- Fork 13.9k
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
Code
fn main() {
    let x: u8 = (4i32);
}Current output
error[E0308]: mismatched types
 --> src/main.rs:2:17
  |
2 |     let x: u8 = (4i32);
  |            --   ^^^^^^ expected `u8`, found `i32`
  |            |
  |            expected due to this
  |
help: change the type of the numeric literal from `i32` to `u8`
  |
2 |     let x: u8 = (4i32)u8;
  |                       ++Desired output
error[E0308]: mismatched types
 --> src/main.rs:2:17
  |
2 |     let x: u8 = (4i32);
  |            --   ^^^^^^ expected `u8`, found `i32`
  |            |
  |            expected due to this
  |
help: change the type of the numeric literal from `i32` to `u8`
  |
2 |     let x: u8 = 4u8;
  |Rationale and extra context
No response
Other cases
Rust Version
1.87.0-nightly
(2025-03-11 6650252439d4e03368b3)Anything else?
No response
moxian
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.