Skip to content

Commit f4ea009

Browse files
authored
Unrolled build for rust-lang#121287
Rollup merge of rust-lang#121287 - zachs18:rc-into-raw-must-use, r=cuviper Clarify/add `must_use` message for Rc/Arc/Weak::into_raw. The current `#[must_use]` messages for `{sync,rc}::Weak::into_raw` ("`self` will be dropped if the result is not used") are misleading, as `self` is consumed and will *not* be dropped. This PR changes their `#[must_use]` message to the same as `Arc::into_raw`'s[ current `#[must_use]` message](https://github.com/rust-lang/rust/blob/d5735645753e990a72446094f703df9b5e421555/library/alloc/src/sync.rs#L1482) ("losing the pointer will leak memory"), and also adds it to `Rc::into_raw`, which is not currently `#[must_use]`.
2 parents 5a1e544 + 261da5f commit f4ea009

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 {
@@ -2970,7 +2971,7 @@ impl<T: ?Sized, A: Allocator> Weak<T, A> {
29702971
///
29712972
/// [`from_raw`]: Weak::from_raw
29722973
/// [`as_ptr`]: Weak::as_ptr
2973-
#[must_use = "`self` will be dropped if the result is not used"]
2974+
#[must_use = "losing the pointer will leak memory"]
29742975
#[stable(feature = "weak_into_raw", since = "1.45.0")]
29752976
pub fn into_raw(self) -> *const T {
29762977
let result = self.as_ptr();

library/alloc/src/sync.rs

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

0 commit comments

Comments
 (0)