mirror of
https://github.com/rust-lang/rust.git
synced 2026-06-02 06:28:20 +03:00
use PrimVal::to_bool rather than bytes_to_bool
This commit is contained in:
+1
-2
@@ -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,
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user