about summary refs log tree commit diff
path: root/src/test
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2014-06-27 21:11:31 +0000
committerbors <bors@rust-lang.org>2014-06-27 21:11:31 +0000
commitafdfe40aa0b7dfc7800dddbc1f55da979abfe486 (patch)
tree760cc4227c95a06522e95b520530cc7517b2ed9b /src/test
parentabdf71cf73fd8b0b5bca78da830fe6f2a49ff8c2 (diff)
parent04e64c0c91f1d0de04940eab76ddcfe126d635b1 (diff)
downloadrust-afdfe40aa0b7dfc7800dddbc1f55da979abfe486.tar.gz
rust-afdfe40aa0b7dfc7800dddbc1f55da979abfe486.zip
auto merge of #15226 : luqmana/rust/abol, r=pcwalton
This was causing a ton of leaks in macro expansion.
Diffstat (limited to 'src/test')
-rw-r--r--src/test/run-pass/cleanup-auto-borrow-obj.rs38
1 files changed, 38 insertions, 0 deletions
diff --git a/src/test/run-pass/cleanup-auto-borrow-obj.rs b/src/test/run-pass/cleanup-auto-borrow-obj.rs
new file mode 100644
index 00000000000..23142082a8c
--- /dev/null
+++ b/src/test/run-pass/cleanup-auto-borrow-obj.rs
@@ -0,0 +1,38 @@
+// Copyright 2014 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.
+
+
+// This would previously leak the Box<Trait> because we wouldn't
+// schedule cleanups when auto borrowing trait objects.
+// This program should be valgrind clean.
+
+
+static mut DROP_RAN: bool = false;
+
+struct Foo;
+impl Drop for Foo {
+    fn drop(&mut self) {
+        unsafe { DROP_RAN = true; }
+    }
+}
+
+
+trait Trait {}
+impl Trait for Foo {}
+
+pub fn main() {
+    {
+        let _x: &Trait = box Foo as Box<Trait>;
+    }
+    unsafe {
+        assert!(DROP_RAN);
+    }
+}
+