From ab73d10a6ea034892d38fa8203954764c7e9df55 Mon Sep 17 00:00:00 2001 From: Ralf Jung Date: Sat, 7 Dec 2019 12:47:18 +0100 Subject: [PATCH] fix warnings with cfg(miri) --- src/libcore/tests/hash/mod.rs | 6 ++++-- src/libcore/tests/num/dec2flt/mod.rs | 13 ++++++++++--- 2 files changed, 14 insertions(+), 5 deletions(-) diff --git a/src/libcore/tests/hash/mod.rs b/src/libcore/tests/hash/mod.rs index 1000088e6b0..cdd850d3561 100644 --- a/src/libcore/tests/hash/mod.rs +++ b/src/libcore/tests/hash/mod.rs @@ -70,14 +70,16 @@ fn hash(t: &T) -> u64 { let ptr = 5_usize as *mut i32; assert_eq!(hash(&ptr), 5); + if cfg!(miri) { // Miri cannot hash pointers + return; + } + let cs: &mut [u8] = &mut [1, 2, 3]; let ptr = cs.as_ptr(); let slice_ptr = cs as *const [u8]; - #[cfg(not(miri))] // Miri cannot hash pointers assert_eq!(hash(&slice_ptr), hash(&ptr) + cs.len() as u64); let slice_ptr = cs as *mut [u8]; - #[cfg(not(miri))] // Miri cannot hash pointers assert_eq!(hash(&slice_ptr), hash(&ptr) + cs.len() as u64); } diff --git a/src/libcore/tests/num/dec2flt/mod.rs b/src/libcore/tests/num/dec2flt/mod.rs index 361758f859e..2a309c538b0 100644 --- a/src/libcore/tests/num/dec2flt/mod.rs +++ b/src/libcore/tests/num/dec2flt/mod.rs @@ -31,7 +31,11 @@ fn ordinary() { test_literal!(0.1); test_literal!(12345.); test_literal!(0.9999999); - #[cfg(not(miri))] // Miri is too slow + + if cfg!(miri) { // Miri is too slow + return; + } + test_literal!(2.2250738585072014e-308); } @@ -77,9 +81,12 @@ fn infinity() { fn zero() { test_literal!(0.0); test_literal!(1e-325); - #[cfg(not(miri))] // Miri is too slow + + if cfg!(miri) { // Miri is too slow + return; + } + test_literal!(1e-326); - #[cfg(not(miri))] // Miri is too slow test_literal!(1e-500); } -- 2.44.0