Fix unused_must_use warning for Box::from_raw

This commit is contained in:
Anett Seeker 2022-11-05 21:52:18 +01:00
parent 6b8d9dd0a0
commit 3b8b0ac62a
2 changed files with 2 additions and 2 deletions

View File

@ -952,7 +952,7 @@ impl<T: ?Sized> Box<T> {
/// [`Layout`]: crate::Layout /// [`Layout`]: crate::Layout
#[stable(feature = "box_raw", since = "1.4.0")] #[stable(feature = "box_raw", since = "1.4.0")]
#[inline] #[inline]
#[must_use = "call `drop(from_raw(ptr))` if you intend to drop the `Box`"] #[must_use = "call `drop(Box::from_raw(ptr))` if you intend to drop the `Box`"]
pub unsafe fn from_raw(raw: *mut T) -> Self { pub unsafe fn from_raw(raw: *mut T) -> Self {
unsafe { Self::from_raw_in(raw, Global) } unsafe { Self::from_raw_in(raw, Global) }
} }

View File

@ -4,7 +4,7 @@ warning: unused return value of `Box::<T>::from_raw` that must be used
LL | Box::from_raw(ptr); LL | Box::from_raw(ptr);
| ^^^^^^^^^^^^^^^^^^^ | ^^^^^^^^^^^^^^^^^^^
| |
= note: call `drop(from_raw(ptr))` if you intend to drop the `Box` = note: call `drop(Box::from_raw(ptr))` if you intend to drop the `Box`
note: the lint level is defined here note: the lint level is defined here
--> $DIR/must-use-box-from-raw.rs:5:9 --> $DIR/must-use-box-from-raw.rs:5:9
| |