use PrimVal::to_bool rather than bytes_to_bool

This commit is contained in:
Ralf Jung
2017-06-22 20:20:26 -07:00
parent 12935b6514
commit d5c031640f
2 changed files with 1 additions and 8 deletions
+1 -2
View File
@@ -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,
-6
View File
@@ -23,12 +23,6 @@ pub(super) fn f64_to_bytes(f: f64) -> u128 {
unsafe { transmute::<f64, u64>(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