about summary refs log tree commit diff
path: root/library
diff options
context:
space:
mode:
authorYuki Okushi <huyuumi.dev@gmail.com>2020-12-30 18:15:25 +0900
committerGitHub <noreply@github.com>2020-12-30 18:15:25 +0900
commit9576ee97d1f824281e34ecd531965c33bb2e9dd2 (patch)
tree300a2ac290a7cb048723a35ae6abedf9183ecf0d /library
parentbdc215a8b9bd917e8902f113a9f65afe1d25ffe2 (diff)
parent5718cc2f9b32290dc34ce320076f92d90c00fb7d (diff)
downloadrust-9576ee97d1f824281e34ecd531965c33bb2e9dd2.tar.gz
rust-9576ee97d1f824281e34ecd531965c33bb2e9dd2.zip
Rollup merge of #80477 - tmiasko:safe-forget, r=oli-obk
Make forget intrinsic safe
Diffstat (limited to 'library')
-rw-r--r--library/core/src/mem/mod.rs7
1 files changed, 6 insertions, 1 deletions
diff --git a/library/core/src/mem/mod.rs b/library/core/src/mem/mod.rs
index e84014c68a6..87956787242 100644
--- a/library/core/src/mem/mod.rs
+++ b/library/core/src/mem/mod.rs
@@ -151,9 +151,14 @@ pub const fn forget<T>(t: T) {
 #[inline]
 #[unstable(feature = "forget_unsized", issue = "none")]
 pub fn forget_unsized<T: ?Sized>(t: T) {
+    #[cfg(bootstrap)]
     // SAFETY: the forget intrinsic could be safe, but there's no point in making it safe since
     // we'll be implementing this function soon via `ManuallyDrop`
-    unsafe { intrinsics::forget(t) }
+    unsafe {
+        intrinsics::forget(t)
+    }
+    #[cfg(not(bootstrap))]
+    intrinsics::forget(t)
 }
 
 /// Returns the size of a type in bytes.