]> git.lizzy.rs Git - rust.git/commitdiff
remove useless ident() functions in const tests and replace the useful ones by black_...
authorRalf Jung <post@ralfj.de>
Sat, 8 Jun 2019 10:30:52 +0000 (12:30 +0200)
committerRalf Jung <post@ralfj.de>
Sat, 8 Jun 2019 10:30:52 +0000 (12:30 +0200)
src/test/run-pass/const-int-conversion.rs
src/test/run-pass/const-int-overflowing.rs
src/test/run-pass/const-int-rotate.rs
src/test/run-pass/const-int-wrapping.rs
src/test/run-pass/consts/const-endianess.rs
src/test/run-pass/consts/const-ptr-nonnull.rs
src/test/run-pass/consts/const-ptr-unique.rs

index 3d3240d434292933365912ac5d50a6fe6857e27e..1d3123d216ebfb53ae63ebe190c6961c5f30c6de 100644 (file)
@@ -8,16 +8,12 @@
 const TO_LE_BYTES: [u8; 4] = 0x12_34_56_78_i32.to_le_bytes();
 const TO_NE_BYTES: [u8; 4] = i32::min_value().to_be().to_ne_bytes();
 
-fn ident<T>(ident: T) -> T {
-    ident
-}
-
 fn main() {
-    assert_eq!(REVERSE, ident(0x1e6a2c48));
-    assert_eq!(FROM_BE_BYTES, ident(0x12_34_56_78));
-    assert_eq!(FROM_LE_BYTES, ident(0x78_56_34_12));
-    assert_eq!(FROM_NE_BYTES, ident(i32::min_value()));
-    assert_eq!(TO_BE_BYTES, ident([0x12, 0x34, 0x56, 0x78]));
-    assert_eq!(TO_LE_BYTES, ident([0x78, 0x56, 0x34, 0x12]));
-    assert_eq!(TO_NE_BYTES, ident([0x80, 0, 0, 0]));
+    assert_eq!(REVERSE, 0x1e6a2c48);
+    assert_eq!(FROM_BE_BYTES, 0x12_34_56_78);
+    assert_eq!(FROM_LE_BYTES, 0x78_56_34_12);
+    assert_eq!(FROM_NE_BYTES, i32::min_value());
+    assert_eq!(TO_BE_BYTES, [0x12, 0x34, 0x56, 0x78]);
+    assert_eq!(TO_LE_BYTES, [0x78, 0x56, 0x34, 0x12]);
+    assert_eq!(TO_NE_BYTES, [0x80, 0, 0, 0]);
 }
index 82057868b73bbad56fb9f05d825c4cddbf1f3d66..9597393df72d27940010170a42fc6edcdbf61584 100644 (file)
 const NEG_A: (u32, bool) = 0u32.overflowing_neg();
 const NEG_B: (u32, bool) = core::u32::MAX.overflowing_neg();
 
-fn ident<T>(ident: T) -> T {
-    ident
-}
-
 fn main() {
-    assert_eq!(ADD_A, ident((7, false)));
-    assert_eq!(ADD_B, ident((0, true)));
+    assert_eq!(ADD_A, (7, false));
+    assert_eq!(ADD_B, (0, true));
 
-    assert_eq!(SUB_A, ident((3, false)));
-    assert_eq!(SUB_B, ident((u32::max_value(), true)));
+    assert_eq!(SUB_A, (3, false));
+    assert_eq!(SUB_B, (u32::max_value(), true));
 
-    assert_eq!(MUL_A, ident((10, false)));
-    assert_eq!(MUL_B, ident((1410065408, true)));
+    assert_eq!(MUL_A, (10, false));
+    assert_eq!(MUL_B, (1410065408, true));
 
-    assert_eq!(SHL_A, ident((0x10, false)));
-    assert_eq!(SHL_B, ident((0x10, true)));
+    assert_eq!(SHL_A, (0x10, false));
+    assert_eq!(SHL_B, (0x10, true));
 
-    assert_eq!(SHR_A, ident((0x1, false)));
-    assert_eq!(SHR_B, ident((0x1, true)));
+    assert_eq!(SHR_A, (0x1, false));
+    assert_eq!(SHR_B, (0x1, true));
 
-    assert_eq!(NEG_A, ident((0, false)));
-    assert_eq!(NEG_B, ident((1, true)));
+    assert_eq!(NEG_A, (0, false));
+    assert_eq!(NEG_B, (1, true));
 }
index 965f317c42466646a119df95c19daabd4e599e18..16946eadd632aeb7c6dd1d652c729ab47b8fd9cc 100644 (file)
 const MULTIPLE_ROTATE_LEFT: i32 = 0b0010_0001i32.rotate_left(128);
 const MULTIPLE_ROTATE_RIGHT: i32 = 0b0010_0001i32.rotate_right(128);
 
