diff --git a/compiler/rustc_mir_transform/src/check_unnecessary_transmutes.rs b/compiler/rustc_mir_transform/src/check_unnecessary_transmutes.rs index 4aff127908eec..5b324cdbf911a 100644 --- a/compiler/rustc_mir_transform/src/check_unnecessary_transmutes.rs +++ b/compiler/rustc_mir_transform/src/check_unnecessary_transmutes.rs @@ -71,8 +71,6 @@ impl<'a, 'tcx> UnnecessaryTransmuteChecker<'a, 'tcx> { (Uint(_), Float(ty)) => err(format!("{}::from_bits({arg})", ty.name_str())), // bool → { x8 } (Bool, Int(..) | Uint(..)) => err(format!("({arg}) as {}", fn_sig.output())), - // u8 → bool - (Uint(_), Bool) => err(format!("({arg} == 1)")), _ => return None, }) } diff --git a/tests/ui/transmute/unnecessary-transmutation.fixed b/tests/ui/transmute/unnecessary-transmutation.fixed index 1a0df143cc5ff..c368dacae164c 100644 --- a/tests/ui/transmute/unnecessary-transmutation.fixed +++ b/tests/ui/transmute/unnecessary-transmutation.fixed @@ -72,13 +72,13 @@ fn main() { let y: u64 = f64::to_bits(2.0); //~^ ERROR - let z: bool = (1u8 == 1); - //~^ ERROR + let z: bool = transmute(1u8); + // clippy let z: u8 = (z) as u8; //~^ ERROR let z: bool = transmute(1i8); - // no error! + // clippy let z: i8 = (z) as i8; //~^ ERROR } diff --git a/tests/ui/transmute/unnecessary-transmutation.rs b/tests/ui/transmute/unnecessary-transmutation.rs index 6b979263c56ca..e5771948dcf77 100644 --- a/tests/ui/transmute/unnecessary-transmutation.rs +++ b/tests/ui/transmute/unnecessary-transmutation.rs @@ -73,12 +73,12 @@ fn main() { //~^ ERROR let z: bool = transmute(1u8); - //~^ ERROR + // clippy let z: u8 = transmute(z); //~^ ERROR let z: bool = transmute(1i8); - // no error! + // clippy let z: i8 = transmute(z); //~^ ERROR } diff --git a/tests/ui/transmute/unnecessary-transmutation.stderr b/tests/ui/transmute/unnecessary-transmutation.stderr index b661aa13c985d..471d6f8a81f7c 100644 --- a/tests/ui/transmute/unnecessary-transmutation.stderr +++ b/tests/ui/transmute/unnecessary-transmutation.stderr @@ -213,12 +213,6 @@ error: unnecessary transmute LL | let y: u64 = transmute(2.0); | ^^^^^^^^^^^^^^ help: replace this with: `f64::to_bits(2.0)` -error: unnecessary transmute - --> $DIR/unnecessary-transmutation.rs:75:23 - | -LL | let z: bool = transmute(1u8); - | ^^^^^^^^^^^^^^ help: replace this with: `(1u8 == 1)` - error: unnecessary transmute --> $DIR/unnecessary-transmutation.rs:77:21 | @@ -231,5 +225,5 @@ error: unnecessary transmute LL | let z: i8 = transmute(z); | ^^^^^^^^^^^^ help: replace this with: `(z) as i8` -error: aborting due to 32 previous errors +error: aborting due to 31 previous errors