Closed
Description
Summary
Neither from_u32
nor from_u32_unchecked
are stably const
, so this in a const
context Clippy should not warn on calling std::mem::transmute::<u32, char>
.
Lint Name
transmute_int_to_char
Reproducer
I tried this code:
const fn foo() -> char {
unsafe { std::mem::transmute(3486) }
}
I saw this happen:
warning: transmute from a `i32` to a `char`
--> src/lib.rs:2:14
|
2 | unsafe { std::mem::transmute(3486) }
| ^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `std::char::from_u32(3486 as u32).unwrap()`
|
= note: `#[warn(clippy::transmute_int_to_char)]` on by default
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#transmute_int_to_char
I expected to see this happen: No error.
Version
rustc 1.58.0 (02072b482 2022-01-11)
binary: rustc
commit-hash: 02072b482a8b5357f7fb5e5637444ae30e423c40
commit-date: 2022-01-11
host: x86_64-unknown-linux-gnu
release: 1.58.0
LLVM version: 13.0.0
Additional Labels
@rustbot label +I-suggestion-causes-error