about summary refs log tree commit diff
path: root/src/libcore/tests
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2018-07-28 14:26:16 +0000
committerbors <bors@rust-lang.org>2018-07-28 14:26:16 +0000
commit26e73dabeb7a15e0e38feb2cadca3c1f740a61d2 (patch)
tree9489ee4780c8d54342e84750241f875003fa1d24 /src/libcore/tests
parent5b465e309da475aaedcb742ef29094c82e970051 (diff)
parent4e6aea1a10a50fcde27b74edbd99db69bfae724e (diff)
downloadrust-26e73dabeb7a15e0e38feb2cadca3c1f740a61d2.tar.gz
rust-26e73dabeb7a15e0e38feb2cadca3c1f740a61d2.zip
Auto merge of #52711 - eddyb:unsized-manuallydrop, r=nikomatsakis
Change ManuallyDrop<T> to a lang item.

This PR implements the approach @RalfJung proposes in https://internals.rust-lang.org/t/pre-rfc-unions-drop-types-and-manuallydrop/8025 (lang item `struct` instead of `union`).

A followup PR can easily solve #47034 as well, by just adding a few `?Sized` to `libcore/mem.rs`.

r? @nikomatsakis
Diffstat (limited to 'src/libcore/tests')
-rw-r--r--src/libcore/tests/lib.rs1
-rw-r--r--src/libcore/tests/manually_drop.rs24
2 files changed, 25 insertions, 0 deletions
diff --git a/src/libcore/tests/lib.rs b/src/libcore/tests/lib.rs
index ca7db6e4639..6fcfaae4535 100644
--- a/src/libcore/tests/lib.rs
+++ b/src/libcore/tests/lib.rs
@@ -62,6 +62,7 @@ mod fmt;
 mod hash;
 mod intrinsics;
 mod iter;
+mod manually_drop;
 mod mem;
 mod nonzero;
 mod num;
diff --git a/src/libcore/tests/manually_drop.rs b/src/libcore/tests/manually_drop.rs
new file mode 100644
index 00000000000..96bc9247da6
--- /dev/null
+++ b/src/libcore/tests/manually_drop.rs
@@ -0,0 +1,24 @@
+// Copyright 2018 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
+// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
+// option. This file may not be copied, modified, or distributed
+// except according to those terms.
+
+use core::mem::ManuallyDrop;
+
+#[test]
+fn smoke() {
+    struct TypeWithDrop;
+    impl Drop for TypeWithDrop {
+        fn drop(&mut self) {
+            unreachable!("Should not get dropped");
+        }
+    }
+
+    let x = ManuallyDrop::new(TypeWithDrop);
+    drop(x);
+}