diff --git a/src/operator.rs b/src/operator.rs index 58003331e637..ed69c8043939 100644 --- a/src/operator.rs +++ b/src/operator.rs @@ -13,7 +13,6 @@ bytes_to_f64, f32_to_bytes, f64_to_bytes, - bytes_to_bool, }; impl<'a, 'tcx> EvalContext<'a, 'tcx> { @@ -334,7 +333,7 @@ pub fn unary_op<'tcx>( let bytes = val.to_bytes()?; let result_bytes = match (un_op, val_kind) { - (Not, Bool) => !bytes_to_bool(bytes) as u128, + (Not, Bool) => !val.to_bool()? as u128, (Not, U8) => !(bytes as u8) as u128, (Not, U16) => !(bytes as u16) as u128, diff --git a/src/value.rs b/src/value.rs index 99630f6006f8..9f7d3eafe1fb 100644 --- a/src/value.rs +++ b/src/value.rs @@ -23,12 +23,6 @@ pub(super) fn f64_to_bytes(f: f64) -> u128 { unsafe { transmute::(f) as u128 } } -pub(super) fn bytes_to_bool(n: u128) -> bool { - // FIXME(solson): Can we reach here due to user error? - assert!(n == 0 || n == 1, "bytes interpreted as bool were {}", n); - n & 1 == 1 -} - /// A `Value` represents a single self-contained Rust value. /// /// A `Value` can either refer to a block of memory inside an allocation (`ByRef`) or to a primitve