Skip to content

Convert the test suite to use the Drop trait #3967

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions src/test/auxiliary/issue-2526.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,10 @@ export context;

struct arc_destruct<T:Const> {
_data: int,
drop {}
}

impl<T:Const> arc_destruct<T> : Drop {
fn finalize() {}
}

fn arc_destruct<T: Const>(data: int) -> arc_destruct<T> {
Expand All @@ -28,8 +31,10 @@ fn init() -> arc_destruct<context_res> unsafe {

struct context_res {
ctx : int,
}

drop { }
impl context_res : Drop {
fn finalize() {}
}

fn context_res() -> context_res {
Expand Down
7 changes: 6 additions & 1 deletion src/test/auxiliary/issue-3012-1.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
9 changes: 7 additions & 2 deletions src/test/auxiliary/issue2170lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
}
}
33 changes: 19 additions & 14 deletions src/test/auxiliary/test_comm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,23 +29,28 @@ fn port<T: Send>() -> port<T> {

struct port_ptr<T:Send> {
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_::<T>(self.po);
impl<T:Send> port_ptr<T> : 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_::<T>(self.po);
}
rustrt::del_port(self.po);
}
}
rustrt::del_port(self.po);
}
}
}

fn port_ptr<T: Send>(po: *rust_port) -> port_ptr<T> {
Expand Down
5 changes: 4 additions & 1 deletion src/test/bench/task-perf-alloc-unwind.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,10 @@ enum st {

struct r {
_l: @nillist,
drop {}
}

impl r : Drop {
fn finalize() {}
}

fn r(l: @nillist) -> r {
Expand Down
Original file line number Diff line number Diff line change
@@ -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: () });
Expand Down
Original file line number Diff line number Diff line change
@@ -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: () }));
Expand Down
Original file line number Diff line number Diff line change
@@ -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<T,U> { some2(T,U), none2 }

Expand Down
Original file line number Diff line number Diff line change
@@ -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: () }));
Expand Down
8 changes: 7 additions & 1 deletion src/test/compile-fail/bind-by-move-no-lvalues-1.rs
Original file line number Diff line number Diff line change
@@ -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: () });
Expand Down
9 changes: 8 additions & 1 deletion src/test/compile-fail/bind-by-move-no-lvalues-2.rs
Original file line number Diff line number Diff line change
@@ -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<X> }

fn main() {
Expand Down
8 changes: 7 additions & 1 deletion src/test/compile-fail/bind-by-move-no-sub-bindings.rs
Original file line number Diff line number Diff line change
@@ -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: () });
Expand Down
10 changes: 7 additions & 3 deletions src/test/compile-fail/block-must-not-have-result-res.rs
Original file line number Diff line number Diff line change
@@ -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() {
}
}
7 changes: 6 additions & 1 deletion src/test/compile-fail/borrowck-borrowed-uniq-rvalue-2.rs
Original file line number Diff line number Diff line change
@@ -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 {
Expand Down
8 changes: 7 additions & 1 deletion src/test/compile-fail/borrowck-unary-move-2.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
struct noncopyable {
i: (), drop { error!("dropped"); }
i: (),
}

impl noncopyable : Drop {
fn finalize() {
error!("dropped");
}
}

fn noncopyable() -> noncopyable {
Expand Down
6 changes: 5 additions & 1 deletion src/test/compile-fail/cap-clause-illegal-cap.rs
Original file line number Diff line number Diff line change
@@ -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 {
Expand Down
5 changes: 4 additions & 1 deletion src/test/compile-fail/copy-a-resource.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,10 @@

struct foo {
i: int,
drop {}
}

impl foo : Drop {
fn finalize() {}
}

fn foo(i:int) -> foo {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
struct X {
x: ~str,
drop {
}

impl X : Drop {
fn finalize() {
error!("value: %s", self.x);
}
}
Expand Down
7 changes: 6 additions & 1 deletion src/test/compile-fail/functional-struct-update.rs
Original file line number Diff line number Diff line change
@@ -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 {
Expand Down
4 changes: 3 additions & 1 deletion src/test/compile-fail/issue-2487-b.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
struct socket {
sock: int,
}

drop { }
impl socket : Drop {
fn finalize() {}
}

impl socket {
Expand Down
5 changes: 4 additions & 1 deletion src/test/compile-fail/issue-2548.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,10 @@ struct foo {
x: @mut int,


drop {
}

impl foo : Drop {
fn finalize() {
io::println("Goodbye, World!");
*self.x += 1;
}
Expand Down
5 changes: 4 additions & 1 deletion src/test/compile-fail/issue-2587-2.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,10 @@ fn bar<T>(+_t: T) { fail; }

struct S {
x: int,
drop {}
}

impl S : Drop {
fn finalize() {}
}

fn S(x: int) -> S { S { x: x } }
Expand Down
7 changes: 5 additions & 2 deletions src/test/compile-fail/issue-2823.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
struct C {
x: int,
drop {
}

impl C : Drop {
fn finalize() {
error!("dropping: %?", self.x);
}
}
Expand All @@ -9,4 +12,4 @@ fn main() {
let c = C{ x: 2};
let d = copy c; //~ ERROR copying a noncopyable value
error!("%?", d.x);
}
}
17 changes: 0 additions & 17 deletions src/test/compile-fail/issue-2825-b.rs

This file was deleted.

5 changes: 4 additions & 1 deletion src/test/compile-fail/issue-3214.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,10 @@ fn foo<T>() {
struct foo {
mut x: T, //~ ERROR attempt to use a type argument out of scope
//~^ ERROR use of undeclared type name
drop { }
}

impl<T> foo<T> : Drop {
fn finalize() {}
}
}
fn main() { }
6 changes: 5 additions & 1 deletion src/test/compile-fail/liveness-unused.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
5 changes: 4 additions & 1 deletion src/test/compile-fail/no-send-res-ports.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
fn main() {
struct foo {
_x: comm::Port<()>,
drop {}
}

impl foo : Drop {
fn finalize() {}
}

fn foo(x: comm::Port<()>) -> foo {
Expand Down
Loading