about summary refs log tree commit diff
path: root/src/tools
diff options
context:
space:
mode:
authorTrevor Gross <t.gross35@gmail.com>2025-02-23 14:30:28 -0500
committerGitHub <noreply@github.com>2025-02-23 14:30:28 -0500
commit18ffee2126f71fe15a677d718bd27c501b0ccf52 (patch)
treefe3e70c924cb7571769b4e45d4a8e8f89d46a888 /src/tools
parente8342e7d42bf789b6d69caaeafd547f6e7deadc2 (diff)
parentc813d8f3e49aa4c85c9eded426b6507701a2ff94 (diff)
Rollup merge of #137483 - bend-n:😅, r=Noratrieb
rename sub_ptr to offset_from_unsigned

i also made `byte_sub_ptr` `byte_offset_from_unsigned`

fixes #137121
tracking issue #95892
Diffstat (limited to 'src/tools')
-rw-r--r--src/tools/miri/tests/fail/intrinsics/ptr_offset_from_unsigned_neg.rs2
-rw-r--r--src/tools/miri/tests/fail/intrinsics/ptr_offset_from_unsigned_neg.stderr4
-rw-r--r--src/tools/miri/tests/pass/ptr_offset.rs6
3 files changed, 6 insertions, 6 deletions
diff --git a/src/tools/miri/tests/fail/intrinsics/ptr_offset_from_unsigned_neg.rs b/src/tools/miri/tests/fail/intrinsics/ptr_offset_from_unsigned_neg.rs
index 13874398f7b..562d72b0ca0 100644
--- a/src/tools/miri/tests/fail/intrinsics/ptr_offset_from_unsigned_neg.rs
+++ b/src/tools/miri/tests/fail/intrinsics/ptr_offset_from_unsigned_neg.rs
@@ -3,5 +3,5 @@ fn main() {
     let arr = [0u8; 8];
     let ptr1 = arr.as_ptr();
     let ptr2 = ptr1.wrapping_add(4);
-    let _val = unsafe { ptr1.sub_ptr(ptr2) }; //~ERROR: first pointer has smaller address than second
+    let _val = unsafe { ptr1.offset_from_unsigned(ptr2) }; //~ERROR: first pointer has smaller address than second
 }
diff --git a/src/tools/miri/tests/fail/intrinsics/ptr_offset_from_unsigned_neg.stderr b/src/tools/miri/tests/fail/intrinsics/ptr_offset_from_unsigned_neg.stderr
index a0a8e97e7fa..80e3f2c22a1 100644
--- a/src/tools/miri/tests/fail/intrinsics/ptr_offset_from_unsigned_neg.stderr
+++ b/src/tools/miri/tests/fail/intrinsics/ptr_offset_from_unsigned_neg.stderr
@@ -1,8 +1,8 @@
 error: Undefined Behavior: `ptr_offset_from_unsigned` called when first pointer has smaller address than second: $ADDR < $ADDR
   --> tests/fail/intrinsics/ptr_offset_from_unsigned_neg.rs:LL:CC
    |
-LL |     let _val = unsafe { ptr1.sub_ptr(ptr2) };
-   |                         ^^^^^^^^^^^^^^^^^^ `ptr_offset_from_unsigned` called when first pointer has smaller address than second: $ADDR < $ADDR
+LL |     let _val = unsafe { ptr1.offset_from_unsigned(ptr2) };
+   |                         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `ptr_offset_from_unsigned` called when first pointer has smaller address than second: $ADDR < $ADDR
    |
    = help: this indicates a bug in the program: it performed an invalid operation, and caused Undefined Behavior
    = help: see https://doc.rust-lang.org/nightly/reference/behavior-considered-undefined.html for further information
diff --git a/src/tools/miri/tests/pass/ptr_offset.rs b/src/tools/miri/tests/pass/ptr_offset.rs
index a8a0d2836e7..89aff7bf635 100644
--- a/src/tools/miri/tests/pass/ptr_offset.rs
+++ b/src/tools/miri/tests/pass/ptr_offset.rs
@@ -21,7 +21,7 @@ fn smoke() {
     let _val = ptr.wrapping_sub(0);
     let _val = unsafe { ptr.sub(0) };
     let _val = unsafe { ptr.offset_from(ptr) };
-    let _val = unsafe { ptr.sub_ptr(ptr) };
+    let _val = unsafe { ptr.offset_from_unsigned(ptr) };
 }
 
 fn test_offset_from() {
@@ -32,14 +32,14 @@ fn test_offset_from() {
         let y = x.offset(12);
 
         assert_eq!(y.offset_from(x), 12);
-        assert_eq!(y.sub_ptr(x), 12);
+        assert_eq!(y.offset_from_unsigned(x), 12);
         assert_eq!(x.offset_from(y), -12);
         assert_eq!((y as *const u32).offset_from(x as *const u32), 12 / 4);
         assert_eq!((x as *const u32).offset_from(y as *const u32), -12 / 4);
 
         let x = (((x as usize) * 2) / 2) as *const u8;
         assert_eq!(y.offset_from(x), 12);
-        assert_eq!(y.sub_ptr(x), 12);
+        assert_eq!(y.offset_from_unsigned(x), 12);
         assert_eq!(x.offset_from(y), -12);
     }
 }