Skip to content

Commit 29cdf58

Browse files
committed
auto merge of rust-lang#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

Lines changed: 1 addition & 1 deletion
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

Lines changed: 1 addition & 1 deletion
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

Lines changed: 1 addition & 1 deletion
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

Lines changed: 1 addition & 1 deletion
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

Lines changed: 1 addition & 1 deletion
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

Lines changed: 5 additions & 8 deletions
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

Lines changed: 1 addition & 1 deletion
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

Lines changed: 2 additions & 2 deletions
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

Lines changed: 1 addition & 1 deletion
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

Lines changed: 1 addition & 1 deletion
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
}

0 commit comments

Comments
 (0)