-
-
Notifications
You must be signed in to change notification settings - Fork 14.2k
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
Given the following code: playground link
pub fn u32_as_char(x: u32) -> char {
(x as u32) as char
}The current output is:
error[[E0604]](https://doc.rust-lang.org/stable/error-index.html#E0604): only `u8` can be cast as `char`, not `u32`
--> src/lib.rs:3:5
|
3 | (x as u32) as char
| ^^^^^^^^^^^^^^^^^^ invalid cast
|
help: try `char::from_u32` instead
--> src/lib.rs:3:5
|
3 | (x as u32) as char
| ^^^^^^^^^^^^^^^^^^
For more information about this error, try `rustc --explain E0604`.
Ideally the output should look like:
error[[E0604]](https://doc.rust-lang.org/stable/error-index.html#E0604): only `u8` can be cast as `char`, not `u32`
--> src/lib.rs:3:5
|
3 | (x as u32) as char
| ^^^^^^^^^^^^^^^^^^ invalid cast
|
help: try `char::from_u32` instead
--> src/lib.rs:3:5
|
3 | char::from_u32(x as u32)
| ^^^^^^^^^^^^^^^^^^^^^^^^
For more information about this error, try `rustc --explain E0604`.
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.