about summary refs log tree commit diff
diff options
context:
space:
mode:
authorZachary S <zasample18+github@gmail.com>2024-02-18 22:43:42 -0600
committerZachary S <zasample18+github@gmail.com>2024-02-18 22:43:42 -0600
commit261da5fc4b2f015436a206f217300f6616628052 (patch)
tree1b3699a2fbd6e7d15bab76b53bc543e086fa8afe
parent61223975d46f794466efa832bc7562b9707ecc46 (diff)
downloadrust-261da5fc4b2f015436a206f217300f6616628052.tar.gz
rust-261da5fc4b2f015436a206f217300f6616628052.zip
Clarify/add `must_use` message for Rc/Arc/Weak::into_raw.
-rw-r--r--library/alloc/src/rc.rs3
-rw-r--r--library/alloc/src/sync.rs2
2 files changed, 3 insertions, 2 deletions
diff --git a/library/alloc/src/rc.rs b/library/alloc/src/rc.rs
index 2cc38d90ffe..c6ce42e7aa7 100644
--- a/library/alloc/src/rc.rs
+++ b/library/alloc/src/rc.rs
@@ -1329,6 +1329,7 @@ impl<T: ?Sized, A: Allocator> Rc<T, A> {
     /// let x_ptr = Rc::into_raw(x);
     /// assert_eq!(unsafe { &*x_ptr }, "hello");
     /// ```
+    #[must_use = "losing the pointer will leak memory"]
     #[stable(feature = "rc_raw", since = "1.17.0")]
     #[rustc_never_returns_null_ptr]
     pub fn into_raw(this: Self) -> *const T {
@@ -2966,7 +2967,7 @@ impl<T: ?Sized, A: Allocator> Weak<T, A> {
     ///
     /// [`from_raw`]: Weak::from_raw
     /// [`as_ptr`]: Weak::as_ptr
-    #[must_use = "`self` will be dropped if the result is not used"]
+    #[must_use = "losing the pointer will leak memory"]
     #[stable(feature = "weak_into_raw", since = "1.45.0")]
     pub fn into_raw(self) -> *const T {
         let result = self.as_ptr();
diff --git a/library/alloc/src/sync.rs b/library/alloc/src/sync.rs
index e1211da4c61..c7c38d9b45e 100644
--- a/library/alloc/src/sync.rs
+++ b/library/alloc/src/sync.rs
@@ -2715,7 +2715,7 @@ impl<T: ?Sized, A: Allocator> Weak<T, A> {
     ///
     /// [`from_raw`]: Weak::from_raw
     /// [`as_ptr`]: Weak::as_ptr
-    #[must_use = "`self` will be dropped if the result is not used"]
+    #[must_use = "losing the pointer will leak memory"]
     #[stable(feature = "weak_into_raw", since = "1.45.0")]
     pub fn into_raw(self) -> *const T {
         let result = self.as_ptr();