]> git.lizzy.rs Git - rust.git/commitdiff
fix warnings with cfg(miri)
authorRalf Jung <post@ralfj.de>
Sat, 7 Dec 2019 11:47:18 +0000 (12:47 +0100)
committerRalf Jung <post@ralfj.de>
Sat, 7 Dec 2019 11:47:18 +0000 (12:47 +0100)
src/libcore/tests/hash/mod.rs
src/libcore/tests/num/dec2flt/mod.rs

index 1000088e6b0633c5489e9eeee91c4e2af1c1a289..cdd850d3561a23047dfb3429037ba9426de34906 100644 (file)
@@ -70,14 +70,16 @@ fn hash<T: 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);
 }
 
index 361758f859e2e03afdd7f3939f4520077abf81f7..2a309c538b05a659b60ff3e1f3155873918d4612 100644 (file)
@@ -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);
 }