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
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.
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 {
593593pub 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 {
637637pub 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
704704where
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
744744where
745745 T : Sized ,
746746{
0 commit comments