Lift T: Sized
bounds from some strict_provenance
pointer methods
This commit is contained in:
parent
44fcfb0a96
commit
1f34e11d1b
2 changed files with 12 additions and 36 deletions
|
@ -178,14 +178,11 @@ impl<T: ?Sized> *const T {
|
||||||
#[must_use]
|
#[must_use]
|
||||||
#[inline]
|
#[inline]
|
||||||
#[unstable(feature = "strict_provenance", issue = "95228")]
|
#[unstable(feature = "strict_provenance", issue = "95228")]
|
||||||
pub fn addr(self) -> usize
|
pub fn addr(self) -> usize {
|
||||||
where
|
|
||||||
T: Sized,
|
|
||||||
{
|
|
||||||
// FIXME(strict_provenance_magic): I am magic and should be a compiler intrinsic.
|
// FIXME(strict_provenance_magic): I am magic and should be a compiler intrinsic.
|
||||||
// SAFETY: Pointer-to-integer transmutes are valid (if you are okay with losing the
|
// SAFETY: Pointer-to-integer transmutes are valid (if you are okay with losing the
|
||||||
// provenance).
|
// provenance).
|
||||||
unsafe { mem::transmute(self) }
|
unsafe { mem::transmute(self.cast::<()>()) }
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Gets the "address" portion of the pointer, and 'exposes' the "provenance" part for future
|
/// Gets the "address" portion of the pointer, and 'exposes' the "provenance" part for future
|
||||||
|
@ -215,12 +212,9 @@ impl<T: ?Sized> *const T {
|
||||||
#[must_use]
|
#[must_use]
|
||||||
#[inline]
|
#[inline]
|
||||||
#[unstable(feature = "strict_provenance", issue = "95228")]
|
#[unstable(feature = "strict_provenance", issue = "95228")]
|
||||||
pub fn expose_addr(self) -> usize
|
pub fn expose_addr(self) -> usize {
|
||||||
where
|
|
||||||
T: Sized,
|
|
||||||
{
|
|
||||||
// FIXME(strict_provenance_magic): I am magic and should be a compiler intrinsic.
|
// FIXME(strict_provenance_magic): I am magic and should be a compiler intrinsic.
|
||||||
self as usize
|
self.cast::<()>() as usize
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Creates a new pointer with the given address.
|
/// Creates a new pointer with the given address.
|
||||||
|
@ -238,10 +232,7 @@ impl<T: ?Sized> *const T {
|
||||||
#[must_use]
|
#[must_use]
|
||||||
#[inline]
|
#[inline]
|
||||||
#[unstable(feature = "strict_provenance", issue = "95228")]
|
#[unstable(feature = "strict_provenance", issue = "95228")]
|
||||||
pub fn with_addr(self, addr: usize) -> Self
|
pub fn with_addr(self, addr: usize) -> Self {
|
||||||
where
|
|
||||||
T: Sized,
|
|
||||||
{
|
|
||||||
// FIXME(strict_provenance_magic): I am magic and should be a compiler intrinsic.
|
// FIXME(strict_provenance_magic): I am magic and should be a compiler intrinsic.
|
||||||
//
|
//
|
||||||
// In the mean-time, this operation is defined to be "as if" it was
|
// In the mean-time, this operation is defined to be "as if" it was
|
||||||
|
@ -264,10 +255,7 @@ impl<T: ?Sized> *const T {
|
||||||
#[must_use]
|
#[must_use]
|
||||||
#[inline]
|
#[inline]
|
||||||
#[unstable(feature = "strict_provenance", issue = "95228")]
|
#[unstable(feature = "strict_provenance", issue = "95228")]
|
||||||
pub fn map_addr(self, f: impl FnOnce(usize) -> usize) -> Self
|
pub fn map_addr(self, f: impl FnOnce(usize) -> usize) -> Self {
|
||||||
where
|
|
||||||
T: Sized,
|
|
||||||
{
|
|
||||||
self.with_addr(f(self.addr()))
|
self.with_addr(f(self.addr()))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -188,14 +188,11 @@ impl<T: ?Sized> *mut T {
|
||||||
#[must_use]
|
#[must_use]
|
||||||
#[inline]
|
#[inline]
|
||||||
#[unstable(feature = "strict_provenance", issue = "95228")]
|
#[unstable(feature = "strict_provenance", issue = "95228")]
|
||||||
pub fn addr(self) -> usize
|
pub fn addr(self) -> usize {
|
||||||
where
|
|
||||||
T: Sized,
|
|
||||||
{
|
|
||||||
// FIXME(strict_provenance_magic): I am magic and should be a compiler intrinsic.
|
// FIXME(strict_provenance_magic): I am magic and should be a compiler intrinsic.
|
||||||
// SAFETY: Pointer-to-integer transmutes are valid (if you are okay with losing the
|
// SAFETY: Pointer-to-integer transmutes are valid (if you are okay with losing the
|
||||||
// provenance).
|
// provenance).
|
||||||
unsafe { mem::transmute(self) }
|
unsafe { mem::transmute(self.cast::<()>()) }
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Gets the "address" portion of the pointer, and 'exposes' the "provenance" part for future
|
/// Gets the "address" portion of the pointer, and 'exposes' the "provenance" part for future
|
||||||
|
@ -225,12 +222,9 @@ impl<T: ?Sized> *mut T {
|
||||||
#[must_use]
|
#[must_use]
|
||||||
#[inline]
|
#[inline]
|
||||||
#[unstable(feature = "strict_provenance", issue = "95228")]
|
#[unstable(feature = "strict_provenance", issue = "95228")]
|
||||||
pub fn expose_addr(self) -> usize
|
pub fn expose_addr(self) -> usize {
|
||||||
where
|
|
||||||
T: Sized,
|
|
||||||
{
|
|
||||||
// FIXME(strict_provenance_magic): I am magic and should be a compiler intrinsic.
|
// FIXME(strict_provenance_magic): I am magic and should be a compiler intrinsic.
|
||||||
self as usize
|
self.cast::<()>() as usize
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Creates a new pointer with the given address.
|
/// Creates a new pointer with the given address.
|
||||||
|
@ -248,10 +242,7 @@ impl<T: ?Sized> *mut T {
|
||||||
#[must_use]
|
#[must_use]
|
||||||
#[inline]
|
#[inline]
|
||||||
#[unstable(feature = "strict_provenance", issue = "95228")]
|
#[unstable(feature = "strict_provenance", issue = "95228")]
|
||||||
pub fn with_addr(self, addr: usize) -> Self
|
pub fn with_addr(self, addr: usize) -> Self {
|
||||||
where
|
|
||||||
T: Sized,
|
|
||||||
{
|
|
||||||
// FIXME(strict_provenance_magic): I am magic and should be a compiler intrinsic.
|
// FIXME(strict_provenance_magic): I am magic and should be a compiler intrinsic.
|
||||||
//
|
//
|
||||||
// In the mean-time, this operation is defined to be "as if" it was
|
// In the mean-time, this operation is defined to be "as if" it was
|
||||||
|
@ -274,10 +265,7 @@ impl<T: ?Sized> *mut T {
|
||||||
#[must_use]
|
#[must_use]
|
||||||
#[inline]
|
#[inline]
|
||||||
#[unstable(feature = "strict_provenance", issue = "95228")]
|
#[unstable(feature = "strict_provenance", issue = "95228")]
|
||||||
pub fn map_addr(self, f: impl FnOnce(usize) -> usize) -> Self
|
pub fn map_addr(self, f: impl FnOnce(usize) -> usize) -> Self {
|
||||||
where
|
|
||||||
T: Sized,
|
|
||||||
{
|
|
||||||
self.with_addr(f(self.addr()))
|
self.with_addr(f(self.addr()))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue