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

Lines changed: 1 addition & 1 deletion
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

Lines changed: 3 additions & 3 deletions
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

Lines changed: 4 additions & 4 deletions
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

Lines changed: 1 addition & 1 deletion
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

Lines changed: 1 addition & 1 deletion
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

Lines changed: 3 additions & 3 deletions
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

Lines changed: 1 addition & 1 deletion
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

Lines changed: 3 additions & 3 deletions
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

Lines changed: 3 additions & 3 deletions
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

Lines changed: 1 addition & 1 deletion
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
}

0 commit comments

Comments
 (0)