Source code
Revision control
Copy as Markdown
Other Tools
From b8464961a2681585a6231b93cd7e85e50022c2b3 Mon Sep 17 00:00:00 2001
From: Ralf Jung <post@ralfj.de>
Date: Sat, 13 Jul 2024 13:56:05 +0200
Subject: [PATCH] soft-deprecate the addr_of macros
diff --git a/library/core/src/ptr/mod.rs b/library/core/src/ptr/mod.rs
index 25d8f4a0adbd9..3fe5212cea779 100644
--- a/library/core/src/ptr/mod.rs
+++ b/library/core/src/ptr/mod.rs
@@ -2209,6 +2209,9 @@ impl<F: FnPtr> fmt::Debug for F {
/// Creates a `const` raw pointer to a place, without creating an intermediate reference.
///
+/// `addr_of!(expr)` is equivalent to `&raw const expr`. The macro is *soft-deprecated*;
+/// use `&raw const` instead.
+///
/// Creating a reference with `&`/`&mut` is only allowed if the pointer is properly aligned
/// and points to initialized data. For cases where those requirements do not hold,
/// raw pointers should be used instead. However, `&expr as *const _` creates a reference
@@ -2283,6 +2286,9 @@ pub macro addr_of($place:expr) {
/// Creates a `mut` raw pointer to a place, without creating an intermediate reference.
///
+/// `addr_of_mut!(expr)` is equivalent to `&raw mut expr`. The macro is *soft-deprecated*;
+/// use `&raw mut` instead.
+///
/// Creating a reference with `&`/`&mut` is only allowed if the pointer is properly aligned
/// and points to initialized data. For cases where those requirements do not hold,
/// raw pointers should be used instead. However, `&mut expr as *mut _` creates a reference