diff options
Diffstat (limited to 'src/test/ui/consts/ptr_comparisons.rs')
-rw-r--r-- | src/test/ui/consts/ptr_comparisons.rs | 24 |
1 files changed, 8 insertions, 16 deletions
diff --git a/src/test/ui/consts/ptr_comparisons.rs b/src/test/ui/consts/ptr_comparisons.rs index 20233db09..0a3c2d4be 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. |