about summary refs log tree commit diff
path: root/src/libcore
diff options
context:
space:
mode:
Diffstat (limited to 'src/libcore')
-rw-r--r--src/libcore/io.rs10
-rw-r--r--src/libcore/option.rs5
-rw-r--r--src/libcore/pipes.rs5
-rw-r--r--src/libcore/private.rs15
-rw-r--r--src/libcore/rand.rs5
-rw-r--r--src/libcore/run.rs5
-rw-r--r--src/libcore/task/spawn.rs10
-rw-r--r--src/libcore/util.rs5
8 files changed, 48 insertions, 12 deletions
diff --git a/src/libcore/io.rs b/src/libcore/io.rs
index 421eb94a291..45d89b29a2e 100644
--- a/src/libcore/io.rs
+++ b/src/libcore/io.rs
@@ -474,7 +474,10 @@ impl<R:Reader,C> Reader for Wrapper<R, C> {
 
 pub struct FILERes {
     f: *libc::FILE,
-    drop {
+}
+
+impl Drop for FILERes {
+    fn finalize(&self) {
         unsafe {
             libc::fclose(self.f);
         }
@@ -683,7 +686,10 @@ impl Writer for fd_t {
 
 pub struct FdRes {
     fd: fd_t,
-    drop {
+}
+
+impl Drop for FdRes {
+    fn finalize(&self) {
         unsafe {
             libc::close(self.fd);
         }
diff --git a/src/libcore/option.rs b/src/libcore/option.rs
index 1c2df949a2e..12ed0df0076 100644
--- a/src/libcore/option.rs
+++ b/src/libcore/option.rs
@@ -450,7 +450,10 @@ fn test_unwrap_str() {
 fn test_unwrap_resource() {
     struct R {
        i: @mut int,
-       drop { *(self.i) += 1; }
+    }
+
+    impl ::ops::Drop for R {
+       fn finalize(&self) { *(self.i) += 1; }
     }
 
     fn R(i: @mut int) -> R {
diff --git a/src/libcore/pipes.rs b/src/libcore/pipes.rs
index 15a6e700ffd..a0a29c6b516 100644
--- a/src/libcore/pipes.rs
+++ b/src/libcore/pipes.rs
@@ -346,7 +346,10 @@ pub unsafe fn get_buffer<T>(p: *PacketHeader) -> ~Buffer<T> {
 struct BufferResource<T> {
     buffer: ~Buffer<T>,
 
-    drop {
+}
+
+impl<T> ::ops::Drop for BufferResource<T> {
+    fn finalize(&self) {
         unsafe {
             let b = move_it!(self.buffer);
             //let p = ptr::addr_of(*b);
diff --git a/src/libcore/private.rs b/src/libcore/private.rs
index 2580efe6d09..e4fab18966c 100644
--- a/src/libcore/private.rs
+++ b/src/libcore/private.rs
@@ -126,7 +126,10 @@ struct ArcData<T> {
 
 struct ArcDestruct<T> {
     mut data: *libc::c_void,
-    drop {
+}
+
+impl<T> Drop for ArcDestruct<T>{
+    fn finalize(&self) {
         unsafe {
             if self.data.is_null() {
                 return; // Happens when destructing an unwrapper's handle.
@@ -178,7 +181,10 @@ pub unsafe fn unwrap_shared_mutable_state<T:Owned>(rc: SharedMutableState<T>)
     struct DeathThroes<T> {
         mut ptr:      Option<~ArcData<T>>,
         mut response: Option<comm::ChanOne<bool>>,
-        drop {
+    }
+
+    impl<T> Drop for DeathThroes<T>{
+        fn finalize(&self) {
             unsafe {
                 let response = option::swap_unwrap(&mut self.response);
                 // In case we get killed early, we need to tell the person who
@@ -311,7 +317,10 @@ type rust_little_lock = *libc::c_void;
 
 struct LittleLock {
     l: rust_little_lock,
-    drop {
+}
+
+impl Drop for LittleLock {
+    fn finalize(&self) {
         unsafe {
             rustrt::rust_destroy_little_lock(self.l);
         }
diff --git a/src/libcore/rand.rs b/src/libcore/rand.rs
index a88b8346516..15362f89e3f 100644
--- a/src/libcore/rand.rs
+++ b/src/libcore/rand.rs
@@ -365,7 +365,10 @@ impl Rng {
 
 struct RandRes {
     rng: *rust_rng,
-    drop {
+}
+
+impl Drop for RandRes {
+    fn finalize(&self) {
         unsafe {
             rustrt::rand_free(self.rng);
         }
diff --git a/src/libcore/run.rs b/src/libcore/run.rs
index 4e2337b8331..aa1e473e3bf 100644
--- a/src/libcore/run.rs
+++ b/src/libcore/run.rs
@@ -248,7 +248,10 @@ pub fn start_program(prog: &str, args: &[~str]) -> Program {
     }
     struct ProgRes {
         r: ProgRepr,
-        drop {
+    }
+
+    impl Drop for ProgRes {
+        fn finalize(&self) {
             unsafe {
                 // FIXME #4943: This is bad.
                 destroy_repr(cast::transmute(&self.r));
diff --git a/src/libcore/task/spawn.rs b/src/libcore/task/spawn.rs
index 5110f70ff11..bf7209f9fc3 100644
--- a/src/libcore/task/spawn.rs
+++ b/src/libcore/task/spawn.rs
@@ -308,8 +308,11 @@ struct TCB {
     mut ancestors: AncestorList,
     is_main:       bool,
     notifier:      Option<AutoNotify>,
+}
+
+impl Drop for TCB {
     // Runs on task exit.
-    drop {
+    fn finalize(&self) {
         unsafe {
             // If we are failing, the whole taskgroup needs to die.
             if rt::rust_task_is_unwinding(self.me) {
@@ -353,7 +356,10 @@ fn TCB(me: *rust_task, tasks: TaskGroupArc, ancestors: AncestorList,
 struct AutoNotify {
     notify_chan: Chan<TaskResult>,
     mut failed:  bool,
-    drop {
+}
+
+impl Drop for AutoNotify {
+    fn finalize(&self) {
         let result = if self.failed { Failure } else { Success };
         self.notify_chan.send(result);
     }
diff --git a/src/libcore/util.rs b/src/libcore/util.rs
index 629c4a3291c..522cb2d2783 100644
--- a/src/libcore/util.rs
+++ b/src/libcore/util.rs
@@ -66,7 +66,10 @@ pub fn replace<T>(dest: &mut T, src: T) -> T {
 /// A non-copyable dummy type.
 pub struct NonCopyable {
     i: (),
-    drop { }
+}
+
+impl Drop for NonCopyable {
+    fn finalize(&self) { }
 }
 
 pub fn NonCopyable() -> NonCopyable { NonCopyable { i: () } }