summaryrefslogtreecommitdiffstats
path: root/src/test/ui/consts/ptr_comparisons.rs
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--src/test/ui/consts/ptr_comparisons.rs30
1 files changed, 10 insertions, 20 deletions
diff --git a/src/test/ui/consts/ptr_comparisons.rs b/src/test/ui/consts/ptr_comparisons.rs
index 20233db09..f442e6138 100644
--- a/src/test/ui/consts/ptr_comparisons.rs
+++ b/src/test/ui/consts/ptr_comparisons.rs
@@ -14,38 +14,30 @@ const FOO: &usize = &42;
macro_rules! check {
(eq, $a:expr, $b:expr) => {
pub const _: () =
- assert!(std::intrinsics::ptr_guaranteed_eq($a as *const u8, $b as *const u8));
+ assert!(std::intrinsics::ptr_guaranteed_cmp($a as *const u8, $b as *const u8) == 1);
};
(ne, $a:expr, $b:expr) => {
pub const _: () =
- assert!(std::intrinsics::ptr_guaranteed_ne($a as *const u8, $b as *const u8));
+ assert!(std::intrinsics::ptr_guaranteed_cmp($a as *const u8, $b as *const u8) == 0);
};
- (!eq, $a:expr, $b:expr) => {
+ (!, $a:expr, $b:expr) => {
pub const _: () =
- assert!(!std::intrinsics::ptr_guaranteed_eq($a as *const u8, $b as *const u8));
- };
- (!ne, $a:expr, $b:expr) => {
- pub const _: () =
- assert!(!std::intrinsics::ptr_guaranteed_ne($a as *const u8, $b as *const u8));
+ assert!(std::intrinsics::ptr_guaranteed_cmp($a as *const u8, $b as *const u8) == 2);
};
}
check!(eq, 0, 0);
check!(ne, 0, 1);
-check!(!eq, 0, 1);
-check!(!ne, 0, 0);
check!(ne, FOO as *const _, 0);
-check!(!eq, FOO as *const _, 0);
+check!(ne, unsafe { (FOO as *const usize).offset(1) }, 0);
+check!(ne, unsafe { (FOO as *const usize as *const u8).offset(3) }, 0);
+
// We want pointers to be equal to themselves, but aren't checking this yet because
// there are some open questions (e.g. whether function pointers to the same function
// compare equal, they don't necessarily at runtime).
// The case tested here should work eventually, but does not work yet.
-check!(!eq, FOO as *const _, FOO as *const _);
-check!(ne, unsafe { (FOO as *const usize).offset(1) }, 0);
-check!(!eq, unsafe { (FOO as *const usize).offset(1) }, 0);
+check!(!, FOO as *const _, FOO as *const _);
-check!(ne, unsafe { (FOO as *const usize as *const u8).offset(3) }, 0);
-check!(!eq, unsafe { (FOO as *const usize as *const u8).offset(3) }, 0);
///////////////////////////////////////////////////////////////////////////////
// If any of the below start compiling, make sure to add a `check` test for it.
@@ -63,11 +55,9 @@ const _: *const u8 =
//~| out-of-bounds
const _: usize = unsafe { std::mem::transmute::<*const usize, usize>(FOO) + 4 };
-//~^ ERROR any use of this value will cause an error
+//~^ ERROR evaluation of constant value failed
//~| unable to turn pointer into raw bytes
-//~| WARN this was previously accepted by the compiler but is being phased out
const _: usize = unsafe { *std::mem::transmute::<&&usize, &usize>(&FOO) + 4 };
-//~^ ERROR any use of this value will cause an error
+//~^ ERROR evaluation of constant value failed
//~| unable to turn pointer into raw bytes
-//~| WARN this was previously accepted by the compiler but is being phased out