diff options
| -rw-r--r-- | src/libcore/intrinsics.rs | 3 | ||||
| -rw-r--r-- | src/libcore/mem.rs | 7 | ||||
| -rw-r--r-- | src/librustc_trans/intrinsic.rs | 2 | ||||
| -rw-r--r-- | src/librustc_typeck/check/intrinsic.rs | 1 |
4 files changed, 7 insertions, 6 deletions
diff --git a/src/libcore/intrinsics.rs b/src/libcore/intrinsics.rs index e0a4707ff66..b0287631585 100644 --- a/src/libcore/intrinsics.rs +++ b/src/libcore/intrinsics.rs @@ -691,9 +691,6 @@ extern "rust-intrinsic" { /// initialize memory previous set to the result of `uninit`. pub fn uninit<T>() -> T; - /// Moves a value out of scope without running drop glue. - pub fn forget<T>(_: T) -> (); - /// Reinterprets the bits of a value of one type as another type. /// /// Both types must have the same size. Neither the original, nor the result, diff --git a/src/libcore/mem.rs b/src/libcore/mem.rs index f4a19af02a6..52ccaa417bc 100644 --- a/src/libcore/mem.rs +++ b/src/libcore/mem.rs @@ -171,7 +171,7 @@ pub use intrinsics::transmute; #[inline] #[stable(feature = "rust1", since = "1.0.0")] pub fn forget<T>(t: T) { - unsafe { intrinsics::forget(t) } + ManuallyDrop::new(t); } /// Returns the size of a type in bytes. @@ -780,12 +780,14 @@ pub union ManuallyDrop<T>{ value: T } impl<T> ManuallyDrop<T> { /// Wrap a value to be manually dropped. #[unstable(feature = "manually_drop", issue = "40673")] + #[inline] pub fn new(value: T) -> ManuallyDrop<T> { ManuallyDrop { value: value } } /// Extract the value from the ManuallyDrop container. #[unstable(feature = "manually_drop", issue = "40673")] + #[inline] pub fn into_inner(self) -> T { unsafe { self.value @@ -800,6 +802,7 @@ impl<T> ManuallyDrop<T> { /// now represents uninitialized data. It is up to the user of this method to ensure the /// uninitialized data is not actually used. #[unstable(feature = "manually_drop", issue = "40673")] + #[inline] pub unsafe fn drop(slot: &mut ManuallyDrop<T>) { ptr::drop_in_place(&mut slot.value) } @@ -808,6 +811,7 @@ impl<T> ManuallyDrop<T> { #[unstable(feature = "manually_drop", issue = "40673")] impl<T> ::ops::Deref for ManuallyDrop<T> { type Target = T; + #[inline] fn deref(&self) -> &Self::Target { unsafe { &self.value @@ -817,6 +821,7 @@ impl<T> ::ops::Deref for ManuallyDrop<T> { #[unstable(feature = "manually_drop", issue = "40673")] impl<T> ::ops::DerefMut for ManuallyDrop<T> { + #[inline] fn deref_mut(&mut self) -> &mut Self::Target { unsafe { &mut self.value diff --git a/src/librustc_trans/intrinsic.rs b/src/librustc_trans/intrinsic.rs index 5e7d612d17f..0cbc103994a 100644 --- a/src/librustc_trans/intrinsic.rs +++ b/src/librustc_trans/intrinsic.rs @@ -188,7 +188,7 @@ pub fn trans_intrinsic_call<'a, 'tcx>(bcx: &Builder<'a, 'tcx>, C_nil(ccx) } // Effectively no-ops - "uninit" | "forget" => { + "uninit" => { C_nil(ccx) } "needs_drop" => { diff --git a/src/librustc_typeck/check/intrinsic.rs b/src/librustc_typeck/check/intrinsic.rs index 2861fd28832..cd58fcd4806 100644 --- a/src/librustc_typeck/check/intrinsic.rs +++ b/src/librustc_typeck/check/intrinsic.rs @@ -124,7 +124,6 @@ pub fn check_intrinsic_type<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, "rustc_peek" => (1, vec![param(0)], param(0)), "init" => (1, Vec::new(), param(0)), "uninit" => (1, Vec::new(), param(0)), - "forget" => (1, vec![ param(0) ], tcx.mk_nil()), "transmute" => (2, vec![ param(0) ], param(1)), "move_val_init" => { (1, |
