]> git.lizzy.rs Git - rust.git/commitdiff
add smoke test for ManuallyDrop
authorRalf Jung <post@ralfj.de>
Fri, 27 Jul 2018 10:12:55 +0000 (12:12 +0200)
committerRalf Jung <post@ralfj.de>
Fri, 27 Jul 2018 10:22:26 +0000 (12:22 +0200)
src/libcore/tests/lib.rs
src/libcore/tests/manually_drop.rs [new file with mode: 0644]

index ca7db6e4639a522cd1b9c35b6f686f3fd1f261c4..6fcfaae45350081962e8680df330892b1484c22c 100644 (file)
@@ -62,6 +62,7 @@
 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 (file)
index 0000000..96bc924
--- /dev/null
@@ -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);
+}