Skip to content

switch Drop to &mut self #9244

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

Merged
merged 1 commit into from
Sep 17, 2013
Merged
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
2 changes: 1 addition & 1 deletion doc/tutorial-ffi.md
Original file line number Diff line number Diff line change
Expand Up @@ -321,7 +321,7 @@ impl<T: Send> Unique<T> {

#[unsafe_destructor]
impl<T: Send> Drop for Unique<T> {
fn drop(&self) {
fn drop(&mut self) {
#[fixed_stack_segment];
#[inline(never)];

Expand Down
2 changes: 1 addition & 1 deletion doc/tutorial.md
Original file line number Diff line number Diff line change
Expand Up @@ -1898,7 +1898,7 @@ struct TimeBomb {
}

impl Drop for TimeBomb {
fn drop(&self) {
fn drop(&mut self) {
for _ in range(0, self.explosivity) {
println("blam!");
}
Expand Down
2 changes: 1 addition & 1 deletion src/libextra/arc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -313,7 +313,7 @@ struct PoisonOnFail {
}

impl Drop for PoisonOnFail {
fn drop(&self) {
fn drop(&mut self) {
unsafe {
/* assert!(!*self.failed);
-- might be false in case of cond.wait() */
Expand Down
2 changes: 1 addition & 1 deletion src/libextra/arena.rs
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ fn chunk(size: uint, is_pod: bool) -> Chunk {

#[unsafe_destructor]
impl Drop for Arena {
fn drop(&self) {
fn drop(&mut self) {
unsafe {
destroy_chunk(&self.head);
do self.chunks.each |chunk| {
Expand Down
2 changes: 1 addition & 1 deletion src/libextra/c_vec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ struct DtorRes {

#[unsafe_destructor]
impl Drop for DtorRes {
fn drop(&self) {
fn drop(&mut self) {
match self.dtor {
option::None => (),
option::Some(f) => f()
Expand Down
13 changes: 5 additions & 8 deletions src/libextra/dlist.rs
Original file line number Diff line number Diff line change
Expand Up @@ -415,14 +415,11 @@ impl<T: Ord> DList<T> {

#[unsafe_destructor]
impl<T> Drop for DList<T> {
fn drop(&self) {
let mut_self = unsafe {
cast::transmute_mut(self)
};
fn drop(&mut self) {
// Dissolve the dlist in backwards direction
// Just dropping the list_head can lead to stack exhaustion
// when length is >> 1_000_000
let mut tail = mut_self.list_tail;
let mut tail = self.list_tail;
loop {
match tail.resolve() {
None => break,
Expand All @@ -432,9 +429,9 @@ impl<T> Drop for DList<T> {
}
}
}
mut_self.length = 0;
mut_self.list_head = None;
mut_self.list_tail = Rawlink::none();
self.length = 0;
self.list_head = None;
self.list_tail = Rawlink::none();
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/libextra/future.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ pub struct Future<A> {
// over ~fn's that have pipes and so forth within!
#[unsafe_destructor]
impl<A> Drop for Future<A> {
fn drop(&self) {}
fn drop(&mut self) {}
}

enum FutureState<A> {
Expand Down
4 changes: 2 additions & 2 deletions src/libextra/rc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ impl<T> Rc<T> {

#[unsafe_destructor]
impl<T> Drop for Rc<T> {
fn drop(&self) {
fn drop(&mut self) {
unsafe {
if self.ptr.is_not_null() {
(*self.ptr).count -= 1;
Expand Down Expand Up @@ -218,7 +218,7 @@ impl<T> RcMut<T> {

#[unsafe_destructor]
impl<T> Drop for RcMut<T> {
fn drop(&self) {
fn drop(&mut self) {
unsafe {
if self.ptr.is_not_null() {
(*self.ptr).count -= 1;
Expand Down
2 changes: 1 addition & 1 deletion src/libextra/task_pool.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ pub struct TaskPool<T> {

#[unsafe_destructor]
impl<T> Drop for TaskPool<T> {
fn drop(&self) {
fn drop(&mut self) {
for channel in self.channels.iter() {
channel.send(Quit);
}
Expand Down
2 changes: 1 addition & 1 deletion src/libextra/workcache.rs
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ impl Database {
// FIXME #4330: use &mut self here
#[unsafe_destructor]
impl Drop for Database {
fn drop(&self) {
fn drop(&mut self) {
if self.db_dirty {
self.save();
}
Expand Down
2 changes: 1 addition & 1 deletion src/librustc/back/link.rs
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ pub mod jit {
impl Engine for LLVMJITData {}

impl Drop for LLVMJITData {
fn drop(&self) {
fn drop(&mut self) {
unsafe {
llvm::LLVMDisposeExecutionEngine(self.ee);
llvm::LLVMContextDispose(self.llcx);
Expand Down
8 changes: 4 additions & 4 deletions src/librustc/lib/llvm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2325,7 +2325,7 @@ pub struct target_data_res {
}

impl Drop for target_data_res {
fn drop(&self) {
fn drop(&mut self) {
unsafe {
llvm::LLVMDisposeTargetData(self.TD);
}
Expand Down Expand Up @@ -2361,7 +2361,7 @@ pub struct pass_manager_res {
}

impl Drop for pass_manager_res {
fn drop(&self) {
fn drop(&mut self) {
unsafe {
llvm::LLVMDisposePassManager(self.PM);
}
Expand Down Expand Up @@ -2397,7 +2397,7 @@ pub struct object_file_res {
}

impl Drop for object_file_res {
fn drop(&self) {
fn drop(&mut self) {
unsafe {
llvm::LLVMDisposeObjectFile(self.ObjectFile);
}
Expand Down Expand Up @@ -2434,7 +2434,7 @@ pub struct section_iter_res {
}

impl Drop for section_iter_res {
fn drop(&self) {
fn drop(&mut self) {
unsafe {
llvm::LLVMDisposeSectionIterator(self.SI);
}
Expand Down
4 changes: 2 additions & 2 deletions src/librustc/middle/trans/base.rs
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ pub struct _InsnCtxt { _x: () }

#[unsafe_destructor]
impl Drop for _InsnCtxt {
fn drop(&self) {
fn drop(&mut self) {
do local_data::modify(task_local_insn_key) |c| {
do c.map_move |ctx| {
let mut ctx = (*ctx).clone();
Expand Down Expand Up @@ -159,7 +159,7 @@ impl<'self> StatRecorder<'self> {

#[unsafe_destructor]
impl<'self> Drop for StatRecorder<'self> {
fn drop(&self) {
fn drop(&mut self) {
if self.ccx.sess.trans_stats() {
let end = time::precise_time_ns();
let elapsed = ((end - self.start) / 1_000_000) as uint;
Expand Down
2 changes: 1 addition & 1 deletion src/librustc/middle/trans/common.rs
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ pub struct BuilderRef_res {
}

impl Drop for BuilderRef_res {
fn drop(&self) {
fn drop(&mut self) {
unsafe {
llvm::LLVMDisposeBuilder(self.B);
}
Expand Down
2 changes: 1 addition & 1 deletion src/librustc/middle/trans/context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -273,7 +273,7 @@ impl CrateContext {

#[unsafe_destructor]
impl Drop for CrateContext {
fn drop(&self) {
fn drop(&mut self) {
unset_task_llcx();
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/librustc/rustc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -342,7 +342,7 @@ pub fn monitor(f: ~fn(diagnostic::Emitter)) {
}

impl Drop for finally {
fn drop(&self) { self.ch.send(done); }
fn drop(&mut self) { self.ch.send(done); }
}

let _finally = finally { ch: ch };
Expand Down
2 changes: 1 addition & 1 deletion src/librustc/util/common.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ pub struct _indenter {
}

impl Drop for _indenter {
fn drop(&self) { debug!("<<"); }
fn drop(&mut self) { debug!("<<"); }
}

pub fn _indenter(_i: ()) -> _indenter {
Expand Down
2 changes: 1 addition & 1 deletion src/librustdoc/demo.rs
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ struct Bored {
}

impl Drop for Bored {
fn drop(&self) { }
fn drop(&mut self) { }
}

/**
Expand Down
2 changes: 1 addition & 1 deletion src/libstd/c_str.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
2 changes: 1 addition & 1 deletion src/libstd/condition.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
6 changes: 3 additions & 3 deletions src/libstd/io.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1021,7 +1021,7 @@ impl FILERes {
}

impl Drop for FILERes {
fn drop(&self) {
fn drop(&mut self) {
#[fixed_stack_segment]; #[inline(never)];

unsafe {
Expand Down Expand Up @@ -1302,7 +1302,7 @@ impl FdRes {
}

impl Drop for FdRes {
fn drop(&self) {
fn drop(&mut self) {
#[fixed_stack_segment]; #[inline(never)];

unsafe {
Expand Down Expand Up @@ -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) => {
Expand Down
6 changes: 3 additions & 3 deletions src/libstd/ops.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

#[lang="drop"]
pub trait Drop {
fn drop(&self);
fn drop(&mut self);
}

#[lang="add"]
Expand Down Expand Up @@ -95,7 +95,7 @@ mod bench {
}

impl Drop for HasDtor {
fn drop(&self) {
fn drop(&mut self) {
}
}

Expand All @@ -105,4 +105,4 @@ mod bench {
HasDtor { x : 10 };
}
}
}
}
2 changes: 1 addition & 1 deletion src/libstd/option.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
4 changes: 2 additions & 2 deletions src/libstd/os.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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};
Expand Down
4 changes: 2 additions & 2 deletions src/libstd/rt/comm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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 {
Expand Down
4 changes: 2 additions & 2 deletions src/libstd/rt/kill.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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!"),
Expand Down Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion src/libstd/rt/local_heap.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion src/libstd/rt/rc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
6 changes: 3 additions & 3 deletions src/libstd/rt/sched.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}
}
Expand Down
Loading