2024-01-25 12:17:36 -06:00
|
|
|
#![warn(clippy::transmute_int_to_char)]
|
2024-04-04 12:52:55 -05:00
|
|
|
#![allow(clippy::missing_transmute_annotations)]
|
2024-01-25 12:17:36 -06:00
|
|
|
|
|
|
|
fn int_to_char() {
|
|
|
|
let _: char = unsafe { std::char::from_u32(0_u32).unwrap() };
|
|
|
|
//~^ ERROR: transmute from a `u32` to a `char`
|
|
|
|
//~| NOTE: `-D clippy::transmute-int-to-char` implied by `-D warnings`
|
|
|
|
let _: char = unsafe { std::char::from_u32(0_i32 as u32).unwrap() };
|
|
|
|
//~^ ERROR: transmute from a `i32` to a `char`
|
|
|
|
|
|
|
|
// These shouldn't warn
|
|
|
|
const _: char = unsafe { std::mem::transmute(0_u32) };
|
|
|
|
const _: char = unsafe { std::mem::transmute(0_i32) };
|
|
|
|
}
|
|
|
|
|
|
|
|
fn main() {}
|