340
340
//! clear where a satisfying unambiguous semantics can be defined for Exposed Provenance.
341
341
//! Furthermore, Exposed Provenance will not work (well) with tools like [Miri] and [CHERI].
342
342
//!
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
344
344
//! are meant to replace `as` casts between pointers and integers. [`expose_addr`] is a lot like
345
345
//! [`addr`], but additionally adds the provenance of the pointer to a global list of 'exposed'
346
346
//! 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 `]
348
348
//! 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
350
350
//! no indication of what the correct provenance for the returned pointer is -- and that is exactly
351
351
//! what makes pointer-usize-pointer roundtrips so tricky to rigorously specify! There is no
352
352
//! algorithm that decides which provenance will be used. You can think of this as "guessing" the
355
355
//! there is *no* previously 'exposed' provenance that justifies the way the returned pointer will
356
356
//! be used, the program has undefined behavior.
357
357
//!
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
359
359
//! *not* following Strict Provenance rules. The goal of the Strict Provenance experiment is to
360
360
//! 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.
362
362
//! Maximizing the amount of such code is a major win for avoiding specification complexity and to
363
363
//! facilitate adoption of tools like [CHERI] and [Miri] that can be a big help in increasing the
364
364
//! confidence in (unsafe) Rust code.
375
375
//! [`addr`]: pointer::addr
376
376
//! [`ptr::dangling`]: core::ptr::dangling
377
377
//! [`expose_addr`]: pointer::expose_addr
378
- //! [`from_exposed_addr `]: from_exposed_addr
378
+ //! [`with_exposed_provenance `]: with_exposed_provenance
379
379
//! [Miri]: https://github.com/rust-lang/miri
380
380
//! [CHERI]: https://www.cl.cam.ac.uk/research/security/ctsrd/cheri/
381
381
//! [Strict Provenance]: https://github.com/rust-lang/rust/issues/95228
@@ -582,7 +582,7 @@ pub const fn null_mut<T: ?Sized + Thin>() -> *mut T {
582
582
/// little more than a usize address in disguise.
583
583
///
584
584
/// 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.
586
586
///
587
587
/// This API and its claimed semantics are part of the Strict Provenance experiment,
588
588
/// see the [module documentation][crate::ptr] for details.
@@ -593,7 +593,7 @@ pub const fn null_mut<T: ?Sized + Thin>() -> *mut T {
593
593
pub const fn without_provenance < T > ( addr : usize ) -> * const T {
594
594
// FIXME(strict_provenance_magic): I am magic and should be a compiler intrinsic.
595
595
// 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 .
597
597
// SAFETY: every valid integer is also a valid pointer (as long as you don't dereference that
598
598
// pointer).
599
599
unsafe { mem:: transmute ( addr) }
@@ -626,7 +626,7 @@ pub const fn dangling<T>() -> *const T {
626
626
/// little more than a usize address in disguise.
627
627
///
628
628
/// 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.
630
630
///
631
631
/// This API and its claimed semantics are part of the Strict Provenance experiment,
632
632
/// see the [module documentation][crate::ptr] for details.
@@ -637,7 +637,7 @@ pub const fn dangling<T>() -> *const T {
637
637
pub const fn without_provenance_mut < T > ( addr : usize ) -> * mut T {
638
638
// FIXME(strict_provenance_magic): I am magic and should be a compiler intrinsic.
639
639
// 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 .
641
641
// SAFETY: every valid integer is also a valid pointer (as long as you don't dereference that
642
642
// pointer).
643
643
unsafe { mem:: transmute ( addr) }
@@ -700,7 +700,7 @@ pub const fn dangling_mut<T>() -> *mut T {
700
700
#[ unstable( feature = "exposed_provenance" , issue = "95228" ) ]
701
701
#[ cfg_attr( miri, track_caller) ] // even without panics, this helps for Miri backtraces
702
702
#[ 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
704
704
where
705
705
T : Sized ,
706
706
{
@@ -740,7 +740,7 @@ where
740
740
#[ unstable( feature = "exposed_provenance" , issue = "95228" ) ]
741
741
#[ cfg_attr( miri, track_caller) ] // even without panics, this helps for Miri backtraces
742
742
#[ 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
744
744
where
745
745
T : Sized ,
746
746
{
0 commit comments