Skip to content

Commit 134c4a0

Browse files
committedMar 20, 2017
Auto merge of #39628 - arielb1:shimmir, r=eddyb
Translate shims using MIR This removes one large remaining part of old trans.
2 parents 244f893 + 5dc8548 commit 134c4a0

File tree

88 files changed

+2797
-3169
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

88 files changed

+2797
-3169
lines changed
 

‎src/libcore/intrinsics.rs

+7-1
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,13 @@
4646
issue = "0")]
4747
#![allow(missing_docs)]
4848

49-
extern "rust-intrinsic" {
49+
#[cfg(not(stage0))]
50+
#[stable(feature = "drop_in_place", since = "1.8.0")]
51+
#[rustc_deprecated(reason = "no longer an intrinsic - use `ptr::drop_in_place` directly",
52+
since = "1.18.0")]
53+
pub use ptr::drop_in_place;
5054

55+
extern "rust-intrinsic" {
5156
// NB: These intrinsics take raw pointers because they mutate aliased
5257
// memory, which is not valid for either `&` or `&mut`.
5358

@@ -622,6 +627,7 @@ extern "rust-intrinsic" {
622627
pub fn size_of_val<T: ?Sized>(_: &T) -> usize;
623628
pub fn min_align_of_val<T: ?Sized>(_: &T) -> usize;
624629

630+
#[cfg(stage0)]
625631
/// Executes the destructor (if any) of the pointed-to value.
626632
///
627633
/// This has two use cases:

‎src/libcore/ptr.rs

+29
Original file line numberDiff line numberDiff line change
@@ -37,9 +37,38 @@ pub use intrinsics::copy;
3737
#[stable(feature = "rust1", since = "1.0.0")]
3838
pub use intrinsics::write_bytes;
3939

40+
#[cfg(stage0)]
4041
#[stable(feature = "drop_in_place", since = "1.8.0")]
4142
pub use intrinsics::drop_in_place;
4243

44+
#[cfg(not(stage0))]
45+
/// Executes the destructor (if any) of the pointed-to value.
46+
///
47+
/// This has two use cases:
48+
///
49+
/// * It is *required* to use `drop_in_place` to drop unsized types like
50+
/// trait objects, because they can't be read out onto the stack and
51+
/// dropped normally.
52+
///
53+
/// * It is friendlier to the optimizer to do this over `ptr::read` when
54+
/// dropping manually allocated memory (e.g. when writing Box/Rc/Vec),
55+
/// as the compiler doesn't need to prove that it's sound to elide the
56+
/// copy.
57+
///
58+
/// # Undefined Behavior
59+
///
60+
/// This has all the same safety problems as `ptr::read` with respect to
61+
/// invalid pointers, types, and double drops.
62+
#[stable(feature = "drop_in_place", since = "1.8.0")]
63+
#[lang="drop_in_place"]
64+
#[inline]
65+
#[allow(unconditional_recursion)]
66+
pub unsafe fn drop_in_place<T: ?Sized>(to_drop: *mut T) {
67+
// Code here does not matter - this is replaced by the
68+
// real drop glue by the compiler.
69+
drop_in_place(to_drop);
70+
}
71+
4372
/// Creates a null raw pointer.
4473
///
4574
/// # Examples

0 commit comments

Comments
 (0)