Skip to content

Commit 515e380

Browse files
authored
Rollup merge of rust-lang#80477 - tmiasko:safe-forget, r=oli-obk
Make forget intrinsic safe
2 parents 7e071a9 + 5c258c4 commit 515e380

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

core/src/mem/mod.rs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -151,9 +151,14 @@ pub const fn forget<T>(t: T) {
151151
#[inline]
152152
#[unstable(feature = "forget_unsized", issue = "none")]
153153
pub fn forget_unsized<T: ?Sized>(t: T) {
154+
#[cfg(bootstrap)]
154155
// SAFETY: the forget intrinsic could be safe, but there's no point in making it safe since
155156
// we'll be implementing this function soon via `ManuallyDrop`
156-
unsafe { intrinsics::forget(t) }
157+
unsafe {
158+
intrinsics::forget(t)
159+
}
160+
#[cfg(not(bootstrap))]
161+
intrinsics::forget(t)
157162
}
158163

159164
/// Returns the size of a type in bytes.

0 commit comments

Comments
 (0)