summaryrefslogtreecommitdiffstats
path: root/library/core/src/ptr
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-05-30 03:57:31 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-05-30 03:57:31 +0000
commitdc0db358abe19481e475e10c32149b53370f1a1c (patch)
treeab8ce99c4b255ce46f99ef402c27916055b899ee /library/core/src/ptr
parentReleasing progress-linux version 1.71.1+dfsg1-2~progress7.99u1. (diff)
downloadrustc-dc0db358abe19481e475e10c32149b53370f1a1c.tar.xz
rustc-dc0db358abe19481e475e10c32149b53370f1a1c.zip
Merging upstream version 1.72.1+dfsg1.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'library/core/src/ptr')
-rw-r--r--library/core/src/ptr/const_ptr.rs11
-rw-r--r--library/core/src/ptr/metadata.rs3
-rw-r--r--library/core/src/ptr/mod.rs1
-rw-r--r--library/core/src/ptr/mut_ptr.rs22
-rw-r--r--library/core/src/ptr/unique.rs2
5 files changed, 9 insertions, 30 deletions
diff --git a/library/core/src/ptr/const_ptr.rs b/library/core/src/ptr/const_ptr.rs
index 6e1e862d3..926189a17 100644
--- a/library/core/src/ptr/const_ptr.rs
+++ b/library/core/src/ptr/const_ptr.rs
@@ -104,6 +104,7 @@ impl<T: ?Sized> *const T {
/// refactored.
#[stable(feature = "ptr_const_cast", since = "1.65.0")]
#[rustc_const_stable(feature = "ptr_const_cast", since = "1.65.0")]
+ #[rustc_diagnostic_item = "ptr_cast_mut"]
#[inline(always)]
pub const fn cast_mut(self) -> *mut T {
self as _
@@ -916,16 +917,8 @@ impl<T: ?Sized> *const T {
where
T: Sized,
{
- #[cfg(bootstrap)]
// SAFETY: the caller must uphold the safety contract for `offset`.
- unsafe {
- self.offset(count as isize)
- }
- #[cfg(not(bootstrap))]
- // SAFETY: the caller must uphold the safety contract for `offset`.
- unsafe {
- intrinsics::offset(self, count)
- }
+ unsafe { intrinsics::offset(self, count) }
}
/// Calculates the offset from a pointer in bytes (convenience for `.byte_offset(count as isize)`).
diff --git a/library/core/src/ptr/metadata.rs b/library/core/src/ptr/metadata.rs
index 2ea032d4a..daaa44b1d 100644
--- a/library/core/src/ptr/metadata.rs
+++ b/library/core/src/ptr/metadata.rs
@@ -50,7 +50,8 @@ use crate::hash::{Hash, Hasher};
///
/// [`to_raw_parts`]: *const::to_raw_parts
#[lang = "pointee_trait"]
-#[rustc_deny_explicit_impl]
+#[cfg_attr(not(bootstrap), rustc_deny_explicit_impl(implement_via_object = false))]
+#[cfg_attr(bootstrap, rustc_deny_explicit_impl)]
pub trait Pointee {
/// The type for metadata in pointers and references to `Self`.
#[lang = "metadata_type"]
diff --git a/library/core/src/ptr/mod.rs b/library/core/src/ptr/mod.rs
index d0cb2f715..acc9ca29d 100644
--- a/library/core/src/ptr/mod.rs
+++ b/library/core/src/ptr/mod.rs
@@ -698,6 +698,7 @@ where
#[inline(always)]
#[must_use]
#[unstable(feature = "ptr_from_ref", issue = "106116")]
+#[rustc_diagnostic_item = "ptr_from_ref"]
pub const fn from_ref<T: ?Sized>(r: &T) -> *const T {
r
}
diff --git a/library/core/src/ptr/mut_ptr.rs b/library/core/src/ptr/mut_ptr.rs
index 2fe5164c3..c6f438578 100644
--- a/library/core/src/ptr/mut_ptr.rs
+++ b/library/core/src/ptr/mut_ptr.rs
@@ -473,20 +473,10 @@ impl<T: ?Sized> *mut T {
where
T: Sized,
{
- #[cfg(bootstrap)]
// SAFETY: the caller must uphold the safety contract for `offset`.
// The obtained pointer is valid for writes since the caller must
// guarantee that it points to the same allocated object as `self`.
- unsafe {
- intrinsics::offset(self, count) as *mut T
- }
- #[cfg(not(bootstrap))]
- // SAFETY: the caller must uphold the safety contract for `offset`.
- // The obtained pointer is valid for writes since the caller must
- // guarantee that it points to the same allocated object as `self`.
- unsafe {
- intrinsics::offset(self, count)
- }
+ unsafe { intrinsics::offset(self, count) }
}
/// Calculates the offset from a pointer in bytes.
@@ -1026,16 +1016,8 @@ impl<T: ?Sized> *mut T {
where
T: Sized,
{
- #[cfg(bootstrap)]
- // SAFETY: the caller must uphold the safety contract for `offset`.
- unsafe {
- self.offset(count as isize)
- }
- #[cfg(not(bootstrap))]
// SAFETY: the caller must uphold the safety contract for `offset`.
- unsafe {
- intrinsics::offset(self, count)
- }
+ unsafe { intrinsics::offset(self, count) }
}
/// Calculates the offset from a pointer in bytes (convenience for `.byte_offset(count as isize)`).
diff --git a/library/core/src/ptr/unique.rs b/library/core/src/ptr/unique.rs
index a853f15ed..ff7e91d3e 100644
--- a/library/core/src/ptr/unique.rs
+++ b/library/core/src/ptr/unique.rs
@@ -32,6 +32,8 @@ use crate::ptr::NonNull;
)]
#[doc(hidden)]
#[repr(transparent)]
+// Lang item used experimentally by Miri to define the semantics of `Unique`.
+#[cfg_attr(not(bootstrap), lang = "ptr_unique")]
pub struct Unique<T: ?Sized> {
pointer: NonNull<T>,
// NOTE: this marker has no consequences for variance, but is necessary