about summary refs log tree commit diff
path: root/src/libcore
diff options
context:
space:
mode:
authorRalf Jung <post@ralfj.de>2018-07-27 12:12:55 +0200
committerRalf Jung <post@ralfj.de>2018-07-27 12:22:26 +0200
commit5feedbd9f835efeb753ff74e699268c6edbef679 (patch)
tree7aae829d2be3959dcfda315c97cb5e705b485f07 /src/libcore
parent591eeff22af299043637e75bb5735c3c65e0c7fe (diff)
downloadrust-5feedbd9f835efeb753ff74e699268c6edbef679.tar.gz
rust-5feedbd9f835efeb753ff74e699268c6edbef679.zip
add smoke test for ManuallyDrop
Diffstat (limited to 'src/libcore')
-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);
+}