diff options
| author | bors <bors@rust-lang.org> | 2021-10-11 07:27:44 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2021-10-11 07:27:44 +0000 |
| commit | 86d6d2b7389fe1b339402c1798edae8b695fc9ef (patch) | |
| tree | 88c37951da1bbc2c46818b1705d6fa5e962eae5b /library/alloc/src/string.rs | |
| parent | 9a757817c352801de8b0593728f8aee21e23cd53 (diff) | |
| parent | b115781bcd0609e94c08192924853097c73f1a1c (diff) | |
Auto merge of #89755 - jkugelman:must-use-conversions-that-move-self, r=joshtriplett
Add #[must_use] to conversions that move self Everything here got the same message. Is the wording okay? ```rust #[must_use = "`self` will be dropped if the result is not used"] ``` I want to draw attention to these methods in particular: ```rust alloc::sync::Arc<MaybeUninit<T>> unsafe fn assume_init(self) -> Arc<T>; alloc::sync::Arc<[MaybeUninit<T>]> unsafe fn assume_init(self) -> Arc<[T]>; core::pin::Pin<&'a mut T> const fn into_ref(self) -> Pin<&'a T>; core::pin::Pin<&'a mut T> const fn get_mut(self) -> &'a mut T; core::pin::Pin<&'a mut T> const unsafe fn get_unchecked_mut(self) -> &'a mut T; core::pin::Pin<&'a mut T> unsafe fn map_unchecked_mut(self, func: F) -> Pin<&'a mut U>; core::pin::Pin<&'a mut Pin<P>> fn as_deref_mut(self) -> Pin<&'a mut P::Target>; ``` Parent issue: #89692 r? `@joshtriplett`
Diffstat (limited to 'library/alloc/src/string.rs')
| -rw-r--r-- | library/alloc/src/string.rs | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/library/alloc/src/string.rs b/library/alloc/src/string.rs index d88b8e39898..d00792b9c3e 100644 --- a/library/alloc/src/string.rs +++ b/library/alloc/src/string.rs @@ -676,6 +676,7 @@ impl String { /// let rebuilt = unsafe { String::from_raw_parts(ptr, len, cap) }; /// assert_eq!(rebuilt, "hello"); /// ``` + #[must_use = "`self` will be dropped if the result is not used"] #[unstable(feature = "vec_into_raw_parts", reason = "new API", issue = "65816")] pub fn into_raw_parts(self) -> (*mut u8, usize, usize) { self.vec.into_raw_parts() @@ -781,6 +782,7 @@ impl String { /// assert_eq!(&[104, 101, 108, 108, 111][..], &bytes[..]); /// ``` #[inline] + #[must_use = "`self` will be dropped if the result is not used"] #[stable(feature = "rust1", since = "1.0.0")] pub fn into_bytes(self) -> Vec<u8> { self.vec @@ -1738,6 +1740,7 @@ impl String { /// ``` #[cfg(not(no_global_oom_handling))] #[stable(feature = "box_str", since = "1.4.0")] + #[must_use = "`self` will be dropped if the result is not used"] #[inline] pub fn into_boxed_str(self) -> Box<str> { let slice = self.vec.into_boxed_slice(); @@ -1783,6 +1786,7 @@ impl FromUtf8Error { /// /// assert_eq!(vec![0, 159], value.unwrap_err().into_bytes()); /// ``` + #[must_use = "`self` will be dropped if the result is not used"] #[stable(feature = "rust1", since = "1.0.0")] pub fn into_bytes(self) -> Vec<u8> { self.bytes |
