Skip to content

Commit 29cdf58

Browse files
committed
auto merge of #9244 : thestinger/rust/drop, r=catamorphism
This doesn't close any bugs as the goal is to convert the parameter to by-value, but this is a step towards being able to make guarantees about `&T` pointers (where T is Freeze) to LLVM.
2 parents f45c640 + 4e161a4 commit 29cdf58

File tree

129 files changed

+192
-203
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

129 files changed

+192
-203
lines changed

doc/tutorial-ffi.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -321,7 +321,7 @@ impl<T: Send> Unique<T> {
321321
322322
#[unsafe_destructor]
323323
impl<T: Send> Drop for Unique<T> {
324-
fn drop(&self) {
324+
fn drop(&mut self) {
325325
#[fixed_stack_segment];
326326
#[inline(never)];
327327

doc/tutorial.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -1898,7 +1898,7 @@ struct TimeBomb {
18981898
}
18991899
19001900
impl Drop for TimeBomb {
1901-
fn drop(&self) {
1901+
fn drop(&mut self) {
19021902
for _ in range(0, self.explosivity) {
19031903
println("blam!");
19041904
}

src/libextra/arc.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -313,7 +313,7 @@ struct PoisonOnFail {
313313
}
314314
315315
impl Drop for PoisonOnFail {
316-
fn drop(&self) {
316+
fn drop(&mut self) {
317317
unsafe {
318318
/* assert!(!*self.failed);
319319
-- might be false in case of cond.wait() */

src/libextra/arena.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ fn chunk(size: uint, is_pod: bool) -> Chunk {
9393

9494
#[unsafe_destructor]
9595
impl Drop for Arena {
96-
fn drop(&self) {
96+
fn drop(&mut self) {
9797
unsafe {
9898
destroy_chunk(&self.head);
9999
do self.chunks.each |chunk| {

src/libextra/c_vec.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ struct DtorRes {
5656

5757
#[unsafe_destructor]
5858
impl Drop for DtorRes {
59-
fn drop(&self) {
59+
fn drop(&mut self) {
6060
match self.dtor {
6161
option::None => (),
6262
option::Some(f) => f()

src/libextra/dlist.rs

+5-8
Original file line numberDiff line numberDiff line change
@@ -415,14 +415,11 @@ impl<T: Ord> DList<T> {
415415

416416
#[unsafe_destructor]
417417
impl<T> Drop for DList<T> {
418-
fn drop(&self) {
419-
let mut_self = unsafe {
420-
cast::transmute_mut(self)
421-
};
418+
fn drop(&mut self) {
422419
// Dissolve the dlist in backwards direction
423420
// Just dropping the list_head can lead to stack exhaustion
424421
// when length is >> 1_000_000
425-
let mut tail = mut_self.list_tail;
422+
let mut tail = self.list_tail;
426423
loop {
427424
match tail.resolve() {
428425
None => break,
@@ -432,9 +429,9 @@ impl<T> Drop for DList<T> {
432429
}
433430
}
434431
}
435-
mut_self.length = 0;
436-
mut_self.list_head = None;
437-
mut_self.list_tail = Rawlink::none();
432+
self.length = 0;
433+
self.list_head = None;
434+
self.list_tail = Rawlink::none();
438435
}
439436
}
440437

src/libextra/future.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ pub struct Future<A> {
4343
// over ~fn's that have pipes and so forth within!
4444
#[unsafe_destructor]
4545
impl<A> Drop for Future<A> {
46-
fn drop(&self) {}
46+
fn drop(&mut self) {}
4747
}
4848

4949
enum FutureState<A> {

src/libextra/rc.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ impl<T> Rc<T> {
7373

7474
#[unsafe_destructor]
7575
impl<T> Drop for Rc<T> {
76-
fn drop(&self) {
76+
fn drop(&mut self) {
7777
unsafe {
7878
if self.ptr.is_not_null() {
7979
(*self.ptr).count -= 1;
@@ -218,7 +218,7 @@ impl<T> RcMut<T> {
218218

219219
#[unsafe_destructor]
220220
impl<T> Drop for RcMut<T> {
221-
fn drop(&self) {
221+
fn drop(&mut self) {
222222
unsafe {
223223
if self.ptr.is_not_null() {
224224
(*self.ptr).count -= 1;

src/libextra/task_pool.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ pub struct TaskPool<T> {
3434

3535
#[unsafe_destructor]
3636
impl<T> Drop for TaskPool<T> {
37-
fn drop(&self) {
37+
fn drop(&mut self) {
3838
for channel in self.channels.iter() {
3939
channel.send(Quit);
4040
}

src/libextra/workcache.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -201,7 +201,7 @@ impl Database {
201201
// FIXME #4330: use &mut self here
202202
#[unsafe_destructor]
203203
impl Drop for Database {
204-
fn drop(&self) {
204+
fn drop(&mut self) {
205205
if self.db_dirty {
206206
self.save();
207207
}

src/librustc/back/link.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ pub mod jit {
105105
impl Engine for LLVMJITData {}
106106

107107
impl Drop for LLVMJITData {
108-
fn drop(&self) {
108+
fn drop(&mut self) {
109109
unsafe {
110110
llvm::LLVMDisposeExecutionEngine(self.ee);
111111
llvm::LLVMContextDispose(self.llcx);

src/librustc/lib/llvm.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -2325,7 +2325,7 @@ pub struct target_data_res {
23252325
}
23262326

23272327
impl Drop for target_data_res {
2328-
fn drop(&self) {
2328+
fn drop(&mut self) {
23292329
unsafe {
23302330
llvm::LLVMDisposeTargetData(self.TD);
23312331
}
@@ -2361,7 +2361,7 @@ pub struct pass_manager_res {
23612361
}
23622362

23632363
impl Drop for pass_manager_res {
2364-
fn drop(&self) {
2364+
fn drop(&mut self) {
23652365
unsafe {
23662366
llvm::LLVMDisposePassManager(self.PM);
23672367
}
@@ -2397,7 +2397,7 @@ pub struct object_file_res {
23972397
}
23982398

23992399
impl Drop for object_file_res {
2400-
fn drop(&self) {
2400+
fn drop(&mut self) {
24012401
unsafe {
24022402
llvm::LLVMDisposeObjectFile(self.ObjectFile);
24032403
}
@@ -2434,7 +2434,7 @@ pub struct section_iter_res {
24342434
}
24352435

24362436
impl Drop for section_iter_res {
2437-
fn drop(&self) {
2437+
fn drop(&mut self) {
24382438
unsafe {
24392439
llvm::LLVMDisposeSectionIterator(self.SI);
24402440
}

src/librustc/middle/trans/base.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ pub struct _InsnCtxt { _x: () }
109109

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

160160
#[unsafe_destructor]
161161
impl<'self> Drop for StatRecorder<'self> {
162-
fn drop(&self) {
162+
fn drop(&mut self) {
163163
if self.ccx.sess.trans_stats() {
164164
let end = time::precise_time_ns();
165165
let elapsed = ((end - self.start) / 1_000_000) as uint;

src/librustc/middle/trans/common.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ pub struct BuilderRef_res {
111111
}
112112

113113
impl Drop for BuilderRef_res {
114-
fn drop(&self) {
114+
fn drop(&mut self) {
115115
unsafe {
116116
llvm::LLVMDisposeBuilder(self.B);
117117
}

src/librustc/middle/trans/context.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -282,7 +282,7 @@ impl CrateContext {
282282

283283
#[unsafe_destructor]
284284
impl Drop for CrateContext {
285-
fn drop(&self) {
285+
fn drop(&mut self) {
286286
unset_task_llcx();
287287
}
288288
}

src/librustc/rustc.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -342,7 +342,7 @@ pub fn monitor(f: ~fn(diagnostic::Emitter)) {
342342
}
343343

344344
impl Drop for finally {
345-
fn drop(&self) { self.ch.send(done); }
345+
fn drop(&mut self) { self.ch.send(done); }
346346
}
347347

348348
let _finally = finally { ch: ch };

src/librustc/util/common.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ pub struct _indenter {
4040
}
4141

4242
impl Drop for _indenter {
43-
fn drop(&self) { debug!("<<"); }
43+
fn drop(&mut self) { debug!("<<"); }
4444
}
4545

4646
pub fn _indenter(_i: ()) -> _indenter {

src/librustdoc/demo.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ struct Bored {
127127
}
128128

129129
impl Drop for Bored {
130-
fn drop(&self) { }
130+
fn drop(&mut self) { }
131131
}
132132

133133
/**

src/libstd/c_str.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ impl CString {
127127
}
128128

129129
impl Drop for CString {
130-
fn drop(&self) {
130+
fn drop(&mut self) {
131131
#[fixed_stack_segment]; #[inline(never)];
132132
if self.owns_buffer_ {
133133
unsafe {

src/libstd/condition.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ struct Guard<'self, T, U> {
8787

8888
#[unsafe_destructor]
8989
impl<'self, T, U> Drop for Guard<'self, T, U> {
90-
fn drop(&self) {
90+
fn drop(&mut self) {
9191
debug!("Guard: popping handler from TLS");
9292
let curr = local_data::pop(self.cond.key);
9393
match curr {

src/libstd/io.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -1021,7 +1021,7 @@ impl FILERes {
10211021
}
10221022

10231023
impl Drop for FILERes {
1024-
fn drop(&self) {
1024+
fn drop(&mut self) {
10251025
#[fixed_stack_segment]; #[inline(never)];
10261026

10271027
unsafe {
@@ -1302,7 +1302,7 @@ impl FdRes {
13021302
}
13031303

13041304
impl Drop for FdRes {
1305-
fn drop(&self) {
1305+
fn drop(&mut self) {
13061306
#[fixed_stack_segment]; #[inline(never)];
13071307

13081308
unsafe {
@@ -1832,7 +1832,7 @@ pub mod fsync {
18321832

18331833
#[unsafe_destructor]
18341834
impl<T> Drop for Res<T> {
1835-
fn drop(&self) {
1835+
fn drop(&mut self) {
18361836
match self.arg.opt_level {
18371837
None => (),
18381838
Some(level) => {

src/libstd/ops.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414

1515
#[lang="drop"]
1616
pub trait Drop {
17-
fn drop(&self);
17+
fn drop(&mut self);
1818
}
1919

2020
#[lang="add"]
@@ -95,7 +95,7 @@ mod bench {
9595
}
9696

9797
impl Drop for HasDtor {
98-
fn drop(&self) {
98+
fn drop(&mut self) {
9999
}
100100
}
101101

@@ -105,4 +105,4 @@ mod bench {
105105
HasDtor { x : 10 };
106106
}
107107
}
108-
}
108+
}

src/libstd/option.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -573,7 +573,7 @@ mod tests {
573573

574574
#[unsafe_destructor]
575575
impl ::ops::Drop for R {
576-
fn drop(&self) { *(self.i) += 1; }
576+
fn drop(&mut self) { *(self.i) += 1; }
577577
}
578578

579579
fn R(i: @mut int) -> R {

src/libstd/os.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -1481,7 +1481,7 @@ impl MemoryMap {
14811481

14821482
#[cfg(unix)]
14831483
impl Drop for MemoryMap {
1484-
fn drop(&self) {
1484+
fn drop(&mut self) {
14851485
#[fixed_stack_segment]; #[inline(never)];
14861486

14871487
unsafe {
@@ -1607,7 +1607,7 @@ impl MemoryMap {
16071607
16081608
#[cfg(windows)]
16091609
impl Drop for MemoryMap {
1610-
fn drop(&self) {
1610+
fn drop(&mut self) {
16111611
#[fixed_stack_segment]; #[inline(never)];
16121612
16131613
use libc::types::os::arch::extra::{LPCVOID, HANDLE};

src/libstd/rt/comm.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -363,7 +363,7 @@ impl<T> Peekable<T> for PortOne<T> {
363363

364364
#[unsafe_destructor]
365365
impl<T> Drop for ChanOne<T> {
366-
fn drop(&self) {
366+
fn drop(&mut self) {
367367
if self.suppress_finalize { return }
368368

369369
unsafe {
@@ -391,7 +391,7 @@ impl<T> Drop for ChanOne<T> {
391391

392392
#[unsafe_destructor]
393393
impl<T> Drop for PortOne<T> {
394-
fn drop(&self) {
394+
fn drop(&mut self) {
395395
if self.suppress_finalize { return }
396396

397397
unsafe {

src/libstd/rt/kill.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -235,7 +235,7 @@ pub struct Death {
235235
impl Drop for KillFlag {
236236
// Letting a KillFlag with a task inside get dropped would leak the task.
237237
// We could free it here, but the task should get awoken by hand somehow.
238-
fn drop(&self) {
238+
fn drop(&mut self) {
239239
match self.load(Relaxed) {
240240
KILL_RUNNING | KILL_KILLED => { },
241241
_ => rtabort!("can't drop kill flag with a blocked task inside!"),
@@ -685,7 +685,7 @@ impl Death {
685685
}
686686

687687
impl Drop for Death {
688-
fn drop(&self) {
688+
fn drop(&mut self) {
689689
// Mustn't be in an atomic or unkillable section at task death.
690690
rtassert!(self.unkillable == 0);
691691
rtassert!(self.wont_sleep == 0);

src/libstd/rt/local_heap.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ impl LocalHeap {
7878

7979
impl Drop for LocalHeap {
8080
#[fixed_stack_segment] #[inline(never)]
81-
fn drop(&self) {
81+
fn drop(&mut self) {
8282
unsafe {
8383
rust_delete_boxed_region(self.boxed_region);
8484
rust_delete_memory_region(self.memory_region);

src/libstd/rt/rc.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ impl<T> RC<T> {
7474

7575
#[unsafe_destructor]
7676
impl<T> Drop for RC<T> {
77-
fn drop(&self) {
77+
fn drop(&mut self) {
7878
assert!(self.refcount() > 0);
7979

8080
unsafe {

src/libstd/rt/sched.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -1200,15 +1200,15 @@ mod test {
12001200
struct S { field: () }
12011201

12021202
impl Drop for S {
1203-
fn drop(&self) {
1204-
let _foo = @0;
1203+
fn drop(&mut self) {
1204+
let _foo = @0;
12051205
}
12061206
}
12071207

12081208
let s = S { field: () };
12091209

12101210
do spawntask {
1211-
let _ss = &s;
1211+
let _ss = &s;
12121212
}
12131213
}
12141214
}

0 commit comments

Comments
 (0)