Clarify/add must_use messages for more into_raw* functions of `al… · model-checking/verify-rust-std@697377a (original) (raw)

4 files changed

lines changed

Original file line number Diff line number Diff line change
@@ -1097,6 +1097,7 @@ impl<T: ?Sized, A: Allocator> Box<T, A> {
1097 1097 /// ```
1098 1098 ///
1099 1099 /// [memory layout]: self#memory-layout
1100 + #[must_use = "losing the pointer will leak memory"]
1100 1101 #[stable(feature = "box_raw", since = "1.4.0")]
1101 1102 #[inline]
1102 1103 pub fn into_raw(b: Self) -> *mut T {
@@ -1150,6 +1151,7 @@ impl<T: ?Sized, A: Allocator> Box<T, A> {
1150 1151 /// ```
1151 1152 ///
1152 1153 /// [memory layout]: self#memory-layout
1154 + #[must_use = "losing the pointer will leak memory"]
1153 1155 #[unstable(feature = "allocator_api", issue = "32838")]
1154 1156 #[inline]
1155 1157 pub fn into_raw_with_allocator(b: Self) -> (*mut T, A) {
Original file line number Diff line number Diff line change
@@ -1372,6 +1372,7 @@ impl<T: ?Sized, A: Allocator> Rc<T, A> {
1372 1372 /// let x = unsafe { Rc::from_raw_in(ptr, alloc) };
1373 1373 /// assert_eq!(&*x, "hello");
1374 1374 /// ```
1375 + #[must_use = "losing the pointer will leak memory"]
1375 1376 #[unstable(feature = "allocator_api", issue = "32838")]
1376 1377 pub fn into_raw_with_allocator(this: Self) -> (*const T, A) {
1377 1378 let this = mem::ManuallyDrop::new(this);
@@ -3100,6 +3101,7 @@ impl<T: ?Sized, A: Allocator> Weak<T, A> {
3100 3101 ///
3101 3102 /// [`from_raw_in`]: Weak::from_raw_in
3102 3103 /// [`as_ptr`]: Weak::as_ptr
3104 + #[must_use = "losing the pointer will leak memory"]
3103 3105 #[inline]
3104 3106 #[unstable(feature = "allocator_api", issue = "32838")]
3105 3107 pub fn into_raw_with_allocator(self) -> (*const T, A) {
Original file line number Diff line number Diff line change
@@ -903,7 +903,7 @@ impl String {
903 903 /// let rebuilt = unsafe { String::from_raw_parts(ptr, len, cap) };
904 904 /// assert_eq!(rebuilt, "hello");
905 905 /// ```
906 - #[must_use = "`self` will be dropped if the result is not used"]
906 + #[must_use = "losing the pointer will leak memory"]
907 907 #[unstable(feature = "vec_into_raw_parts", reason = "new API", issue = "65816")]
908 908 pub fn into_raw_parts(self) -> (*mut u8, usize, usize) {
909 909 self.vec.into_raw_parts()
Original file line number Diff line number Diff line change
@@ -879,6 +879,7 @@ impl<T, A: Allocator> Vec<T, A> {
879 879 /// };
880 880 /// assert_eq!(rebuilt, [4294967295, 0, 1]);
881 881 /// ```
882 + #[must_use = "losing the pointer will leak memory"]
882 883 #[unstable(feature = "vec_into_raw_parts", reason = "new API", issue = "65816")]
883 884 pub fn into_raw_parts(self) -> (*mut T, usize, usize) {
884 885 let mut me = ManuallyDrop::new(self);
@@ -922,6 +923,7 @@ impl<T, A: Allocator> Vec<T, A> {
922 923 /// };
923 924 /// assert_eq!(rebuilt, [4294967295, 0, 1]);
924 925 /// ```
926 + #[must_use = "losing the pointer will leak memory"]
925 927 #[unstable(feature = "allocator_api", issue = "32838")]
926 928 // #[unstable(feature = "vec_into_raw_parts", reason = "new API", issue = "65816")]
927 929 pub fn into_raw_parts_with_alloc(self) -> (*mut T, usize, usize, A) {