Suggest mem::forget if mem::ManuallyDrop::new isn't used

I think this communicates the intent better, and is shorter anyway.
This commit is contained in:
Scott McMurray
2020-08-25 09:40:53 -07:00
parent c30341ddec
commit f3024073f9
3 changed files with 7 additions and 3 deletions

View File

@@ -145,7 +145,7 @@ pub use crate::intrinsics::transmute;
#[rustc_const_stable(feature = "const_forget", since = "1.46.0")]
#[stable(feature = "rust1", since = "1.0.0")]
pub const fn forget<T>(t: T) {
ManuallyDrop::new(t);
let _ = ManuallyDrop::new(t);
}
/// Like [`forget`], but also accepts unsized values.