Skip to content

Commit 2666041

Browse files
committed
rename ptr::from_exposed_addr -> ptr::with_exposed_provenance
1 parent caa3e75 commit 2666041

14 files changed

+30
-30
lines changed

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -324,7 +324,7 @@ environment variable. We first document the most relevant and most commonly used
324324
number of available CPUs is `1`. Note that this flag does not affect how miri handles threads in
325325
any way.
326326
* `-Zmiri-permissive-provenance` disables the warning for integer-to-pointer casts and
327-
[`ptr::from_exposed_addr`](https://doc.rust-lang.org/nightly/std/ptr/fn.from_exposed_addr.html).
327+
[`ptr::with_exposed_provenance`](https://doc.rust-lang.org/nightly/std/ptr/fn.with_exposed_provenance.html).
328328
This will necessarily miss some bugs as those operations are not efficiently and accurately
329329
implementable in a sanitizer, but it will only miss bugs that concern memory/pointers which is
330330
subject to these operations.

src/alloc_addresses/mod.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,12 @@ use reuse_pool::ReusePool;
1818

1919
#[derive(Copy, Clone, Debug, PartialEq, Eq)]
2020
pub enum ProvenanceMode {
21-
/// We support `expose_addr`/`from_exposed_addr` via "wildcard" provenance.
22-
/// However, we want on `from_exposed_addr` to alert the user of the precision loss.
21+
/// We support `expose_addr`/`with_exposed_provenance` via "wildcard" provenance.
22+
/// However, we want on `with_exposed_provenance` to alert the user of the precision loss.
2323
Default,
2424
/// Like `Default`, but without the warning.
2525
Permissive,
26-
/// We error on `from_exposed_addr`, ensuring no precision loss.
26+
/// We error on `with_exposed_provenance`, ensuring no precision loss.
2727
Strict,
2828
}
2929

src/diagnostics.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ impl fmt::Display for TerminationInfo {
6565
Int2PtrWithStrictProvenance =>
6666
write!(
6767
f,
68-
"integer-to-pointer casts and `ptr::from_exposed_addr` are not supported with `-Zmiri-strict-provenance`"
68+
"integer-to-pointer casts and `ptr::with_exposed_provenance` are not supported with `-Zmiri-strict-provenance`"
6969
),
7070
StackedBorrowsUb { msg, .. } => write!(f, "{msg}"),
7171
TreeBorrowsUb { title, .. } => write!(f, "{title}"),
@@ -587,7 +587,7 @@ impl<'mir, 'tcx> MiriMachine<'mir, 'tcx> {
587587
(
588588
None,
589589
format!(
590-
"This program is using integer-to-pointer casts or (equivalently) `ptr::from_exposed_addr`,"
590+
"This program is using integer-to-pointer casts or (equivalently) `ptr::with_exposed_provenance`,"
591591
),
592592
),
593593
(
@@ -597,7 +597,7 @@ impl<'mir, 'tcx> MiriMachine<'mir, 'tcx> {
597597
(
598598
None,
599599
format!(
600-
"See https://doc.rust-lang.org/nightly/std/ptr/fn.from_exposed_addr.html for more details on that operation."
600+
"See https://doc.rust-lang.org/nightly/std/ptr/fn.with_exposed_provenance.html for more details on that operation."
601601
),
602602
),
603603
(
@@ -609,7 +609,7 @@ impl<'mir, 'tcx> MiriMachine<'mir, 'tcx> {
609609
(
610610
None,
611611
format!(
612-
"You can then pass the `-Zmiri-strict-provenance` flag to Miri, to ensure you are not relying on `from_exposed_addr` semantics."
612+
"You can then pass the `-Zmiri-strict-provenance` flag to Miri, to ensure you are not relying on `with_exposed_provenance` semantics."
613613
),
614614
),
615615
(

tests/fail/provenance/ptr_int_unexposed.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,6 @@ fn main() {
77

88
let x_usize: usize = x_ptr.addr();
99
// Cast back an address that did *not* get exposed.
10-
let ptr = std::ptr::from_exposed_addr::<i32>(x_usize);
10+
let ptr = std::ptr::with_exposed_provenance::<i32>(x_usize);
1111
assert_eq!(unsafe { *ptr }, 3); //~ ERROR: is a dangling pointer
1212
}

tests/fail/provenance/strict_provenance_cast.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,5 @@
33

44
fn main() {
55
let addr = &0 as *const i32 as usize;
6-
let _ptr = std::ptr::from_exposed_addr::<i32>(addr); //~ ERROR: integer-to-pointer casts and `ptr::from_exposed_addr` are not supported
6+
let _ptr = std::ptr::with_exposed_provenance::<i32>(addr); //~ ERROR: integer-to-pointer casts and `ptr::with_exposed_provenance` are not supported
77
}

tests/fail/provenance/strict_provenance_cast.stderr

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
error: unsupported operation: integer-to-pointer casts and `ptr::from_exposed_addr` are not supported with `-Zmiri-strict-provenance`
1+
error: unsupported operation: integer-to-pointer casts and `ptr::with_exposed_provenance` are not supported with `-Zmiri-strict-provenance`
22
--> $DIR/strict_provenance_cast.rs:LL:CC
33
|
4-
LL | let _ptr = std::ptr::from_exposed_addr::<i32>(addr);
5-
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ integer-to-pointer casts and `ptr::from_exposed_addr` are not supported with `-Zmiri-strict-provenance`
4+
LL | let _ptr = std::ptr::with_exposed_provenance::<i32>(addr);
5+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ integer-to-pointer casts and `ptr::with_exposed_provenance` are not supported with `-Zmiri-strict-provenance`
66
|
77
= help: use Strict Provenance APIs (https://doc.rust-lang.org/nightly/std/ptr/index.html#strict-provenance, https://crates.io/crates/sptr) instead
88
= note: BACKTRACE:

tests/fail/stacked_borrows/exposed_only_ro.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,6 @@ fn main() {
77
let mut x = 0;
88
let _fool = &mut x as *mut i32; // this would have fooled the old untagged pointer logic
99
let addr = (&x as *const i32).expose_addr();
10-
let ptr = std::ptr::from_exposed_addr_mut::<i32>(addr);
10+
let ptr = std::ptr::with_exposed_provenance_mut::<i32>(addr);
1111
unsafe { *ptr = 0 }; //~ ERROR: /write access using <wildcard> .* no exposed tags have suitable permission in the borrow stack/
1212
}

tests/pass/box.stack.stderr

+3-3
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,11 @@ warning: integer-to-pointer cast
44
LL | let r2 = ((r as usize) + 0) as *mut i32;
55
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ integer-to-pointer cast
66
|
7-
= help: This program is using integer-to-pointer casts or (equivalently) `ptr::from_exposed_addr`,
7+
= help: This program is using integer-to-pointer casts or (equivalently) `ptr::with_exposed_provenance`,
88
= help: which means that Miri might miss pointer bugs in this program.
9-
= help: See https://doc.rust-lang.org/nightly/std/ptr/fn.from_exposed_addr.html for more details on that operation.
9+
= help: See https://doc.rust-lang.org/nightly/std/ptr/fn.with_exposed_provenance.html for more details on that operation.
1010
= help: To ensure that Miri does not miss bugs in your program, use Strict Provenance APIs (https://doc.rust-lang.org/nightly/std/ptr/index.html#strict-provenance, https://crates.io/crates/sptr) instead.
11-
= help: You can then pass the `-Zmiri-strict-provenance` flag to Miri, to ensure you are not relying on `from_exposed_addr` semantics.
11+
= help: You can then pass the `-Zmiri-strict-provenance` flag to Miri, to ensure you are not relying on `with_exposed_provenance` semantics.
1212
= help: Alternatively, the `-Zmiri-permissive-provenance` flag disables this warning.
1313
= note: BACKTRACE:
1414
= note: inside `into_raw` at $DIR/box.rs:LL:CC

tests/pass/extern_types.stack.stderr

+3-3
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,11 @@ warning: integer-to-pointer cast
44
LL | let x: &Foo = unsafe { &*(16 as *const Foo) };
55
| ^^^^^^^^^^^^^^^^^^ integer-to-pointer cast
66
|
7-
= help: This program is using integer-to-pointer casts or (equivalently) `ptr::from_exposed_addr`,
7+
= help: This program is using integer-to-pointer casts or (equivalently) `ptr::with_exposed_provenance`,
88
= help: which means that Miri might miss pointer bugs in this program.
9-
= help: See https://doc.rust-lang.org/nightly/std/ptr/fn.from_exposed_addr.html for more details on that operation.
9+
= help: See https://doc.rust-lang.org/nightly/std/ptr/fn.with_exposed_provenance.html for more details on that operation.
1010
= help: To ensure that Miri does not miss bugs in your program, use Strict Provenance APIs (https://doc.rust-lang.org/nightly/std/ptr/index.html#strict-provenance, https://crates.io/crates/sptr) instead.
11-
= help: You can then pass the `-Zmiri-strict-provenance` flag to Miri, to ensure you are not relying on `from_exposed_addr` semantics.
11+
= help: You can then pass the `-Zmiri-strict-provenance` flag to Miri, to ensure you are not relying on `with_exposed_provenance` semantics.
1212
= help: Alternatively, the `-Zmiri-permissive-provenance` flag disables this warning.
1313
= note: BACKTRACE:
1414
= note: inside `main` at $DIR/extern_types.rs:LL:CC

tests/pass/portable-simd-ptrs.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,5 +8,5 @@ fn main() {
88
// Pointer casts
99
let _val: Simd<*const u8, 4> = Simd::<*const i32, 4>::splat(ptr::null()).cast();
1010
let addrs = Simd::<*const i32, 4>::splat(ptr::null()).expose_addr();
11-
let _ptrs = Simd::<*const i32, 4>::from_exposed_addr(addrs);
11+
let _ptrs = Simd::<*const i32, 4>::with_exposed_provenance(addrs);
1212
}

tests/pass/ptr_int_from_exposed.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ fn ptr_roundtrip_out_of_bounds() {
1212

1313
let x_usize = x_ptr.wrapping_offset(128).expose_addr();
1414

15-
let ptr = ptr::from_exposed_addr::<i32>(x_usize).wrapping_offset(-128);
15+
let ptr = ptr::with_exposed_provenance::<i32>(x_usize).wrapping_offset(-128);
1616
assert_eq!(unsafe { *ptr }, 3);
1717
}
1818

@@ -27,7 +27,7 @@ fn ptr_roundtrip_confusion() {
2727
let x_usize = x_ptr.expose_addr();
2828
let y_usize = y_ptr.expose_addr();
2929

30-
let ptr = ptr::from_exposed_addr::<i32>(y_usize);
30+
let ptr = ptr::with_exposed_provenance::<i32>(y_usize);
3131
let ptr = ptr.with_addr(x_usize);
3232
assert_eq!(unsafe { *ptr }, 0);
3333
}
@@ -39,7 +39,7 @@ fn ptr_roundtrip_imperfect() {
3939

4040
let x_usize = x_ptr.expose_addr() + 128;
4141

42-
let ptr = ptr::from_exposed_addr::<u8>(x_usize).wrapping_offset(-128);
42+
let ptr = ptr::with_exposed_provenance::<u8>(x_usize).wrapping_offset(-128);
4343
assert_eq!(unsafe { *ptr }, 3);
4444
}
4545

@@ -51,7 +51,7 @@ fn ptr_roundtrip_null() {
5151
let null = x_null_ptr.expose_addr();
5252
assert_eq!(null, 0);
5353

54-
let x_null_ptr_copy = ptr::from_exposed_addr::<i32>(null); // just a roundtrip, so has provenance of x (angelically)
54+
let x_null_ptr_copy = ptr::with_exposed_provenance::<i32>(null); // just a roundtrip, so has provenance of x (angelically)
5555
let x_ptr_copy = x_null_ptr_copy.with_addr(x_ptr.addr()); // addr of x and provenance of x
5656
assert_eq!(unsafe { *x_ptr_copy }, 42);
5757
}

tests/pass/stacked-borrows/int-to-ptr.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ fn example(variant: bool) {
3939
// 4 is the "obvious" choice (topmost tag, what we used to do with untagged pointers).
4040
// And indeed if `variant == true` it is the only possible choice.
4141
// But if `variant == false` then 2 is the only possible choice!
42-
let x_wildcard = ptr::from_exposed_addr_mut::<i32>(x_raw2_addr);
42+
let x_wildcard = ptr::with_exposed_provenance_mut::<i32>(x_raw2_addr);
4343

4444
if variant {
4545
// If we picked 2, this will invalidate 3.

tests/pass/stacked-borrows/issue-miri-2389.stderr

+3-3
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,11 @@ warning: integer-to-pointer cast
44
LL | let wildcard = &root0 as *const Cell<i32> as usize as *const Cell<i32>;
55
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ integer-to-pointer cast
66
|
7-
= help: This program is using integer-to-pointer casts or (equivalently) `ptr::from_exposed_addr`,
7+
= help: This program is using integer-to-pointer casts or (equivalently) `ptr::with_exposed_provenance`,
88
= help: which means that Miri might miss pointer bugs in this program.
9-
= help: See https://doc.rust-lang.org/nightly/std/ptr/fn.from_exposed_addr.html for more details on that operation.
9+
= help: See https://doc.rust-lang.org/nightly/std/ptr/fn.with_exposed_provenance.html for more details on that operation.
1010
= help: To ensure that Miri does not miss bugs in your program, use Strict Provenance APIs (https://doc.rust-lang.org/nightly/std/ptr/index.html#strict-provenance, https://crates.io/crates/sptr) instead.
11-
= help: You can then pass the `-Zmiri-strict-provenance` flag to Miri, to ensure you are not relying on `from_exposed_addr` semantics.
11+
= help: You can then pass the `-Zmiri-strict-provenance` flag to Miri, to ensure you are not relying on `with_exposed_provenance` semantics.
1212
= help: Alternatively, the `-Zmiri-permissive-provenance` flag disables this warning.
1313
= note: BACKTRACE:
1414
= note: inside `main` at $DIR/issue-miri-2389.rs:LL:CC

tests/pass/stacked-borrows/unknown-bottom-gc.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ fn main() {
99

1010
// Expose the allocation and use the exposed pointer, creating an unknown bottom
1111
unsafe {
12-
let p: *mut u8 = ptr::from_exposed_addr::<u8>(ptr.expose_addr()) as *mut u8;
12+
let p: *mut u8 = ptr::with_exposed_provenance::<u8>(ptr.expose_addr()) as *mut u8;
1313
*p = 1;
1414
}
1515

0 commit comments

Comments
 (0)