Skip to content

Commit 261da5f

Browse files
committed
Clarify/add must_use message for Rc/Arc/Weak::into_raw.
1 parent 6122397 commit 261da5f

File tree

2 files changed

+3
-2
lines changed

2 files changed

+3
-2
lines changed

library/alloc/src/rc.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -1329,6 +1329,7 @@ impl<T: ?Sized, A: Allocator> Rc<T, A> {
13291329
/// let x_ptr = Rc::into_raw(x);
13301330
/// assert_eq!(unsafe { &*x_ptr }, "hello");
13311331
/// ```
1332+
#[must_use = "losing the pointer will leak memory"]
13321333
#[stable(feature = "rc_raw", since = "1.17.0")]
13331334
#[rustc_never_returns_null_ptr]
13341335
pub fn into_raw(this: Self) -> *const T {
@@ -2966,7 +2967,7 @@ impl<T: ?Sized, A: Allocator> Weak<T, A> {
29662967
///
29672968
/// [`from_raw`]: Weak::from_raw
29682969
/// [`as_ptr`]: Weak::as_ptr
2969-
#[must_use = "`self` will be dropped if the result is not used"]
2970+
#[must_use = "losing the pointer will leak memory"]
29702971
#[stable(feature = "weak_into_raw", since = "1.45.0")]
29712972
pub fn into_raw(self) -> *const T {
29722973
let result = self.as_ptr();

library/alloc/src/sync.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -2715,7 +2715,7 @@ impl<T: ?Sized, A: Allocator> Weak<T, A> {
27152715
///
27162716
/// [`from_raw`]: Weak::from_raw
27172717
/// [`as_ptr`]: Weak::as_ptr
2718-
#[must_use = "`self` will be dropped if the result is not used"]
2718+
#[must_use = "losing the pointer will leak memory"]
27192719
#[stable(feature = "weak_into_raw", since = "1.45.0")]
27202720
pub fn into_raw(self) -> *const T {
27212721
let result = self.as_ptr();

0 commit comments

Comments
 (0)