-fn ident<T>(ident: T) -> T {
-    ident
-}
-
 fn main() {
-    assert_eq!(LEFT, ident(0xb301));
-    assert_eq!(RIGHT, ident(0x0100_00b3));
+    assert_eq!(LEFT, 0xb301);
+    assert_eq!(RIGHT, 0x0100_00b3);
 
-    assert_eq!(LEFT_OVERFLOW, ident(0));
-    assert_eq!(RIGHT_OVERFLOW, ident(0));
-    assert_eq!(ONE_LEFT_OVERFLOW, ident(0b0001_0000_0000_0000));
-    assert_eq!(ONE_RIGHT_OVERFLOW, ident(0b0001_0000));
+    assert_eq!(LEFT_OVERFLOW, 0);
+    assert_eq!(RIGHT_OVERFLOW, 0);
+    assert_eq!(ONE_LEFT_OVERFLOW, 0b0001_0000_0000_0000);
+    assert_eq!(ONE_RIGHT_OVERFLOW, 0b0001_0000);
 
-    assert_eq!(NON_ZERO_LEFT_OVERFLOW, ident(0b0010_0000_0000_0000));
-    assert_eq!(NON_ZERO_RIGHT_OVERFLOW, ident(0b0000_0000_0010_0000));
+    assert_eq!(NON_ZERO_LEFT_OVERFLOW, 0b0010_0000_0000_0000);
+    assert_eq!(NON_ZERO_RIGHT_OVERFLOW, 0b0000_0000_0010_0000);
 
-    assert_eq!(ZERO_ROTATE_LEFT, ident(0b0010_0001));
-    assert_eq!(ZERO_ROTATE_RIGHT, ident(0b0111_1001));
+    assert_eq!(ZERO_ROTATE_LEFT, 0b0010_0001);
+    assert_eq!(ZERO_ROTATE_RIGHT, 0b0111_1001);
 
-    assert_eq!(MULTIPLE_ROTATE_LEFT, ident(0b0010_0001));
-    assert_eq!(MULTIPLE_ROTATE_RIGHT, ident(0b0010_0001));
+    assert_eq!(MULTIPLE_ROTATE_LEFT, 0b0010_0001);
+    assert_eq!(MULTIPLE_ROTATE_RIGHT, 0b0010_0001);
 }
index 140fd57ecb8026b537b5ad095b34d7a7c402e744..db86c25194f08585d3e6824242a0dd807531461e 100644 (file)
 const NEG_A: u32 = 5u32.wrapping_neg();
 const NEG_B: u32 = 1234567890u32.wrapping_neg();
 
-fn ident<T>(ident: T) -> T {
-    ident
-}
-
 fn main() {
-    assert_eq!(ADD_A, ident(255));
-    assert_eq!(ADD_B, ident(199));
+    assert_eq!(ADD_A, 255);
+    assert_eq!(ADD_B, 199);
 
-    assert_eq!(SUB_A, ident(0));
-    assert_eq!(SUB_B, ident(101));
+    assert_eq!(SUB_A, 0);
+    assert_eq!(SUB_B, 101);
 
-    assert_eq!(MUL_A, ident(120));
-    assert_eq!(MUL_B, ident(44));
+    assert_eq!(MUL_A, 120);
+    assert_eq!(MUL_B, 44);
 
-    assert_eq!(SHL_A, ident(128));
-    assert_eq!(SHL_B, ident(1));
+    assert_eq!(SHL_A, 128);
+    assert_eq!(SHL_B, 1);
 
-    assert_eq!(SHR_A, ident(1));
-    assert_eq!(SHR_B, ident(128));
+    assert_eq!(SHR_A, 1);
+    assert_eq!(SHR_B, 128);
 
-    assert_eq!(NEG_A, ident(4294967291));
-    assert_eq!(NEG_B, ident(3060399406));
+    assert_eq!(NEG_A, 4294967291);
+    assert_eq!(NEG_B, 3060399406);
 }
index cbe6d864c9c3a7eb35be33cb0679a3a2759e9546..936f31954d3dd446b8b000f43def12caf4e93df8 100644 (file)
@@ -2,7 +2,7 @@
 #![feature(test)]
 
 extern crate test;
-use test::black_box as b;
+use test::black_box as b; // prevent promotion of the argument and const-propagation of the result
 
 const BE_U32: u32 = 55u32.to_be();
 const LE_U32: u32 = 55u32.to_le();
index c5b9d837b47a896085dc83fc23e38137388394cd..4cdc8c7942359d02744b7e8d32166966dbc9573d 100644 (file)
@@ -1,15 +1,16 @@
 // run-pass
 
+#![feature(ptr_internals, test)]
+
+extern crate test;
+use test::black_box as b; // prevent promotion of the argument and const-propagation of the result
+
 use std::ptr::NonNull;
 
 const DANGLING: NonNull<u32> = NonNull::dangling();
 const CASTED: NonNull<u32> = NonNull::cast(NonNull::<i32>::dangling());
 
-fn ident<T>(ident: T) -> T {
-    ident
-}
-
 pub fn main() {
-    assert_eq!(DANGLING, ident(NonNull::dangling()));
-    assert_eq!(CASTED, ident(NonNull::dangling()));
+    assert_eq!(DANGLING, b(NonNull::dangling()));
+    assert_eq!(CASTED, b(NonNull::dangling()));
 }
index eb371ab184166491e039136ed2d4ae954be90c8d..b5cc78d4b71885002bc2f6a0532345d87322d819 100644 (file)
@@ -1,15 +1,15 @@
 // run-pass
 
-#![feature(ptr_internals)]
+#![feature(ptr_internals, test)]
+
+extern crate test;
+use test::black_box as b; // prevent promotion of the argument and const-propagation of the result
 
 use std::ptr::Unique;
 
-const PTR: *mut u32 = Unique::empty().as_ptr();
 
-fn ident<T>(ident: T) -> T {
-    ident
-}
+const PTR: *mut u32 = Unique::empty().as_ptr();
 
 pub fn main() {
-    assert_eq!(PTR, ident(Unique::<u32>::empty().as_ptr()));
+    assert_eq!(PTR, b(Unique::<u32>::empty()).as_ptr());
 }