diff --git a/src/test/auxiliary/issue-2526.rs b/src/test/auxiliary/issue-2526.rs index 8352c3163a2a8..d17de197e24a9 100644 --- a/src/test/auxiliary/issue-2526.rs +++ b/src/test/auxiliary/issue-2526.rs @@ -9,7 +9,10 @@ export context; struct arc_destruct { _data: int, - drop {} +} + +impl arc_destruct : Drop { + fn finalize() {} } fn arc_destruct(data: int) -> arc_destruct { @@ -28,8 +31,10 @@ fn init() -> arc_destruct unsafe { struct context_res { ctx : int, +} - drop { } +impl context_res : Drop { + fn finalize() {} } fn context_res() -> context_res { diff --git a/src/test/auxiliary/issue-3012-1.rs b/src/test/auxiliary/issue-3012-1.rs index d774669cd1326..ba123cf5254e1 100644 --- a/src/test/auxiliary/issue-3012-1.rs +++ b/src/test/auxiliary/issue-3012-1.rs @@ -9,7 +9,12 @@ export socket_handle; struct socket_handle { sockfd: libc::c_int, - drop { /* c::close(self.sockfd); */ } +} + +impl socket_handle : Drop { + fn finalize() { + /* c::close(self.sockfd); */ + } } fn socket_handle(x: libc::c_int) -> socket_handle { diff --git a/src/test/auxiliary/issue2170lib.rs b/src/test/auxiliary/issue2170lib.rs index 50af402a12c84..3ce738fd5e0c6 100644 --- a/src/test/auxiliary/issue2170lib.rs +++ b/src/test/auxiliary/issue2170lib.rs @@ -5,11 +5,16 @@ fn foo(_x: i32) { struct rsrc { x: i32, - drop { foo(self.x); } +} + +impl rsrc : Drop { + fn finalize() { + foo(self.x); + } } fn rsrc(x: i32) -> rsrc { rsrc { x: x } -} \ No newline at end of file +} diff --git a/src/test/auxiliary/test_comm.rs b/src/test/auxiliary/test_comm.rs index 18960d0ad8aa2..9664dc24c3335 100644 --- a/src/test/auxiliary/test_comm.rs +++ b/src/test/auxiliary/test_comm.rs @@ -29,23 +29,28 @@ fn port() -> port { struct port_ptr { po: *rust_port, - drop unsafe { - debug!("in the port_ptr destructor"); - do task::unkillable { - let yield = 0u; - let yieldp = ptr::addr_of(&yield); - rustrt::rust_port_begin_detach(self.po, yieldp); - if yield != 0u { - task::yield(); - } - rustrt::rust_port_end_detach(self.po); +} - while rustrt::rust_port_size(self.po) > 0u as size_t { - recv_::(self.po); +impl port_ptr : Drop { + fn finalize() { + unsafe { + debug!("in the port_ptr destructor"); + do task::unkillable { + let yield = 0u; + let yieldp = ptr::addr_of(&yield); + rustrt::rust_port_begin_detach(self.po, yieldp); + if yield != 0u { + task::yield(); + } + rustrt::rust_port_end_detach(self.po); + + while rustrt::rust_port_size(self.po) > 0u as size_t { + recv_::(self.po); + } + rustrt::del_port(self.po); + } } - rustrt::del_port(self.po); } - } } fn port_ptr(po: *rust_port) -> port_ptr { diff --git a/src/test/bench/task-perf-alloc-unwind.rs b/src/test/bench/task-perf-alloc-unwind.rs index 55d75ff7c82d3..65fb9ec173918 100644 --- a/src/test/bench/task-perf-alloc-unwind.rs +++ b/src/test/bench/task-perf-alloc-unwind.rs @@ -42,7 +42,10 @@ enum st { struct r { _l: @nillist, - drop {} +} + +impl r : Drop { + fn finalize() {} } fn r(l: @nillist) -> r { diff --git a/src/test/compile-fail/bind-by-move-neither-can-live-while-the-other-survives-1.rs b/src/test/compile-fail/bind-by-move-neither-can-live-while-the-other-survives-1.rs index 8a518edf73601..1f7989d1ae935 100644 --- a/src/test/compile-fail/bind-by-move-neither-can-live-while-the-other-survives-1.rs +++ b/src/test/compile-fail/bind-by-move-neither-can-live-while-the-other-survives-1.rs @@ -1,4 +1,10 @@ -struct X { x: (), drop { error!("destructor runs"); } } +struct X { x: () } + +impl X : Drop { + fn finalize() { + error!("destructor runs"); + } +} fn main() { let x = Some(X { x: () }); diff --git a/src/test/compile-fail/bind-by-move-neither-can-live-while-the-other-survives-2.rs b/src/test/compile-fail/bind-by-move-neither-can-live-while-the-other-survives-2.rs index b99d4197848f8..598fc4b0a0805 100644 --- a/src/test/compile-fail/bind-by-move-neither-can-live-while-the-other-survives-2.rs +++ b/src/test/compile-fail/bind-by-move-neither-can-live-while-the-other-survives-2.rs @@ -1,4 +1,10 @@ -struct X { x: (), drop { error!("destructor runs"); } } +struct X { x: (), } + +impl X : Drop { + fn finalize() { + error!("destructor runs"); + } +} fn main() { let x = Some((X { x: () }, X { x: () })); diff --git a/src/test/compile-fail/bind-by-move-neither-can-live-while-the-other-survives-3.rs b/src/test/compile-fail/bind-by-move-neither-can-live-while-the-other-survives-3.rs index 496ec09513b11..1cd62e9288922 100644 --- a/src/test/compile-fail/bind-by-move-neither-can-live-while-the-other-survives-3.rs +++ b/src/test/compile-fail/bind-by-move-neither-can-live-while-the-other-survives-3.rs @@ -1,4 +1,10 @@ -struct X { x: (), drop { error!("destructor runs"); } } +struct X { x: (), } + +impl X : Drop { + fn finalize() { + error!("destructor runs"); + } +} enum double_option { some2(T,U), none2 } diff --git a/src/test/compile-fail/bind-by-move-neither-can-live-while-the-other-survives-4.rs b/src/test/compile-fail/bind-by-move-neither-can-live-while-the-other-survives-4.rs index 93096751d5cf9..3cd6c45af0b8a 100644 --- a/src/test/compile-fail/bind-by-move-neither-can-live-while-the-other-survives-4.rs +++ b/src/test/compile-fail/bind-by-move-neither-can-live-while-the-other-survives-4.rs @@ -1,4 +1,10 @@ -struct X { x: (), drop { error!("destructor runs"); } } +struct X { x: (), } + +impl X : Drop { + fn finalize() { + error!("destructor runs"); + } +} fn main() { let x = Some((X { x: () }, X { x: () })); diff --git a/src/test/compile-fail/bind-by-move-no-lvalues-1.rs b/src/test/compile-fail/bind-by-move-no-lvalues-1.rs index 8e881d1d42958..29d21ee670d8b 100644 --- a/src/test/compile-fail/bind-by-move-no-lvalues-1.rs +++ b/src/test/compile-fail/bind-by-move-no-lvalues-1.rs @@ -1,4 +1,10 @@ -struct X { x: (), drop { error!("destructor runs"); } } +struct X { x: (), } + +impl X : Drop { + fn finalize() { + error!("destructor runs"); + } +} fn main() { let x = Some(X { x: () }); diff --git a/src/test/compile-fail/bind-by-move-no-lvalues-2.rs b/src/test/compile-fail/bind-by-move-no-lvalues-2.rs index f65f5f0de6154..b1b38b587e869 100644 --- a/src/test/compile-fail/bind-by-move-no-lvalues-2.rs +++ b/src/test/compile-fail/bind-by-move-no-lvalues-2.rs @@ -1,4 +1,11 @@ -struct X { x: (), drop { error!("destructor runs"); } } +struct X { x: (), } + +impl X : Drop { + fn finalize() { + error!("destructor runs"); + } +} + struct Y { y: Option } fn main() { diff --git a/src/test/compile-fail/bind-by-move-no-sub-bindings.rs b/src/test/compile-fail/bind-by-move-no-sub-bindings.rs index 1a511ccef53cb..2a36d9e0db6f6 100644 --- a/src/test/compile-fail/bind-by-move-no-sub-bindings.rs +++ b/src/test/compile-fail/bind-by-move-no-sub-bindings.rs @@ -1,4 +1,10 @@ -struct X { x: (), drop { error!("destructor runs"); } } +struct X { x: (), } + +impl X : Drop { + fn finalize() { + error!("destructor runs"); + } +} fn main() { let x = Some(X { x: () }); diff --git a/src/test/compile-fail/block-must-not-have-result-res.rs b/src/test/compile-fail/block-must-not-have-result-res.rs index 3ab4a6a72f278..a282352123426 100644 --- a/src/test/compile-fail/block-must-not-have-result-res.rs +++ b/src/test/compile-fail/block-must-not-have-result-res.rs @@ -1,8 +1,12 @@ // error-pattern:mismatched types: expected `()` but found `bool` -struct r { - drop { true } +struct r {} + +impl r : Drop { + fn finalize() { + true + } } fn main() { -} \ No newline at end of file +} diff --git a/src/test/compile-fail/borrowck-borrowed-uniq-rvalue-2.rs b/src/test/compile-fail/borrowck-borrowed-uniq-rvalue-2.rs index 6cd22b7f53502..4920a0239a577 100644 --- a/src/test/compile-fail/borrowck-borrowed-uniq-rvalue-2.rs +++ b/src/test/compile-fail/borrowck-borrowed-uniq-rvalue-2.rs @@ -1,6 +1,11 @@ struct defer { x: &[&str], - drop { error!("%?", self.x); } +} + +impl defer : Drop { + fn finalize() { + error!("%?", self.x); + } } fn defer(x: &r/[&r/str]) -> defer/&r { diff --git a/src/test/compile-fail/borrowck-unary-move-2.rs b/src/test/compile-fail/borrowck-unary-move-2.rs index 1d1595383ee7f..b8fcf695c3fdc 100644 --- a/src/test/compile-fail/borrowck-unary-move-2.rs +++ b/src/test/compile-fail/borrowck-unary-move-2.rs @@ -1,5 +1,11 @@ struct noncopyable { - i: (), drop { error!("dropped"); } + i: (), +} + +impl noncopyable : Drop { + fn finalize() { + error!("dropped"); + } } fn noncopyable() -> noncopyable { diff --git a/src/test/compile-fail/cap-clause-illegal-cap.rs b/src/test/compile-fail/cap-clause-illegal-cap.rs index c5c3ff034dfc6..be630ec851810 100644 --- a/src/test/compile-fail/cap-clause-illegal-cap.rs +++ b/src/test/compile-fail/cap-clause-illegal-cap.rs @@ -1,6 +1,10 @@ // error-pattern: copying a noncopyable value -struct foo { x: int, drop { } } +struct foo { x: int, } + +impl foo : Drop { + fn finalize() {} +} fn foo(x: int) -> foo { foo { diff --git a/src/test/compile-fail/copy-a-resource.rs b/src/test/compile-fail/copy-a-resource.rs index dc9237e631800..9f86b9e894a58 100644 --- a/src/test/compile-fail/copy-a-resource.rs +++ b/src/test/compile-fail/copy-a-resource.rs @@ -2,7 +2,10 @@ struct foo { i: int, - drop {} +} + +impl foo : Drop { + fn finalize() {} } fn foo(i:int) -> foo { diff --git a/src/test/compile-fail/disallowed-deconstructing-destructing-struct.rs b/src/test/compile-fail/disallowed-deconstructing-destructing-struct.rs index 0ee8bf0c7c7dc..407b786016d60 100644 --- a/src/test/compile-fail/disallowed-deconstructing-destructing-struct.rs +++ b/src/test/compile-fail/disallowed-deconstructing-destructing-struct.rs @@ -1,6 +1,9 @@ struct X { x: ~str, - drop { +} + +impl X : Drop { + fn finalize() { error!("value: %s", self.x); } } diff --git a/src/test/compile-fail/functional-struct-update.rs b/src/test/compile-fail/functional-struct-update.rs index 8d7913a62faa7..13012f146bf28 100644 --- a/src/test/compile-fail/functional-struct-update.rs +++ b/src/test/compile-fail/functional-struct-update.rs @@ -1,6 +1,11 @@ struct Bar { x: int, - drop { io::println("Goodbye, cruel world"); } +} + +impl Bar : Drop { + fn finalize() { + io::println("Goodbye, cruel world"); + } } struct Foo { diff --git a/src/test/compile-fail/issue-2487-b.rs b/src/test/compile-fail/issue-2487-b.rs index acf85de8bd707..5476ab240007f 100644 --- a/src/test/compile-fail/issue-2487-b.rs +++ b/src/test/compile-fail/issue-2487-b.rs @@ -1,7 +1,9 @@ struct socket { sock: int, +} - drop { } +impl socket : Drop { + fn finalize() {} } impl socket { diff --git a/src/test/compile-fail/issue-2548.rs b/src/test/compile-fail/issue-2548.rs index 33886b289347f..5567e5855e47b 100644 --- a/src/test/compile-fail/issue-2548.rs +++ b/src/test/compile-fail/issue-2548.rs @@ -4,7 +4,10 @@ struct foo { x: @mut int, - drop { +} + +impl foo : Drop { + fn finalize() { io::println("Goodbye, World!"); *self.x += 1; } diff --git a/src/test/compile-fail/issue-2587-2.rs b/src/test/compile-fail/issue-2587-2.rs index 576496e736c26..375da3849f8bf 100644 --- a/src/test/compile-fail/issue-2587-2.rs +++ b/src/test/compile-fail/issue-2587-2.rs @@ -11,7 +11,10 @@ fn bar(+_t: T) { fail; } struct S { x: int, - drop {} +} + +impl S : Drop { + fn finalize() {} } fn S(x: int) -> S { S { x: x } } diff --git a/src/test/compile-fail/issue-2823.rs b/src/test/compile-fail/issue-2823.rs index 67e028dcd46d3..5b02a6da45892 100644 --- a/src/test/compile-fail/issue-2823.rs +++ b/src/test/compile-fail/issue-2823.rs @@ -1,6 +1,9 @@ struct C { x: int, - drop { +} + +impl C : Drop { + fn finalize() { error!("dropping: %?", self.x); } } @@ -9,4 +12,4 @@ fn main() { let c = C{ x: 2}; let d = copy c; //~ ERROR copying a noncopyable value error!("%?", d.x); -} \ No newline at end of file +} diff --git a/src/test/compile-fail/issue-2825-b.rs b/src/test/compile-fail/issue-2825-b.rs deleted file mode 100644 index 5ddb6b5f7041b..0000000000000 --- a/src/test/compile-fail/issue-2825-b.rs +++ /dev/null @@ -1,17 +0,0 @@ -struct example { - x: int, - drop {} //~ ERROR First destructor declared - drop { - debug!("Goodbye, cruel world"); - } -} - -fn example() -> example { - example { - x: 1 - } -} - -fn main(_args: ~[~str]) { - let e: example = example(); -} diff --git a/src/test/compile-fail/issue-3214.rs b/src/test/compile-fail/issue-3214.rs index 7008f8c4ce293..9e38c39bb72a3 100644 --- a/src/test/compile-fail/issue-3214.rs +++ b/src/test/compile-fail/issue-3214.rs @@ -2,7 +2,10 @@ fn foo() { struct foo { mut x: T, //~ ERROR attempt to use a type argument out of scope //~^ ERROR use of undeclared type name - drop { } + } + + impl foo : Drop { + fn finalize() {} } } fn main() { } diff --git a/src/test/compile-fail/liveness-unused.rs b/src/test/compile-fail/liveness-unused.rs index 473a133730a4f..3aaaa2ef16fd0 100644 --- a/src/test/compile-fail/liveness-unused.rs +++ b/src/test/compile-fail/liveness-unused.rs @@ -50,8 +50,12 @@ fn f4b() -> int { // leave this in here just to trigger compile-fail: struct r { x: (), - drop {} } + +impl r : Drop { + fn finalize() {} +} + fn main() { let x = r { x: () }; fn@(move x) { copy x; }; //~ ERROR copying a noncopyable value diff --git a/src/test/compile-fail/no-send-res-ports.rs b/src/test/compile-fail/no-send-res-ports.rs index d0455f4d8a98b..7f5c7e1f59b5f 100644 --- a/src/test/compile-fail/no-send-res-ports.rs +++ b/src/test/compile-fail/no-send-res-ports.rs @@ -1,7 +1,10 @@ fn main() { struct foo { _x: comm::Port<()>, - drop {} + } + + impl foo : Drop { + fn finalize() {} } fn foo(x: comm::Port<()>) -> foo { diff --git a/src/test/compile-fail/non-const.rs b/src/test/compile-fail/non-const.rs index d2cf08fc8471b..084b357561acd 100644 --- a/src/test/compile-fail/non-const.rs +++ b/src/test/compile-fail/non-const.rs @@ -4,7 +4,10 @@ fn foo(_x: T) { } struct r { x:int, - drop {} +} + +impl r : Drop { + fn finalize() {} } fn r(x:int) -> r { @@ -15,7 +18,10 @@ fn r(x:int) -> r { struct r2 { x:@mut int, - drop {} +} + +impl r2 : Drop { + fn finalize() {} } fn r2(x:@mut int) -> r2 { diff --git a/src/test/compile-fail/noncopyable-class.rs b/src/test/compile-fail/noncopyable-class.rs index af43fe66b4b30..0d56867225d6d 100644 --- a/src/test/compile-fail/noncopyable-class.rs +++ b/src/test/compile-fail/noncopyable-class.rs @@ -4,7 +4,10 @@ // copied struct bar { x: int, - drop {} +} + +impl bar : Drop { + fn finalize() {} } fn bar(x:int) -> bar { diff --git a/src/test/compile-fail/pinned-deep-copy.rs b/src/test/compile-fail/pinned-deep-copy.rs index d17d0c7e911cb..c95e2f0b54d1e 100644 --- a/src/test/compile-fail/pinned-deep-copy.rs +++ b/src/test/compile-fail/pinned-deep-copy.rs @@ -2,7 +2,12 @@ struct r { i: @mut int, - drop { *(self.i) = *(self.i) + 1; } +} + +impl r : Drop { + fn finalize() { + *(self.i) = *(self.i) + 1; + } } fn r(i: @mut int) -> r { @@ -20,4 +25,4 @@ fn main() { log(debug, x); } log(error, *i); -} \ No newline at end of file +} diff --git a/src/test/compile-fail/record-with-resource.rs b/src/test/compile-fail/record-with-resource.rs index 15821b21c4d33..6bcac8f56e0a6 100644 --- a/src/test/compile-fail/record-with-resource.rs +++ b/src/test/compile-fail/record-with-resource.rs @@ -2,7 +2,12 @@ struct my_resource { x: int, - drop { log(error, self.x); } +} + +impl my_resource : Drop { + fn finalize() { + log(error, self.x); + } } fn my_resource(x: int) -> my_resource { diff --git a/src/test/compile-fail/regions-in-rsrcs.rs b/src/test/compile-fail/regions-in-rsrcs.rs index 1380eed2fe911..cce998bea2db7 100644 --- a/src/test/compile-fail/regions-in-rsrcs.rs +++ b/src/test/compile-fail/regions-in-rsrcs.rs @@ -1,16 +1,25 @@ struct yes0 { x: &uint, - drop {} +} + +impl yes0 : Drop { + fn finalize() {} } struct yes1 { x: &self/uint, - drop {} +} + +impl yes1 : Drop { + fn finalize() {} } struct yes2 { x: &foo/uint, //~ ERROR named regions other than `self` are not allowed as part of a type declaration - drop {} } -fn main() {} \ No newline at end of file +impl yes2 : Drop { + fn finalize() {} +} + +fn main() {} diff --git a/src/test/compile-fail/repeat-to-run-dtor-twice.rs b/src/test/compile-fail/repeat-to-run-dtor-twice.rs index a028e7c1e3764..fb5b2509cb890 100644 --- a/src/test/compile-fail/repeat-to-run-dtor-twice.rs +++ b/src/test/compile-fail/repeat-to-run-dtor-twice.rs @@ -4,7 +4,10 @@ struct Foo { x: int, - drop { +} + +impl Foo : Drop { + fn finalize() { io::println("Goodbye!"); } } diff --git a/src/test/compile-fail/unique-object-noncopyable.rs b/src/test/compile-fail/unique-object-noncopyable.rs index 2d4c391841bf4..32739a1075ae2 100644 --- a/src/test/compile-fail/unique-object-noncopyable.rs +++ b/src/test/compile-fail/unique-object-noncopyable.rs @@ -4,7 +4,10 @@ trait Foo { struct Bar { x: int, - drop {} +} + +impl Bar : Drop { + fn finalize() {} } impl Bar : Foo { diff --git a/src/test/compile-fail/unique-pinned-nocopy.rs b/src/test/compile-fail/unique-pinned-nocopy.rs index 83d1b8393e854..6a665c2924037 100644 --- a/src/test/compile-fail/unique-pinned-nocopy.rs +++ b/src/test/compile-fail/unique-pinned-nocopy.rs @@ -2,11 +2,14 @@ struct r { b:bool, - drop {} +} + +impl r : Drop { + fn finalize() {} } fn main() { let i = move ~r { b: true }; let j = i; log(debug, i); -} \ No newline at end of file +} diff --git a/src/test/compile-fail/unique-vec-res.rs b/src/test/compile-fail/unique-vec-res.rs index c89a61f12205c..157b4435d077e 100644 --- a/src/test/compile-fail/unique-vec-res.rs +++ b/src/test/compile-fail/unique-vec-res.rs @@ -2,7 +2,12 @@ struct r { i: @mut int, - drop { *(self.i) = *(self.i) + 1; } +} + +impl r : Drop { + fn finalize() { + *(self.i) = *(self.i) + 1; + } } fn f(+i: ~[T], +j: ~[T]) { @@ -17,4 +22,4 @@ fn main() { f(r1, r2); log(debug, (r2, *i1)); log(debug, (r1, *i2)); -} \ No newline at end of file +} diff --git a/src/test/compile-fail/vec-res-add.rs b/src/test/compile-fail/vec-res-add.rs index 737f0382b6260..2978b4dc32f40 100644 --- a/src/test/compile-fail/vec-res-add.rs +++ b/src/test/compile-fail/vec-res-add.rs @@ -4,7 +4,10 @@ struct r { let i:int; new(i:int) {self.i = i;} - drop {} +} + +impl r : Drop { + fn finalize() {} } fn main() { diff --git a/src/test/run-fail/issue-2061.rs b/src/test/run-fail/issue-2061.rs index e6e18089d9036..bed54138acb4e 100644 --- a/src/test/run-fail/issue-2061.rs +++ b/src/test/run-fail/issue-2061.rs @@ -2,7 +2,10 @@ // error-pattern: ran out of stack struct R { b: int, - drop { +} + +impl R : Drop { + fn finalize() { let _y = R { b: self.b }; } } diff --git a/src/test/run-fail/morestack2.rs b/src/test/run-fail/morestack2.rs index d0b6f727b64a5..29ea363ecaea8 100644 --- a/src/test/run-fail/morestack2.rs +++ b/src/test/run-fail/morestack2.rs @@ -23,14 +23,17 @@ fn getbig_call_c_and_fail(i: int) { struct and_then_get_big_again { x:int, - drop { - fn getbig(i: int) { - if i != 0 { - getbig(i - 1); +} + +impl and_then_get_big_again : Drop { + fn finalize() { + fn getbig(i: int) { + if i != 0 { + getbig(i - 1); + } } + getbig(10000); } - getbig(10000); - } } fn and_then_get_big_again(x:int) -> and_then_get_big_again { @@ -44,4 +47,4 @@ fn main() { let r = and_then_get_big_again(4); getbig_call_c_and_fail(10000); }; -} \ No newline at end of file +} diff --git a/src/test/run-fail/morestack3.rs b/src/test/run-fail/morestack3.rs index 120d70d9f928c..9d021b96226c4 100644 --- a/src/test/run-fail/morestack3.rs +++ b/src/test/run-fail/morestack3.rs @@ -15,14 +15,17 @@ fn getbig_and_fail(&&i: int) { struct and_then_get_big_again { x:int, - drop { - fn getbig(i: int) { - if i != 0 { - getbig(i - 1); +} + +impl and_then_get_big_again : Drop { + fn finalize() { + fn getbig(i: int) { + if i != 0 { + getbig(i - 1); + } } + getbig(100); } - getbig(100); - } } fn and_then_get_big_again(x:int) -> and_then_get_big_again { @@ -35,4 +38,4 @@ fn main() { do task::spawn { getbig_and_fail(400); }; -} \ No newline at end of file +} diff --git a/src/test/run-fail/morestack4.rs b/src/test/run-fail/morestack4.rs index 358e59a1265d0..fac54ae250770 100644 --- a/src/test/run-fail/morestack4.rs +++ b/src/test/run-fail/morestack4.rs @@ -15,7 +15,10 @@ fn getbig_and_fail(&&i: int) { struct and_then_get_big_again { x:int, - drop {} +} + +impl and_then_get_big_again : Drop { + fn finalize() {} } fn and_then_get_big_again(x:int) -> and_then_get_big_again { @@ -28,4 +31,4 @@ fn main() { do task::spawn { getbig_and_fail(1); }; -} \ No newline at end of file +} diff --git a/src/test/run-fail/rt-set-exit-status-fail2.rs b/src/test/run-fail/rt-set-exit-status-fail2.rs index 4551830f5fab5..d8c5662e193ae 100644 --- a/src/test/run-fail/rt-set-exit-status-fail2.rs +++ b/src/test/run-fail/rt-set-exit-status-fail2.rs @@ -2,12 +2,15 @@ struct r { x:int, - // Setting the exit status after the runtime has already - // failed has no effect and the process exits with the - // runtime's exit code - drop { - os::set_exit_status(50); - } +} + +// Setting the exit status after the runtime has already +// failed has no effect and the process exits with the +// runtime's exit code +impl r : Drop { + fn finalize() { + os::set_exit_status(50); + } } fn r(x:int) -> r { @@ -22,4 +25,4 @@ fn main() { let i = r(5); }; fail; -} \ No newline at end of file +} diff --git a/src/test/run-fail/unwind-box-res.rs b/src/test/run-fail/unwind-box-res.rs index ca85aa9701734..d9e347079f42c 100644 --- a/src/test/run-fail/unwind-box-res.rs +++ b/src/test/run-fail/unwind-box-res.rs @@ -6,9 +6,14 @@ fn failfn() { struct r { v: *int, - drop unsafe { - let _v2: ~int = cast::reinterpret_cast(&self.v); - } +} + +impl r : Drop { + fn finalize() { + unsafe { + let _v2: ~int = cast::reinterpret_cast(&self.v); + } + } } fn r(v: *int) -> r { @@ -24,4 +29,4 @@ fn main() unsafe { let x = @r(i1p); failfn(); log(error, x); -} \ No newline at end of file +} diff --git a/src/test/run-fail/unwind-resource-fail.rs b/src/test/run-fail/unwind-resource-fail.rs index 076f1280f9669..fd7cb4a3d62ca 100644 --- a/src/test/run-fail/unwind-resource-fail.rs +++ b/src/test/run-fail/unwind-resource-fail.rs @@ -9,4 +9,4 @@ class r { fn main() { @0; let r = move r(0); -} \ No newline at end of file +} diff --git a/src/test/run-fail/unwind-resource-fail3.rs b/src/test/run-fail/unwind-resource-fail3.rs index c7eeec2e5480a..0be7f5cfe8b5c 100644 --- a/src/test/run-fail/unwind-resource-fail3.rs +++ b/src/test/run-fail/unwind-resource-fail3.rs @@ -5,7 +5,12 @@ class faily_box { let i: @int; new(i: @int) { self.i = i; } // What happens to the box pointer owned by this class? - drop { fail "quux"; } +} + +impl faily_box : Drop { + fn finalize() { + fail "quux"; + } } fn main() { diff --git a/src/test/run-pass/class-attributes-1.rs b/src/test/run-pass/class-attributes-1.rs index 0c89ecaf916dc..f3f887230d24d 100644 --- a/src/test/run-pass/class-attributes-1.rs +++ b/src/test/run-pass/class-attributes-1.rs @@ -1,11 +1,15 @@ // pp-exact - Make sure we actually print the attributes struct cat { - #[cat_dropper] - drop { error!("%s landed on hir feet",self.name); } name: ~str, } +impl cat: Drop { + #[cat_dropper] + fn finalize() { error!("%s landed on hir feet",self.name); } +} + + #[cat_maker] fn cat(name: ~str) -> cat { cat{name: name,} } diff --git a/src/test/run-pass/class-attributes-2.rs b/src/test/run-pass/class-attributes-2.rs index 4709b2c5b5b9d..5bcec8d3b0d74 100644 --- a/src/test/run-pass/class-attributes-2.rs +++ b/src/test/run-pass/class-attributes-2.rs @@ -1,10 +1,15 @@ struct cat { name: ~str, - #[cat_dropper] - /** - Actually, cats don't always land on their feet when you drop them. - */ - drop { error!("%s landed on hir feet", self.name); } +} + +impl cat : Drop { + #[cat_dropper] + /** + Actually, cats don't always land on their feet when you drop them. + */ + fn finalize() { + error!("%s landed on hir feet", self.name); + } } #[cat_maker] diff --git a/src/test/run-pass/class-dtor.rs b/src/test/run-pass/class-dtor.rs index 5fa8a71aa54f4..318392921d873 100644 --- a/src/test/run-pass/class-dtor.rs +++ b/src/test/run-pass/class-dtor.rs @@ -1,7 +1,12 @@ struct cat { done : extern fn(uint), meows : uint, - drop { self.done(self.meows); } +} + +impl cat : Drop { + fn finalize() { + self.done(self.meows); + } } fn cat(done: extern fn(uint)) -> cat { diff --git a/src/test/run-pass/init-res-into-things.rs b/src/test/run-pass/init-res-into-things.rs index ca03c0736a2d0..04520d925b1c3 100644 --- a/src/test/run-pass/init-res-into-things.rs +++ b/src/test/run-pass/init-res-into-things.rs @@ -3,7 +3,12 @@ struct r { i: @mut int, - drop { *(self.i) = *(self.i) + 1; } +} + +impl r : Drop { + fn finalize() { + *(self.i) = *(self.i) + 1; + } } fn r(i: @mut int) -> r { diff --git a/src/test/run-pass/issue-2487-a.rs b/src/test/run-pass/issue-2487-a.rs index 8a21f128a9916..15c46ffbaf875 100644 --- a/src/test/run-pass/issue-2487-a.rs +++ b/src/test/run-pass/issue-2487-a.rs @@ -1,7 +1,10 @@ struct socket { sock: int, - drop { } +} + +impl socket : Drop { + fn finalize() {} } impl socket { diff --git a/src/test/run-pass/issue-2708.rs b/src/test/run-pass/issue-2708.rs index b2651045e5299..aefcca9004b9e 100644 --- a/src/test/run-pass/issue-2708.rs +++ b/src/test/run-pass/issue-2708.rs @@ -3,7 +3,10 @@ struct Font { cairo_font: uint, font_dtor: uint, - drop { } +} + +impl Font : Drop { + fn finalize() {} } fn Font() -> Font { diff --git a/src/test/run-pass/issue-2718.rs b/src/test/run-pass/issue-2718.rs index ebc601245963d..14ac611e720f1 100644 --- a/src/test/run-pass/issue-2718.rs +++ b/src/test/run-pass/issue-2718.rs @@ -141,7 +141,10 @@ mod pipes { struct send_packet { mut p: Option<*packet>, - drop { + } + + impl send_packet : Drop { + fn finalize() { if self.p != None { let mut p = None; p <-> self.p; @@ -166,7 +169,10 @@ mod pipes { struct recv_packet { mut p: Option<*packet>, - drop { + } + + impl recv_packet : Drop { + fn finalize() { if self.p != None { let mut p = None; p <-> self.p; diff --git a/src/test/run-pass/issue-2735-2.rs b/src/test/run-pass/issue-2735-2.rs index a0406d2735f35..86458989ffd0a 100644 --- a/src/test/run-pass/issue-2735-2.rs +++ b/src/test/run-pass/issue-2735-2.rs @@ -1,7 +1,12 @@ // This test should behave exactly like issue-2735-3 struct defer { b: &mut bool, - drop { *(self.b) = true; } +} + +impl defer : Drop { + fn finalize() { + *(self.b) = true; + } } fn defer(b: &r/mut bool) -> defer/&r { diff --git a/src/test/run-pass/issue-2735-3.rs b/src/test/run-pass/issue-2735-3.rs index 8e4fea9349123..4a93de936bc0b 100644 --- a/src/test/run-pass/issue-2735-3.rs +++ b/src/test/run-pass/issue-2735-3.rs @@ -1,7 +1,12 @@ // This test should behave exactly like issue-2735-2 struct defer { b: &mut bool, - drop { *(self.b) = true; } +} + +impl defer : Drop { + fn finalize() { + *(self.b) = true; + } } fn defer(b: &r/mut bool) -> defer/&r { diff --git a/src/test/run-pass/issue-2895.rs b/src/test/run-pass/issue-2895.rs index 1765e8638a637..d15edccaa1830 100644 --- a/src/test/run-pass/issue-2895.rs +++ b/src/test/run-pass/issue-2895.rs @@ -7,7 +7,10 @@ struct Cat { struct Kitty { x: int, - drop {} +} + +impl Kitty : Drop { + fn finalize() {} } #[cfg(target_arch = "x86_64")] diff --git a/src/test/run-pass/issue-3220.rs b/src/test/run-pass/issue-3220.rs index eb3eddd2681d0..273db8505a1ab 100644 --- a/src/test/run-pass/issue-3220.rs +++ b/src/test/run-pass/issue-3220.rs @@ -1,4 +1,9 @@ -struct thing { x: int, drop { } } +struct thing { x: int, } + +impl thing : Drop { + fn finalize() {} +} + fn thing() -> thing { thing { x: 0 diff --git a/src/test/run-pass/issue-979.rs b/src/test/run-pass/issue-979.rs index 9b1aa574e9129..970afb0597ecf 100644 --- a/src/test/run-pass/issue-979.rs +++ b/src/test/run-pass/issue-979.rs @@ -1,6 +1,11 @@ struct r { b: @mut int, - drop { *(self.b) += 1; } +} + +impl r : Drop { + fn finalize() { + *(self.b) += 1; + } } fn r(b: @mut int) -> r { @@ -16,4 +21,4 @@ fn main() { } assert *b == 1; -} \ No newline at end of file +} diff --git a/src/test/run-pass/option-unwrap.rs b/src/test/run-pass/option-unwrap.rs index 7481b06d873df..d2ae1e02a41d3 100644 --- a/src/test/run-pass/option-unwrap.rs +++ b/src/test/run-pass/option-unwrap.rs @@ -1,7 +1,10 @@ struct dtor { x: @mut int, - drop { +} + +impl dtor : Drop { + fn finalize() { // abuse access to shared mutable state to write this code *self.x -= 1; } @@ -23,4 +26,4 @@ fn main() { } assert *x == 0; -} \ No newline at end of file +} diff --git a/src/test/run-pass/pipe-presentation-examples.rs b/src/test/run-pass/pipe-presentation-examples.rs index cd5fcaabf5cb4..06c1734a28f73 100644 --- a/src/test/run-pass/pipe-presentation-examples.rs +++ b/src/test/run-pass/pipe-presentation-examples.rs @@ -66,7 +66,10 @@ macro_rules! select ( struct Buffer { foo: (), - drop { } +} + +impl Buffer : Drop { + fn finalize() {} } proto! double_buffer ( diff --git a/src/test/run-pass/resource-assign-is-not-copy.rs b/src/test/run-pass/resource-assign-is-not-copy.rs index f0bea875df90c..522392d99add9 100644 --- a/src/test/run-pass/resource-assign-is-not-copy.rs +++ b/src/test/run-pass/resource-assign-is-not-copy.rs @@ -1,6 +1,11 @@ struct r { i: @mut int, - drop { *(self.i) += 1; } +} + +impl r : Drop { + fn finalize() { + *(self.i) += 1; + } } fn r(i: @mut int) -> r { diff --git a/src/test/run-pass/resource-cycle.rs b/src/test/run-pass/resource-cycle.rs index 893042842d091..6b637e668edc4 100644 --- a/src/test/run-pass/resource-cycle.rs +++ b/src/test/run-pass/resource-cycle.rs @@ -2,12 +2,18 @@ struct r { v: *int, - drop unsafe { - debug!("r's dtor: self = %x, self.v = %x, self.v's value = %x", - cast::reinterpret_cast::<*r, uint>(&ptr::addr_of(&self)), - cast::reinterpret_cast::<**int, uint>(&ptr::addr_of(&(self.v))), - cast::reinterpret_cast::<*int, uint>(&self.v)); - let v2: ~int = cast::reinterpret_cast(&self.v); } +} + +impl r : Drop { + fn finalize() { + unsafe { + debug!("r's dtor: self = %x, self.v = %x, self.v's value = %x", + cast::reinterpret_cast::<*r, uint>(&ptr::addr_of(&self)), + cast::reinterpret_cast::<**int, uint>(&ptr::addr_of(&(self.v))), + cast::reinterpret_cast::<*int, uint>(&self.v)); + let v2: ~int = cast::reinterpret_cast(&self.v); + } + } } fn r(v: *int) -> r unsafe { diff --git a/src/test/run-pass/resource-cycle2.rs b/src/test/run-pass/resource-cycle2.rs index a38950e17e36a..ec04699ae986b 100644 --- a/src/test/run-pass/resource-cycle2.rs +++ b/src/test/run-pass/resource-cycle2.rs @@ -8,9 +8,14 @@ type u = { struct r { v: u, - drop unsafe { - let v2: ~int = cast::reinterpret_cast(&self.v.c); - } +} + +impl r : Drop { + fn finalize() { + unsafe { + let v2: ~int = cast::reinterpret_cast(&self.v.c); + } + } } fn r(v: u) -> r { diff --git a/src/test/run-pass/resource-cycle3.rs b/src/test/run-pass/resource-cycle3.rs index aa0f18089d9e9..22b0f1272a84c 100644 --- a/src/test/run-pass/resource-cycle3.rs +++ b/src/test/run-pass/resource-cycle3.rs @@ -12,10 +12,15 @@ struct r { v: u, w: int, x: *int, - drop unsafe { - let _v2: ~int = cast::reinterpret_cast(&self.v.c); - // let _v3: ~int = unsafe::reinterpret_cast(self.x); - } +} + +impl r : Drop { + fn finalize() { + unsafe { + let _v2: ~int = cast::reinterpret_cast(&self.v.c); + // let _v3: ~int = unsafe::reinterpret_cast(self.x); + } + } } fn r(v: u, w: int, _x: *int) -> r unsafe { diff --git a/src/test/run-pass/resource-destruct.rs b/src/test/run-pass/resource-destruct.rs index 2d3110c451857..92a57004b5074 100644 --- a/src/test/run-pass/resource-destruct.rs +++ b/src/test/run-pass/resource-destruct.rs @@ -1,6 +1,11 @@ struct shrinky_pointer { i: @@mut int, - drop { log(error, ~"Hello!"); **(self.i) -= 1; } +} + +impl shrinky_pointer : Drop { + fn finalize() { + log(error, ~"Hello!"); **(self.i) -= 1; + } } impl shrinky_pointer { diff --git a/src/test/run-pass/resource-generic.rs b/src/test/run-pass/resource-generic.rs index f109775dd7b50..476f695e783db 100644 --- a/src/test/run-pass/resource-generic.rs +++ b/src/test/run-pass/resource-generic.rs @@ -3,7 +3,12 @@ struct finish { arg: {val: T, fin: extern fn(T)}, - drop { self.arg.fin(self.arg.val); } +} + +impl finish : Drop { + fn finalize() { + self.arg.fin(self.arg.val); + } } fn finish(arg: {val: T, fin: extern fn(T)}) -> finish { diff --git a/src/test/run-pass/resource-in-struct.rs b/src/test/run-pass/resource-in-struct.rs index 9c14bd462abac..b350955bec0c5 100644 --- a/src/test/run-pass/resource-in-struct.rs +++ b/src/test/run-pass/resource-in-struct.rs @@ -5,8 +5,13 @@ type closable = @mut bool; struct close_res { i: closable, - - drop { *(self.i) = false; } + +} + +impl close_res : Drop { + fn finalize() { + *(self.i) = false; + } } fn close_res(i: closable) -> close_res { diff --git a/src/test/run-pass/send-resource.rs b/src/test/run-pass/send-resource.rs index a2ef71b141244..ebef3f39eea6d 100644 --- a/src/test/run-pass/send-resource.rs +++ b/src/test/run-pass/send-resource.rs @@ -3,7 +3,10 @@ use comm::*; struct test { f: int, - drop {} +} + +impl test : Drop { + fn finalize() {} } fn test(f: int) -> test { @@ -24,4 +27,4 @@ fn main() { } p.recv().send(test(42)); -} \ No newline at end of file +} diff --git a/src/test/run-pass/struct-literal-dtor.rs b/src/test/run-pass/struct-literal-dtor.rs index 2b56cee9f6b41..6bc605f2a0865 100644 --- a/src/test/run-pass/struct-literal-dtor.rs +++ b/src/test/run-pass/struct-literal-dtor.rs @@ -1,6 +1,11 @@ struct foo { x: ~str, - drop { error!("%s", self.x); } +} + +impl foo : Drop { + fn finalize() { + error!("%s", self.x); + } } fn main() { diff --git a/src/test/run-pass/task-compare.rs b/src/test/run-pass/task-compare.rs index 4b5852a1d9729..2996ce8ff73cb 100644 --- a/src/test/run-pass/task-compare.rs +++ b/src/test/run-pass/task-compare.rs @@ -9,7 +9,10 @@ fn child() { } struct notify { ch: comm::Chan, v: @mut bool, - drop { +} + +impl notify : Drop { + fn finalize() { error!("notify: task=%? v=%x unwinding=%b b=%b", task::get_task(), ptr::addr_of(&(*(self.v))) as uint, diff --git a/src/test/run-pass/task-killjoin-rsrc.rs b/src/test/run-pass/task-killjoin-rsrc.rs index 1e8da40b5b309..fbbdaea2c943a 100644 --- a/src/test/run-pass/task-killjoin-rsrc.rs +++ b/src/test/run-pass/task-killjoin-rsrc.rs @@ -7,7 +7,10 @@ extern mod std; struct notify { ch: comm::Chan, v: @mut bool, - drop { +} + +impl notify : Drop { + fn finalize() { error!("notify: task=%? v=%x unwinding=%b b=%b", task::get_task(), ptr::addr_of(&(*(self.v))) as uint, diff --git a/src/test/run-pass/type-param-constraints.rs b/src/test/run-pass/type-param-constraints.rs index 24ffc218e0b5a..3016778dea35c 100644 --- a/src/test/run-pass/type-param-constraints.rs +++ b/src/test/run-pass/type-param-constraints.rs @@ -7,7 +7,10 @@ fn u_foo(unique: T) { } struct r { i: int, - drop {} +} + +impl r : Drop { + fn finalize() {} } fn r(i:int) -> r { diff --git a/src/test/run-pass/unique-pinned-nocopy-2.rs b/src/test/run-pass/unique-pinned-nocopy-2.rs index 194b74d09d1c8..ad7e8d20400ea 100644 --- a/src/test/run-pass/unique-pinned-nocopy-2.rs +++ b/src/test/run-pass/unique-pinned-nocopy-2.rs @@ -1,6 +1,11 @@ struct r { i: @mut int, - drop { *(self.i) = *(self.i) + 1; } +} + +impl r : Drop { + fn finalize() { + *(self.i) = *(self.i) + 1; + } } fn r(i: @mut int) -> r { @@ -15,4 +20,4 @@ fn main() { let j = ~r(i); } assert *i == 1; -} \ No newline at end of file +} diff --git a/src/test/run-pass/unwind-resource.rs b/src/test/run-pass/unwind-resource.rs index a03564d0801ca..00ab35e9e6181 100644 --- a/src/test/run-pass/unwind-resource.rs +++ b/src/test/run-pass/unwind-resource.rs @@ -3,9 +3,14 @@ extern mod std; struct complainer { c: comm::Chan, - drop { error!("About to send!"); - comm::send(self.c, true); - error!("Sent!"); } +} + +impl complainer : Drop { + fn finalize() { + error!("About to send!"); + comm::send(self.c, true); + error!("Sent!"); + } } fn complainer(c: comm::Chan) -> complainer { diff --git a/src/test/run-pass/unwind-resource2.rs b/src/test/run-pass/unwind-resource2.rs index 1470d7d7169dc..7a159464aabf3 100644 --- a/src/test/run-pass/unwind-resource2.rs +++ b/src/test/run-pass/unwind-resource2.rs @@ -3,7 +3,10 @@ extern mod std; struct complainer { c: @int, - drop {} +} + +impl complainer : Drop { + fn finalize() {} } fn complainer(c: @int) -> complainer { diff --git a/src/test/run-pass/vec-slice-drop.rs b/src/test/run-pass/vec-slice-drop.rs index 5587193cc5157..e057117c4a57c 100644 --- a/src/test/run-pass/vec-slice-drop.rs +++ b/src/test/run-pass/vec-slice-drop.rs @@ -1,7 +1,12 @@ // Make sure that destructors get run on slice literals struct foo { x: @mut int, - drop { *self.x += 1; } +} + +impl foo : Drop { + fn finalize() { + *self.x += 1; + } } fn foo(x: @mut int) -> foo {