Skip to content

Commit 93d3300

Browse files
authored
Rollup merge of rust-lang#122935 - RalfJung:with-exposed-provenance, r=Amanieu
rename ptr::from_exposed_addr -> ptr::with_exposed_provenance As discussed on [Zulip](https://rust-lang.zulipchat.com/#narrow/stream/136281-t-opsem/topic/To.20expose.20or.20not.20to.20expose/near/427757066). The old name, `from_exposed_addr`, makes little sense as it's not the address that is exposed, it's the provenance. (`ptr.expose_addr()` stays unchanged as we haven't found a better option yet. The intended interpretation is "expose the provenance and return the address".) The new name nicely matches `ptr::without_provenance`.
2 parents 61daba9 + c7a9561 commit 93d3300

File tree

3 files changed

+16
-16
lines changed

3 files changed

+16
-16
lines changed

crates/core_simd/src/simd/ptr/const_ptr.rs

+5-5
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,9 +137,9 @@ 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
142-
unsafe { core::intrinsics::simd::simd_from_exposed_addr(addr) }
142+
unsafe { core::intrinsics::simd::simd_with_exposed_provenance(addr) }
143143
}
144144

145145
#[inline]

crates/core_simd/src/simd/ptr/mut_ptr.rs

+5-5
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,9 +134,9 @@ 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
139-
unsafe { core::intrinsics::simd::simd_from_exposed_addr(addr) }
139+
unsafe { core::intrinsics::simd::simd_with_exposed_provenance(addr) }
140140
}
141141

142142
#[inline]

crates/core_simd/tests/pointers.rs

+6-6
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
}

0 commit comments

Comments
 (0)