Skip to content

Commit 67b9d7d

Browse files
committedMar 23, 2024
rename ptr::from_exposed_addr -> ptr::with_exposed_provenance
·
1.89.01.79.0
1 parent c3b05c6 commit 67b9d7d

File tree

31 files changed

+85
-85
lines changed

31 files changed

+85
-85
lines changed
 

‎compiler/rustc_hir_typeck/messages.ftl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ hir_typeck_invalid_callee = expected function, found {$ty}
8686
hir_typeck_lossy_provenance_int2ptr =
8787
strict provenance disallows casting integer `{$expr_ty}` to pointer `{$cast_ty}`
8888
.suggestion = use `.with_addr()` to adjust a valid pointer in the same allocation, to this address
89-
.help = if you can't comply with strict provenance and don't have a pointer with the correct provenance you can use `std::ptr::from_exposed_addr()` instead
89+
.help = if you can't comply with strict provenance and don't have a pointer with the correct provenance you can use `std::ptr::with_exposed_provenance()` instead
9090
9191
hir_typeck_lossy_provenance_ptr2int =
9292
under strict provenance it is considered bad style to cast pointer `{$expr_ty}` to integer `{$cast_ty}`

‎compiler/rustc_lint_defs/src/builtin.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2749,19 +2749,19 @@ declare_lint! {
27492749
/// memory the pointer is allowed to read/write. Casting an integer, which
27502750
/// doesn't have provenance, to a pointer requires the compiler to assign
27512751
/// (guess) provenance. The compiler assigns "all exposed valid" (see the
2752-
/// docs of [`ptr::from_exposed_addr`] for more information about this
2752+
/// docs of [`ptr::with_exposed_provenance`] for more information about this
27532753
/// "exposing"). This penalizes the optimiser and is not well suited for
27542754
/// dynamic analysis/dynamic program verification (e.g. Miri or CHERI
27552755
/// platforms).
27562756
///
27572757
/// It is much better to use [`ptr::with_addr`] instead to specify the
27582758
/// provenance you want. If using this function is not possible because the
27592759
/// code relies on exposed provenance then there is as an escape hatch
2760-
/// [`ptr::from_exposed_addr`].
2760+
/// [`ptr::with_exposed_provenance`].
27612761
///
27622762
/// [issue #95228]: https://github.com/rust-lang/rust/issues/95228
27632763
/// [`ptr::with_addr`]: https://doc.rust-lang.org/core/primitive.pointer.html#method.with_addr
2764-
/// [`ptr::from_exposed_addr`]: https://doc.rust-lang.org/core/ptr/fn.from_exposed_addr.html
2764+
/// [`ptr::with_exposed_provenance`]: https://doc.rust-lang.org/core/ptr/fn.with_exposed_provenance.html
27652765
pub FUZZY_PROVENANCE_CASTS,
27662766
Allow,
27672767
"a fuzzy integer to pointer cast is used",

‎compiler/rustc_middle/src/mir/syntax.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1318,7 +1318,7 @@ pub enum CastKind {
13181318
/// See the docs on `expose_addr` for more details.
13191319
PointerExposeAddress,
13201320
/// An address-to-pointer cast that picks up an exposed provenance.
1321-
/// See the docs on `from_exposed_addr` for more details.
1321+
/// See the docs on `with_exposed_provenance` for more details.
13221322
PointerFromExposedAddress,
13231323
/// Pointer related casts that are done by coercions. Note that reference-to-raw-ptr casts are
13241324
/// translated into `&raw mut/const *r`, i.e., they are not actually casts.

‎library/core/src/ptr/const_ptr.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,7 @@ impl<T: ?Sized> *const T {
165165
#[unstable(feature = "ptr_to_from_bits", issue = "91126")]
166166
#[deprecated(
167167
since = "1.67.0",
168-
note = "replaced by the `ptr::from_exposed_addr` function, or update \
168+
note = "replaced by the `ptr::with_exposed_provenance` function, or update \
169169
your code to follow the strict provenance rules using its APIs"
170170
)]
171171
#[allow(fuzzy_provenance_casts)] // this is an unstable and semi-deprecated cast function
@@ -187,7 +187,7 @@ impl<T: ?Sized> *const T {
187187
///
188188
/// If using those APIs is not possible because there is no way to preserve a pointer with the
189189
/// required provenance, then Strict Provenance might not be for you. Use pointer-integer casts
190-
/// or [`expose_addr`][pointer::expose_addr] and [`from_exposed_addr`][from_exposed_addr]
190+
/// or [`expose_addr`][pointer::expose_addr] and [`with_exposed_provenance`][with_exposed_provenance]
191191
/// instead. However, note that this makes your code less portable and less amenable to tools
192192
/// that check for compliance with the Rust memory model.
193193
///
@@ -211,30 +211,30 @@ impl<T: ?Sized> *const T {
211211
}
212212

213213
/// Gets the "address" portion of the pointer, and 'exposes' the "provenance" part for future
214-
/// use in [`from_exposed_addr`][].
214+
/// use in [`with_exposed_provenance`][].
215215
///
216216
/// This is equivalent to `self as usize`, which semantically discards *provenance* and
217217
/// *address-space* information. Furthermore, this (like the `as` cast) has the implicit
218218
/// side-effect of marking the provenance as 'exposed', so on platforms that support it you can
219-
/// later call [`from_exposed_addr`][] to reconstitute the original pointer including its
219+
/// later call [`with_exposed_provenance`][] to reconstitute the original pointer including its
220220
/// provenance. (Reconstructing address space information, if required, is your responsibility.)
221221
///
222222
/// Using this method means that code is *not* following [Strict
223223
/// Provenance][super#strict-provenance] rules. Supporting
224-
/// [`from_exposed_addr`][] complicates specification and reasoning and may not be supported by
224+
/// [`with_exposed_provenance`][] complicates specification and reasoning and may not be supported by
225225
/// tools that help you to stay conformant with the Rust memory model, so it is recommended to
226226
/// use [`addr`][pointer::addr] wherever possible.
227227
///
228228
/// On most platforms this will produce a value with the same bytes as the original pointer,
229229
/// because all the bytes are dedicated to describing the address. Platforms which need to store
230230
/// additional information in the pointer may not support this operation, since the 'expose'
231-
/// side-effect which is required for [`from_exposed_addr`][] to work is typically not
231+
/// side-effect which is required for [`with_exposed_provenance`][] to work is typically not
232232
/// available.
233233
///
234234
/// It is unclear whether this method can be given a satisfying unambiguous specification. This
235235
/// API and its claimed semantics are part of [Exposed Provenance][super#exposed-provenance].
236236
///
237-
/// [`from_exposed_addr`]: from_exposed_addr
237+
/// [`with_exposed_provenance`]: with_exposed_provenance
238238
#[must_use]
239239
#[inline(always)]
240240
#[unstable(feature = "exposed_provenance", issue = "95228")]

‎library/core/src/ptr/mod.rs

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -340,13 +340,13 @@
340340
//! clear where a satisfying unambiguous semantics can be defined for Exposed Provenance.
341341
//! Furthermore, Exposed Provenance will not work (well) with tools like [Miri] and [CHERI].
342342
//!
343-
//! Exposed Provenance is provided by the [`expose_addr`] and [`from_exposed_addr`] methods, which
343+
//! Exposed Provenance is provided by the [`expose_addr`] and [`with_exposed_provenance`] methods, which
344344
//! are meant to replace `as` casts between pointers and integers. [`expose_addr`] is a lot like
345345
//! [`addr`], but additionally adds the provenance of the pointer to a global list of 'exposed'
346346
//! provenances. (This list is purely conceptual, it exists for the purpose of specifying Rust but
347-
//! is not materialized in actual executions, except in tools like [Miri].) [`from_exposed_addr`]
347+
//! is not materialized in actual executions, except in tools like [Miri].) [`with_exposed_provenance`]
348348
//! can be used to construct a pointer with one of these previously 'exposed' provenances.
349-
//! [`from_exposed_addr`] takes only `addr: usize` as arguments, so unlike in [`with_addr`] there is
349+
//! [`with_exposed_provenance`] takes only `addr: usize` as arguments, so unlike in [`with_addr`] there is
350350
//! no indication of what the correct provenance for the returned pointer is -- and that is exactly
351351
//! what makes pointer-usize-pointer roundtrips so tricky to rigorously specify! There is no
352352
//! algorithm that decides which provenance will be used. You can think of this as "guessing" the
@@ -355,10 +355,10 @@
355355
//! there is *no* previously 'exposed' provenance that justifies the way the returned pointer will
356356
//! be used, the program has undefined behavior.
357357
//!
358-
//! Using [`expose_addr`] or [`from_exposed_addr`] (or the `as` casts) means that code is
358+
//! Using [`expose_addr`] or [`with_exposed_provenance`] (or the `as` casts) means that code is
359359
//! *not* following Strict Provenance rules. The goal of the Strict Provenance experiment is to
360360
//! determine how far one can get in Rust without the use of [`expose_addr`] and
361-
//! [`from_exposed_addr`], and to encourage code to be written with Strict Provenance APIs only.
361+
//! [`with_exposed_provenance`], and to encourage code to be written with Strict Provenance APIs only.
362362
//! Maximizing the amount of such code is a major win for avoiding specification complexity and to
363363
//! facilitate adoption of tools like [CHERI] and [Miri] that can be a big help in increasing the
364364
//! confidence in (unsafe) Rust code.
@@ -375,7 +375,7 @@
375375
//! [`addr`]: pointer::addr
376376
//! [`ptr::dangling`]: core::ptr::dangling
377377
//! [`expose_addr`]: pointer::expose_addr
378-
//! [`from_exposed_addr`]: from_exposed_addr
378+
//! [`with_exposed_provenance`]: with_exposed_provenance
379379
//! [Miri]: https://github.com/rust-lang/miri
380380
//! [CHERI]: https://www.cl.cam.ac.uk/research/security/ctsrd/cheri/
381381
//! [Strict Provenance]: https://github.com/rust-lang/rust/issues/95228
@@ -582,7 +582,7 @@ pub const fn null_mut<T: ?Sized + Thin>() -> *mut T {
582582
/// little more than a usize address in disguise.
583583
///
584584
/// This is different from `addr as *const T`, which creates a pointer that picks up a previously
585-
/// exposed provenance. See [`from_exposed_addr`] for more details on that operation.
585+
/// exposed provenance. See [`with_exposed_provenance`] for more details on that operation.
586586
///
587587
/// This API and its claimed semantics are part of the Strict Provenance experiment,
588588
/// see the [module documentation][crate::ptr] for details.
@@ -593,7 +593,7 @@ pub const fn null_mut<T: ?Sized + Thin>() -> *mut T {
593593
pub const fn without_provenance<T>(addr: usize) -> *const T {
594594
// FIXME(strict_provenance_magic): I am magic and should be a compiler intrinsic.
595595
// We use transmute rather than a cast so tools like Miri can tell that this
596-
// is *not* the same as from_exposed_addr.
596+
// is *not* the same as with_exposed_provenance.
597597
// SAFETY: every valid integer is also a valid pointer (as long as you don't dereference that
598598
// pointer).
599599
unsafe { mem::transmute(addr) }
@@ -626,7 +626,7 @@ pub const fn dangling<T>() -> *const T {
626626
/// little more than a usize address in disguise.
627627
///
628628
/// This is different from `addr as *mut T`, which creates a pointer that picks up a previously
629-
/// exposed provenance. See [`from_exposed_addr_mut`] for more details on that operation.
629+
/// exposed provenance. See [`with_exposed_provenance_mut`] for more details on that operation.
630630
///
631631
/// This API and its claimed semantics are part of the Strict Provenance experiment,
632632
/// see the [module documentation][crate::ptr] for details.
@@ -637,7 +637,7 @@ pub const fn dangling<T>() -> *const T {
637637
pub const fn without_provenance_mut<T>(addr: usize) -> *mut T {
638638
// FIXME(strict_provenance_magic): I am magic and should be a compiler intrinsic.
639639
// We use transmute rather than a cast so tools like Miri can tell that this
640-
// is *not* the same as from_exposed_addr.
640+
// is *not* the same as with_exposed_provenance.
641641
// SAFETY: every valid integer is also a valid pointer (as long as you don't dereference that
642642
// pointer).
643643
unsafe { mem::transmute(addr) }
@@ -700,7 +700,7 @@ pub const fn dangling_mut<T>() -> *mut T {
700700
#[unstable(feature = "exposed_provenance", issue = "95228")]
701701
#[cfg_attr(miri, track_caller)] // even without panics, this helps for Miri backtraces
702702
#[allow(fuzzy_provenance_casts)] // this *is* the explicit provenance API one should use instead
703-
pub fn from_exposed_addr<T>(addr: usize) -> *const T
703+
pub fn with_exposed_provenance<T>(addr: usize) -> *const T
704704
where
705705
T: Sized,
706706
{
@@ -740,7 +740,7 @@ where
740740
#[unstable(feature = "exposed_provenance", issue = "95228")]
741741
#[cfg_attr(miri, track_caller)] // even without panics, this helps for Miri backtraces
742742
#[allow(fuzzy_provenance_casts)] // this *is* the explicit provenance API one should use instead
743-
pub fn from_exposed_addr_mut<T>(addr: usize) -> *mut T
743+
pub fn with_exposed_provenance_mut<T>(addr: usize) -> *mut T
744744
where
745745
T: Sized,
746746
{

‎library/core/src/ptr/mut_ptr.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,7 @@ impl<T: ?Sized> *mut T {
171171
#[unstable(feature = "ptr_to_from_bits", issue = "91126")]
172172
#[deprecated(
173173
since = "1.67.0",
174-
note = "replaced by the `ptr::from_exposed_addr_mut` function, or \
174+
note = "replaced by the `ptr::with_exposed_provenance_mut` function, or \
175175
update your code to follow the strict provenance rules using its APIs"
176176
)]
177177
#[allow(fuzzy_provenance_casts)] // this is an unstable and semi-deprecated cast function
@@ -194,7 +194,7 @@ impl<T: ?Sized> *mut T {
194194
///
195195
/// If using those APIs is not possible because there is no way to preserve a pointer with the
196196
/// required provenance, then Strict Provenance might not be for you. Use pointer-integer casts
197-
/// or [`expose_addr`][pointer::expose_addr] and [`from_exposed_addr`][from_exposed_addr]
197+
/// or [`expose_addr`][pointer::expose_addr] and [`with_exposed_provenance`][with_exposed_provenance]
198198
/// instead. However, note that this makes your code less portable and less amenable to tools
199199
/// that check for compliance with the Rust memory model.
200200
///
@@ -218,30 +218,30 @@ impl<T: ?Sized> *mut T {
218218
}
219219

220220
/// Gets the "address" portion of the pointer, and 'exposes' the "provenance" part for future
221-
/// use in [`from_exposed_addr`][].
221+
/// use in [`with_exposed_provenance`][].
222222
///
223223
/// This is equivalent to `self as usize`, which semantically discards *provenance* and
224224
/// *address-space* information. Furthermore, this (like the `as` cast) has the implicit
225225
/// side-effect of marking the provenance as 'exposed', so on platforms that support it you can
226-
/// later call [`from_exposed_addr_mut`][] to reconstitute the original pointer including its
226+
/// later call [`with_exposed_provenance_mut`][] to reconstitute the original pointer including its
227227
/// provenance. (Reconstructing address space information, if required, is your responsibility.)
228228
///
229229
/// Using this method means that code is *not* following [Strict
230230
/// Provenance][super#strict-provenance] rules. Supporting
231-
/// [`from_exposed_addr_mut`][] complicates specification and reasoning and may not be supported
231+
/// [`with_exposed_provenance_mut`][] complicates specification and reasoning and may not be supported
232232
/// by tools that help you to stay conformant with the Rust memory model, so it is recommended
233233
/// to use [`addr`][pointer::addr] wherever possible.
234234
///
235235
/// On most platforms this will produce a value with the same bytes as the original pointer,
236236
/// because all the bytes are dedicated to describing the address. Platforms which need to store
237237
/// additional information in the pointer may not support this operation, since the 'expose'
238-
/// side-effect which is required for [`from_exposed_addr_mut`][] to work is typically not
238+
/// side-effect which is required for [`with_exposed_provenance_mut`][] to work is typically not
239239
/// available.
240240
///
241241
/// It is unclear whether this method can be given a satisfying unambiguous specification. This
242242
/// API and its claimed semantics are part of [Exposed Provenance][super#exposed-provenance].
243243
///
244-
/// [`from_exposed_addr_mut`]: from_exposed_addr_mut
244+
/// [`with_exposed_provenance_mut`]: with_exposed_provenance_mut
245245
#[must_use]
246246
#[inline(always)]
247247
#[unstable(feature = "exposed_provenance", issue = "95228")]

‎library/portable-simd/crates/core_simd/src/simd/ptr/const_ptr.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -51,13 +51,13 @@ pub trait SimdConstPtr: Copy + Sealed {
5151
fn with_addr(self, addr: Self::Usize) -> Self;
5252

5353
/// Gets the "address" portion of the pointer, and "exposes" the provenance part for future use
54-
/// in [`Self::from_exposed_addr`].
54+
/// in [`Self::with_exposed_provenance`].
5555
fn expose_addr(self) -> Self::Usize;
5656

5757
/// Convert an address back to a pointer, picking up a previously "exposed" provenance.
5858
///
59-
/// Equivalent to calling [`core::ptr::from_exposed_addr`] on each element.
60-
fn from_exposed_addr(addr: Self::Usize) -> Self;
59+
/// Equivalent to calling [`core::ptr::with_exposed_provenance`] on each element.
60+
fn with_exposed_provenance(addr: Self::Usize) -> Self;
6161

6262
/// Calculates the offset from a pointer using wrapping arithmetic.
6363
///
@@ -137,7 +137,7 @@ where
137137
}
138138

139139
#[inline]
140-
fn from_exposed_addr(addr: Self::Usize) -> Self {
140+
fn with_exposed_provenance(addr: Self::Usize) -> Self {
141141
// Safety: `self` is a pointer vector
142142
unsafe { core::intrinsics::simd::simd_from_exposed_addr(addr) }
143143
}

‎library/portable-simd/crates/core_simd/src/simd/ptr/mut_ptr.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -48,13 +48,13 @@ pub trait SimdMutPtr: Copy + Sealed {
4848
fn with_addr(self, addr: Self::Usize) -> Self;
4949

5050
/// Gets the "address" portion of the pointer, and "exposes" the provenance part for future use
51-
/// in [`Self::from_exposed_addr`].
51+
/// in [`Self::with_exposed_provenance`].
5252
fn expose_addr(self) -> Self::Usize;
5353

5454
/// Convert an address back to a pointer, picking up a previously "exposed" provenance.
5555
///
56-
/// Equivalent to calling [`core::ptr::from_exposed_addr_mut`] on each element.
57-
fn from_exposed_addr(addr: Self::Usize) -> Self;
56+
/// Equivalent to calling [`core::ptr::with_exposed_provenance_mut`] on each element.
57+
fn with_exposed_provenance(addr: Self::Usize) -> Self;
5858

5959
/// Calculates the offset from a pointer using wrapping arithmetic.
6060
///
@@ -134,7 +134,7 @@ where
134134
}
135135

136136
#[inline]
137-
fn from_exposed_addr(addr: Self::Usize) -> Self {
137+
fn with_exposed_provenance(addr: Self::Usize) -> Self {
138138
// Safety: `self` is a pointer vector
139139
unsafe { core::intrinsics::simd::simd_from_exposed_addr(addr) }
140140
}

‎library/portable-simd/crates/core_simd/tests/pointers.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -80,10 +80,10 @@ mod const_ptr {
8080
);
8181
}
8282

83-
fn from_exposed_addr<const LANES: usize>() {
83+
fn with_exposed_provenance<const LANES: usize>() {
8484
test_helpers::test_unary_elementwise(
85-
&Simd::<*const u32, LANES>::from_exposed_addr,
86-
&core::ptr::from_exposed_addr::<u32>,
85+
&Simd::<*const u32, LANES>::with_exposed_provenance,
86+
&core::ptr::with_exposed_provenance::<u32>,
8787
&|_| true,
8888
);
8989
}
@@ -103,10 +103,10 @@ mod mut_ptr {
103103
);
104104
}
105105

106-
fn from_exposed_addr<const LANES: usize>() {
106+
fn with_exposed_provenance<const LANES: usize>() {
107107
test_helpers::test_unary_elementwise(
108-
&Simd::<*mut u32, LANES>::from_exposed_addr,
109-
&core::ptr::from_exposed_addr_mut::<u32>,
108+
&Simd::<*mut u32, LANES>::with_exposed_provenance,
109+
&core::ptr::with_exposed_provenance_mut::<u32>,
110110
&|_| true,
111111
);
112112
}

‎library/std/src/os/xous/ffi.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -389,7 +389,7 @@ pub(crate) unsafe fn map_memory<T>(
389389
let result = a0;
390390

391391
if result == SyscallResult::MemoryRange as usize {
392-
let start = core::ptr::from_exposed_addr_mut::<T>(a1);
392+
let start = core::ptr::with_exposed_provenance_mut::<T>(a1);
393393
let len = a2 / core::mem::size_of::<T>();
394394
let end = unsafe { start.add(len) };
395395
Ok(unsafe { core::slice::from_raw_parts_mut(start, len) })

‎library/std/src/sys/pal/hermit/thread.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ impl Thread {
4747
extern "C" fn thread_start(main: usize) {
4848
unsafe {
4949
// Finally, let's run some code.
50-
Box::from_raw(ptr::from_exposed_addr::<Box<dyn FnOnce()>>(main).cast_mut())();
50+
Box::from_raw(ptr::with_exposed_provenance::<Box<dyn FnOnce()>>(main).cast_mut())();
5151

5252
// run all destructors
5353
run_dtors();

‎library/std/src/sys/pal/itron/thread.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ impl Thread {
9898
});
9999

100100
unsafe extern "C" fn trampoline(exinf: isize) {
101-
let p_inner: *mut ThreadInner = crate::ptr::from_exposed_addr_mut(exinf as usize);
101+
let p_inner: *mut ThreadInner = crate::ptr::with_exposed_provenance_mut(exinf as usize);
102102
// Safety: `ThreadInner` is alive at this point
103103
let inner = unsafe { &*p_inner };
104104

‎library/std/src/sys/pal/xous/thread_local_key.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ fn tls_ptr_addr() -> *mut *mut u8 {
4949
out(reg) tp,
5050
);
5151
}
52-
core::ptr::from_exposed_addr_mut::<*mut u8>(tp)
52+
core::ptr::with_exposed_provenance_mut::<*mut u8>(tp)
5353
}
5454

5555
/// Create an area of memory that's unique per thread. This area will

‎library/std/src/sys/pal/zkvm/thread_local_key.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,13 @@ pub unsafe fn create(_dtor: Option<unsafe extern "C" fn(*mut u8)>) -> Key {
99

1010
#[inline]
1111
pub unsafe fn set(key: Key, value: *mut u8) {
12-
let key: *mut *mut u8 = core::ptr::from_exposed_addr_mut(key);
12+
let key: *mut *mut u8 = core::ptr::with_exposed_provenance_mut(key);
1313
*key = value;
1414
}
1515

1616
#[inline]
1717
pub unsafe fn get(key: Key) -> *mut u8 {
18-
let key: *mut *mut u8 = core::ptr::from_exposed_addr_mut(key);
18+
let key: *mut *mut u8 = core::ptr::with_exposed_provenance_mut(key);
1919
*key
2020
}
2121

‎library/std/src/sys/personality/dwarf/eh.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ pub unsafe fn find_eh_action(lsda: *const u8, context: &EHContext<'_>) -> Result
125125
// Can never have null landing pad for sjlj -- that would have
126126
// been indicated by a -1 call site index.
127127
// FIXME(strict provenance)
128-
let lpad = ptr::from_exposed_addr((cs_lpad + 1) as usize);
128+
let lpad = ptr::with_exposed_provenance((cs_lpad + 1) as usize);
129129
return Ok(interpret_cs_action(action_table, cs_action_entry, lpad));
130130
}
131131
}

‎src/tools/miri/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/tools/miri/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/tools/miri/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
(

‎src/tools/miri/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
}

‎src/tools/miri/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
}

‎src/tools/miri/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:

‎src/tools/miri/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
}

‎src/tools/miri/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

‎src/tools/miri/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

‎src/tools/miri/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
}

‎src/tools/miri/tests/pass/ptr_int_from_exposed.rs

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

‎src/tools/miri/tests/pass/stacked-borrows/int-to-ptr.rs

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

‎src/tools/miri/tests/pass/stacked-borrows/issue-miri-2389.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 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

‎src/tools/miri/tests/pass/stacked-borrows/unknown-bottom-gc.rs

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

‎tests/ui/lint/lint-strict-provenance-fuzzy-casts.stderr

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ error: strict provenance disallows casting integer `usize` to pointer `*const u8
44
LL | let dangling = 16_usize as *const u8;
55
| ^^^^^^^^^^^^^^^^^^^^^
66
|
7-
= help: if you can't comply with strict provenance and don't have a pointer with the correct provenance you can use `std::ptr::from_exposed_addr()` instead
7+
= help: if you can't comply with strict provenance and don't have a pointer with the correct provenance you can use `std::ptr::with_exposed_provenance()` instead
88
note: the lint level is defined here
99
--> $DIR/lint-strict-provenance-fuzzy-casts.rs:2:9
1010
|

‎tests/ui/simd/intrinsic/ptr-cast.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,10 @@ fn main() {
2424

2525
let exposed_addr: V<usize> = simd_expose_addr(const_ptrs);
2626

27-
let from_exposed_addr: V<*mut i8> = simd_from_exposed_addr(exposed_addr);
27+
let with_exposed_provenance: V<*mut i8> = simd_from_exposed_addr(exposed_addr);
2828

2929
assert!(const_ptrs.0 == [ptr as *const u8, core::ptr::null()]);
3030
assert!(exposed_addr.0 == [ptr as usize, 0]);
31-
assert!(from_exposed_addr.0 == ptrs.0);
31+
assert!(with_exposed_provenance.0 == ptrs.0);
3232
}
3333
}

0 commit comments

Comments
 (0)
Please sign in to comment.