about summary refs log tree commit diff
path: root/src/libstd
diff options
context:
space:
mode:
authorDaniel Micay <danielmicay@gmail.com>2013-09-16 21:18:07 -0400
committerDaniel Micay <danielmicay@gmail.com>2013-09-16 22:19:23 -0400
commit4e161a4d401224507513bfbf33b22f0b72f8ba81 (patch)
tree59cd25a1d2132de130ddacc5ca2d25d39a511195 /src/libstd
parentbc89ade401e637fcb7d4d1d0b7f356ca359b0e7d (diff)
downloadrust-4e161a4d401224507513bfbf33b22f0b72f8ba81.tar.gz
rust-4e161a4d401224507513bfbf33b22f0b72f8ba81.zip
switch Drop to `&mut self`
Diffstat (limited to 'src/libstd')
-rw-r--r--src/libstd/c_str.rs2
-rw-r--r--src/libstd/condition.rs2
-rw-r--r--src/libstd/io.rs6
-rw-r--r--src/libstd/ops.rs6
-rw-r--r--src/libstd/option.rs2
-rw-r--r--src/libstd/os.rs4
-rw-r--r--src/libstd/rt/comm.rs4
-rw-r--r--src/libstd/rt/kill.rs4
-rw-r--r--src/libstd/rt/local_heap.rs2
-rw-r--r--src/libstd/rt/rc.rs2
-rw-r--r--src/libstd/rt/sched.rs6
-rw-r--r--src/libstd/rt/stack.rs2
-rw-r--r--src/libstd/rt/task.rs2
-rw-r--r--src/libstd/rt/thread.rs2
-rw-r--r--src/libstd/rt/uv/uvio.rs14
-rw-r--r--src/libstd/run.rs9
-rw-r--r--src/libstd/task/spawn.rs61
-rw-r--r--src/libstd/unstable/atomics.rs2
-rw-r--r--src/libstd/unstable/dynamic_lib.rs2
-rw-r--r--src/libstd/unstable/finally.rs2
-rw-r--r--src/libstd/unstable/sync.rs4
-rw-r--r--src/libstd/util.rs4
22 files changed, 68 insertions, 76 deletions
diff --git a/src/libstd/c_str.rs b/src/libstd/c_str.rs
index a2842efbf8a..75598b300a3 100644
--- a/src/libstd/c_str.rs
+++ b/src/libstd/c_str.rs
@@ -127,7 +127,7 @@ impl CString {
 }
 
 impl Drop for CString {
-    fn drop(&self) {
+    fn drop(&mut self) {
         #[fixed_stack_segment]; #[inline(never)];
         if self.owns_buffer_ {
             unsafe {
diff --git a/src/libstd/condition.rs b/src/libstd/condition.rs
index 9cd2ad79d18..954b8bd7330 100644
--- a/src/libstd/condition.rs
+++ b/src/libstd/condition.rs
@@ -87,7 +87,7 @@ struct Guard<'self, T, U> {
 
 #[unsafe_destructor]
 impl<'self, T, U> Drop for Guard<'self, T, U> {
-    fn drop(&self) {
+    fn drop(&mut self) {
         debug!("Guard: popping handler from TLS");
         let curr = local_data::pop(self.cond.key);
         match curr {
diff --git a/src/libstd/io.rs b/src/libstd/io.rs
index 2ca36de4f49..890a53690d9 100644
--- a/src/libstd/io.rs
+++ b/src/libstd/io.rs
@@ -1021,7 +1021,7 @@ impl FILERes {
 }
 
 impl Drop for FILERes {
-    fn drop(&self) {
+    fn drop(&mut self) {
         #[fixed_stack_segment]; #[inline(never)];
 
         unsafe {
@@ -1302,7 +1302,7 @@ impl FdRes {
 }
 
 impl Drop for FdRes {
-    fn drop(&self) {
+    fn drop(&mut self) {
         #[fixed_stack_segment]; #[inline(never)];
 
         unsafe {
@@ -1832,7 +1832,7 @@ pub mod fsync {
 
     #[unsafe_destructor]
     impl<T> Drop for Res<T> {
-        fn drop(&self) {
+        fn drop(&mut self) {
             match self.arg.opt_level {
                 None => (),
                 Some(level) => {
diff --git a/src/libstd/ops.rs b/src/libstd/ops.rs
index 756b4a10d3c..1d4d827434b 100644
--- a/src/libstd/ops.rs
+++ b/src/libstd/ops.rs
@@ -14,7 +14,7 @@
 
 #[lang="drop"]
 pub trait Drop {
-    fn drop(&self);
+    fn drop(&mut self);
 }
 
 #[lang="add"]
@@ -95,7 +95,7 @@ mod bench {
     }
 
     impl Drop for HasDtor {
-        fn drop(&self) {
+        fn drop(&mut self) {
         }
     }
 
@@ -105,4 +105,4 @@ mod bench {
             HasDtor { x : 10 };
         }
     }
-}
\ No newline at end of file
+}
diff --git a/src/libstd/option.rs b/src/libstd/option.rs
index ce725257dff..9b6d0a77cd8 100644
--- a/src/libstd/option.rs
+++ b/src/libstd/option.rs
@@ -573,7 +573,7 @@ mod tests {
 
         #[unsafe_destructor]
         impl ::ops::Drop for R {
-           fn drop(&self) { *(self.i) += 1; }
+           fn drop(&mut self) { *(self.i) += 1; }
         }
 
         fn R(i: @mut int) -> R {
diff --git a/src/libstd/os.rs b/src/libstd/os.rs
index c45f2af8f7e..6fe6a1e47e9 100644
--- a/src/libstd/os.rs
+++ b/src/libstd/os.rs
@@ -1481,7 +1481,7 @@ impl MemoryMap {
 
 #[cfg(unix)]
 impl Drop for MemoryMap {
-    fn drop(&self) {
+    fn drop(&mut self) {
         #[fixed_stack_segment]; #[inline(never)];
 
         unsafe {
@@ -1607,7 +1607,7 @@ impl MemoryMap {
 
 #[cfg(windows)]
 impl Drop for MemoryMap {
-    fn drop(&self) {
+    fn drop(&mut self) {
         #[fixed_stack_segment]; #[inline(never)];
 
         use libc::types::os::arch::extra::{LPCVOID, HANDLE};
diff --git a/src/libstd/rt/comm.rs b/src/libstd/rt/comm.rs
index 4f5f26513b4..a8cd9bd66d7 100644
--- a/src/libstd/rt/comm.rs
+++ b/src/libstd/rt/comm.rs
@@ -363,7 +363,7 @@ impl<T> Peekable<T> for PortOne<T> {
 
 #[unsafe_destructor]
 impl<T> Drop for ChanOne<T> {
-    fn drop(&self) {
+    fn drop(&mut self) {
         if self.suppress_finalize { return }
 
         unsafe {
@@ -391,7 +391,7 @@ impl<T> Drop for ChanOne<T> {
 
 #[unsafe_destructor]
 impl<T> Drop for PortOne<T> {
-    fn drop(&self) {
+    fn drop(&mut self) {
         if self.suppress_finalize { return }
 
         unsafe {
diff --git a/src/libstd/rt/kill.rs b/src/libstd/rt/kill.rs
index e6003fb1a44..92dc62490ed 100644
--- a/src/libstd/rt/kill.rs
+++ b/src/libstd/rt/kill.rs
@@ -235,7 +235,7 @@ pub struct Death {
 impl Drop for KillFlag {
     // Letting a KillFlag with a task inside get dropped would leak the task.
     // We could free it here, but the task should get awoken by hand somehow.
-    fn drop(&self) {
+    fn drop(&mut self) {
         match self.load(Relaxed) {
             KILL_RUNNING | KILL_KILLED => { },
             _ => rtabort!("can't drop kill flag with a blocked task inside!"),
@@ -685,7 +685,7 @@ impl Death {
 }
 
 impl Drop for Death {
-    fn drop(&self) {
+    fn drop(&mut self) {
         // Mustn't be in an atomic or unkillable section at task death.
         rtassert!(self.unkillable == 0);
         rtassert!(self.wont_sleep == 0);
diff --git a/src/libstd/rt/local_heap.rs b/src/libstd/rt/local_heap.rs
index 12ec19a1ecc..9d0a0e0ac25 100644
--- a/src/libstd/rt/local_heap.rs
+++ b/src/libstd/rt/local_heap.rs
@@ -78,7 +78,7 @@ impl LocalHeap {
 
 impl Drop for LocalHeap {
     #[fixed_stack_segment] #[inline(never)]
-    fn drop(&self) {
+    fn drop(&mut self) {
         unsafe {
             rust_delete_boxed_region(self.boxed_region);
             rust_delete_memory_region(self.memory_region);
diff --git a/src/libstd/rt/rc.rs b/src/libstd/rt/rc.rs
index 18a5dd4a114..0a6890f627b 100644
--- a/src/libstd/rt/rc.rs
+++ b/src/libstd/rt/rc.rs
@@ -74,7 +74,7 @@ impl<T> RC<T> {
 
 #[unsafe_destructor]
 impl<T> Drop for RC<T> {
-    fn drop(&self) {
+    fn drop(&mut self) {
         assert!(self.refcount() > 0);
 
         unsafe {
diff --git a/src/libstd/rt/sched.rs b/src/libstd/rt/sched.rs
index bcf9ae4a2a8..854fdadfb00 100644
--- a/src/libstd/rt/sched.rs
+++ b/src/libstd/rt/sched.rs
@@ -1200,15 +1200,15 @@ mod test {
             struct S { field: () }
 
             impl Drop for S {
-                fn drop(&self) {
-                        let _foo = @0;
+                fn drop(&mut self) {
+                    let _foo = @0;
                 }
             }
 
             let s = S { field: () };
 
             do spawntask {
-                        let _ss = &s;
+                let _ss = &s;
             }
         }
     }
diff --git a/src/libstd/rt/stack.rs b/src/libstd/rt/stack.rs
index da70659acec..fddee5882b9 100644
--- a/src/libstd/rt/stack.rs
+++ b/src/libstd/rt/stack.rs
@@ -53,7 +53,7 @@ impl StackSegment {
 }
 
 impl Drop for StackSegment {
-    fn drop(&self) {
+    fn drop(&mut self) {
         #[fixed_stack_segment]; #[inline(never)];
 
         unsafe {
diff --git a/src/libstd/rt/task.rs b/src/libstd/rt/task.rs
index da81aab0f78..09f5ee7febb 100644
--- a/src/libstd/rt/task.rs
+++ b/src/libstd/rt/task.rs
@@ -328,7 +328,7 @@ impl Task {
 }
 
 impl Drop for Task {
-    fn drop(&self) {
+    fn drop(&mut self) {
         rtdebug!("called drop for a task: %u", borrow::to_uint(self));
         rtassert!(self.destroyed)
     }
diff --git a/src/libstd/rt/thread.rs b/src/libstd/rt/thread.rs
index 61db08f4813..8b64fda2136 100644
--- a/src/libstd/rt/thread.rs
+++ b/src/libstd/rt/thread.rs
@@ -46,7 +46,7 @@ impl Thread {
 }
 
 impl Drop for Thread {
-    fn drop(&self) {
+    fn drop(&mut self) {
         #[fixed_stack_segment]; #[inline(never)];
 
         assert!(self.joined);
diff --git a/src/libstd/rt/uv/uvio.rs b/src/libstd/rt/uv/uvio.rs
index b930ea2437e..f3b97441e8e 100644
--- a/src/libstd/rt/uv/uvio.rs
+++ b/src/libstd/rt/uv/uvio.rs
@@ -187,7 +187,7 @@ impl UvEventLoop {
 }
 
 impl Drop for UvEventLoop {
-    fn drop(&self) {
+    fn drop(&mut self) {
         // XXX: Need mutable finalizer
         let this = unsafe {
             transmute::<&UvEventLoop, &mut UvEventLoop>(self)
@@ -351,7 +351,7 @@ impl RemoteCallback for UvRemoteCallback {
 }
 
 impl Drop for UvRemoteCallback {
-    fn drop(&self) {
+    fn drop(&mut self) {
         unsafe {
             let this: &mut UvRemoteCallback = cast::transmute_mut(self);
             do this.exit_flag.with |should_exit| {
@@ -647,7 +647,7 @@ impl UvTcpListener {
 }
 
 impl Drop for UvTcpListener {
-    fn drop(&self) {
+    fn drop(&mut self) {
         // XXX need mutable finalizer
         let self_ = unsafe { transmute::<&UvTcpListener, &mut UvTcpListener>(self) };
         do self_.home_for_io_with_sched |self_, scheduler| {
@@ -762,7 +762,7 @@ impl HomingIO for UvTcpStream {
 }
 
 impl Drop for UvTcpStream {
-    fn drop(&self) {
+    fn drop(&mut self) {
         // XXX need mutable finalizer
         let this = unsafe { transmute::<&UvTcpStream, &mut UvTcpStream>(self) };
         do this.home_for_io_with_sched |self_, scheduler| {
@@ -921,7 +921,7 @@ impl HomingIO for UvUdpSocket {
 }
 
 impl Drop for UvUdpSocket {
-    fn drop(&self) {
+    fn drop(&mut self) {
         // XXX need mutable finalizer
         let this = unsafe { transmute::<&UvUdpSocket, &mut UvUdpSocket>(self) };
         do this.home_for_io_with_sched |self_, scheduler| {
@@ -1139,7 +1139,7 @@ impl UvTimer {
 }
 
 impl Drop for UvTimer {
-    fn drop(&self) {
+    fn drop(&mut self) {
         let self_ = unsafe { transmute::<&UvTimer, &mut UvTimer>(self) };
         do self_.home_for_io_with_sched |self_, scheduler| {
             rtdebug!("closing UvTimer");
@@ -1253,7 +1253,7 @@ impl UvFileStream {
 }
 
 impl Drop for UvFileStream {
-    fn drop(&self) {
+    fn drop(&mut self) {
         let self_ = unsafe { transmute::<&UvFileStream, &mut UvFileStream>(self) };
         if self.close_on_drop {
             do self_.home_for_io_with_sched |self_, scheduler| {
diff --git a/src/libstd/run.rs b/src/libstd/run.rs
index 0fe9236253d..83646dc59b3 100644
--- a/src/libstd/run.rs
+++ b/src/libstd/run.rs
@@ -436,12 +436,9 @@ impl Process {
 }
 
 impl Drop for Process {
-    fn drop(&self) {
-        // FIXME(#4330) Need self by value to get mutability.
-        let mut_self: &mut Process = unsafe { cast::transmute(self) };
-
-        mut_self.finish();
-        mut_self.close_outputs();
+    fn drop(&mut self) {
+        self.finish();
+        self.close_outputs();
         free_handle(self.handle);
     }
 }
diff --git a/src/libstd/task/spawn.rs b/src/libstd/task/spawn.rs
index c3a3dc56ce2..58cea8d7d0e 100644
--- a/src/libstd/task/spawn.rs
+++ b/src/libstd/task/spawn.rs
@@ -319,40 +319,35 @@ pub struct Taskgroup {
 
 impl Drop for Taskgroup {
     // Runs on task exit.
-    fn drop(&self) {
-        unsafe {
-            // FIXME(#4330) Need self by value to get mutability.
-            let this: &mut Taskgroup = transmute(self);
-
-            // If we are failing, the whole taskgroup needs to die.
-            do RuntimeGlue::with_task_handle_and_failing |me, failing| {
-                if failing {
-                    for x in this.notifier.mut_iter() {
-                        x.failed = true;
-                    }
-                    // Take everybody down with us. After this point, every
-                    // other task in the group will see 'tg' as none, which
-                    // indicates the whole taskgroup is failing (and forbids
-                    // new spawns from succeeding).
-                    let tg = do access_group(&self.tasks) |tg| { tg.take() };
-                    // It's safe to send kill signals outside the lock, because
-                    // we have a refcount on all kill-handles in the group.
-                    kill_taskgroup(tg, me);
-                } else {
-                    // Remove ourselves from the group(s).
-                    do access_group(&self.tasks) |tg| {
-                        leave_taskgroup(tg, me, true);
-                    }
+    fn drop(&mut self) {
+        // If we are failing, the whole taskgroup needs to die.
+        do RuntimeGlue::with_task_handle_and_failing |me, failing| {
+            if failing {
+                for x in self.notifier.mut_iter() {
+                    x.failed = true;
+                }
+                // Take everybody down with us. After this point, every
+                // other task in the group will see 'tg' as none, which
+                // indicates the whole taskgroup is failing (and forbids
+                // new spawns from succeeding).
+                let tg = do access_group(&self.tasks) |tg| { tg.take() };
+                // It's safe to send kill signals outside the lock, because
+                // we have a refcount on all kill-handles in the group.
+                kill_taskgroup(tg, me);
+            } else {
+                // Remove ourselves from the group(s).
+                do access_group(&self.tasks) |tg| {
+                    leave_taskgroup(tg, me, true);
                 }
-                // It doesn't matter whether this happens before or after dealing
-                // with our own taskgroup, so long as both happen before we die.
-                // We remove ourself from every ancestor we can, so no cleanup; no
-                // break.
-                do each_ancestor(&mut this.ancestors, |_| {}) |ancestor_group| {
-                    leave_taskgroup(ancestor_group, me, false);
-                    true
-                };
             }
+            // It doesn't matter whether this happens before or after dealing
+            // with our own taskgroup, so long as both happen before we die.
+            // We remove ourself from every ancestor we can, so no cleanup; no
+            // break.
+            do each_ancestor(&mut self.ancestors, |_| {}) |ancestor_group| {
+                leave_taskgroup(ancestor_group, me, false);
+                true
+            };
         }
     }
 }
@@ -377,7 +372,7 @@ struct AutoNotify {
 }
 
 impl Drop for AutoNotify {
-    fn drop(&self) {
+    fn drop(&mut self) {
         let result = if self.failed { Failure } else { Success };
         self.notify_chan.send(result);
     }
diff --git a/src/libstd/unstable/atomics.rs b/src/libstd/unstable/atomics.rs
index f9380e7ad12..a32b52db1cc 100644
--- a/src/libstd/unstable/atomics.rs
+++ b/src/libstd/unstable/atomics.rs
@@ -338,7 +338,7 @@ impl<T> AtomicOption<T> {
 
 #[unsafe_destructor]
 impl<T> Drop for AtomicOption<T> {
-    fn drop(&self) {
+    fn drop(&mut self) {
         // This will ensure that the contained data is
         // destroyed, unless it's null.
         unsafe {
diff --git a/src/libstd/unstable/dynamic_lib.rs b/src/libstd/unstable/dynamic_lib.rs
index d8a07eeb8b7..4c92d9c2e36 100644
--- a/src/libstd/unstable/dynamic_lib.rs
+++ b/src/libstd/unstable/dynamic_lib.rs
@@ -26,7 +26,7 @@ use result::*;
 pub struct DynamicLibrary { priv handle: *libc::c_void }
 
 impl Drop for DynamicLibrary {
-    fn drop(&self) {
+    fn drop(&mut self) {
         match do dl::check_for_errors_in {
             unsafe {
                 dl::close(self.handle)
diff --git a/src/libstd/unstable/finally.rs b/src/libstd/unstable/finally.rs
index 42820aaaa95..6833ca6d7cf 100644
--- a/src/libstd/unstable/finally.rs
+++ b/src/libstd/unstable/finally.rs
@@ -64,7 +64,7 @@ struct Finallyalizer<'self> {
 
 #[unsafe_destructor]
 impl<'self> Drop for Finallyalizer<'self> {
-    fn drop(&self) {
+    fn drop(&mut self) {
         (self.dtor)();
     }
 }
diff --git a/src/libstd/unstable/sync.rs b/src/libstd/unstable/sync.rs
index 26313323291..1dafeb27a0e 100644
--- a/src/libstd/unstable/sync.rs
+++ b/src/libstd/unstable/sync.rs
@@ -220,7 +220,7 @@ impl<T: Send> Clone for UnsafeArc<T> {
 
 #[unsafe_destructor]
 impl<T> Drop for UnsafeArc<T>{
-    fn drop(&self) {
+    fn drop(&mut self) {
         unsafe {
             // Happens when destructing an unwrapper's handle and from `#[unsafe_no_drop_flag]`
             if self.data.is_null() {
@@ -308,7 +308,7 @@ pub struct LittleLock {
 }
 
 impl Drop for LittleLock {
-    fn drop(&self) {
+    fn drop(&mut self) {
         unsafe {
             rust_destroy_little_lock(self.l);
         }
diff --git a/src/libstd/util.rs b/src/libstd/util.rs
index 5085f337d4b..e8bcceb85fa 100644
--- a/src/libstd/util.rs
+++ b/src/libstd/util.rs
@@ -88,7 +88,7 @@ impl NonCopyable {
 }
 
 impl Drop for NonCopyable {
-    fn drop(&self) { }
+    fn drop(&mut self) { }
 }
 
 /// A type with no inhabitants
@@ -188,7 +188,7 @@ mod tests {
         struct Foo { five: int }
 
         impl Drop for Foo {
-            fn drop(&self) {
+            fn drop(&mut self) {
                 assert_eq!(self.five, 5);
                 unsafe {
                     did_run = true;