Skip to content

Commit 81f6abb

Browse files
committed
---
yaml --- r: 36281 b: refs/heads/try2 c: c44c9a4 h: refs/heads/master i: 36279: 6bb2387 v: v3
1 parent 7af89ba commit 81f6abb

File tree

9 files changed

+53
-108
lines changed

9 files changed

+53
-108
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ refs/heads/snap-stage3: eb8fd119c65c67f3b1b8268cc7341c22d39b7b61
55
refs/heads/try: d324a424d8f84b1eb049b12cf34182bda91b0024
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/ndm: f3868061cd7988080c30d6d5bf352a5a5fe2460b
8-
refs/heads/try2: 11024eaebbd5d958df3944178e5746c0d9fda383
8+
refs/heads/try2: c44c9a47d828e93344a9af659c3245bb2502630a
99
refs/heads/incoming: d9317a174e434d4c99fc1a37fd7dc0d2f5328d37
1010
refs/heads/dist-snap: 22efa39382d41b084fde1719df7ae8ce5697d8c9
1111
refs/tags/release-0.2: c870d2dffb391e14efb05aa27898f1f6333a9596

branches/try2/src/libstd/arc.rs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -217,10 +217,7 @@ fn check_poison(is_mutex: bool, failed: bool) {
217217
#[doc(hidden)]
218218
struct PoisonOnFail {
219219
failed: &mut bool,
220-
}
221-
222-
impl PoisonOnFail : Drop {
223-
fn finalize() {
220+
drop {
224221
/* assert !*self.failed; -- might be false in case of cond.wait() */
225222
if task::failing() { *self.failed = true; }
226223
}

branches/try2/src/libstd/arena.rs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -55,10 +55,7 @@ pub struct Arena {
5555
priv mut head: Chunk,
5656
priv mut pod_head: Chunk,
5757
priv mut chunks: @List<Chunk>,
58-
}
59-
60-
impl Arena : Drop {
61-
fn finalize() {
58+
drop {
6259
unsafe {
6360
destroy_chunk(&self.head);
6461
for list::each(self.chunks) |chunk| {

branches/try2/src/libstd/c_vec.rs

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -39,15 +39,12 @@ pub enum CVec<T> {
3939

4040
struct DtorRes {
4141
dtor: Option<fn@()>,
42-
}
43-
44-
impl DtorRes : Drop {
45-
fn finalize() {
42+
drop {
4643
match self.dtor {
4744
option::None => (),
4845
option::Some(f) => f()
4946
}
50-
}
47+
}
5148
}
5249

5350
fn DtorRes(dtor: Option<fn@()>) -> DtorRes {

branches/try2/src/libstd/future.rs

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,12 +23,10 @@ use cast::copy_lifetime;
2323
#[doc = "The future type"]
2424
pub struct Future<A> {
2525
/*priv*/ mut state: FutureState<A>,
26-
}
2726

28-
// FIXME(#2829) -- futures should not be copyable, because they close
29-
// over fn~'s that have pipes and so forth within!
30-
impl<A> Future<A> : Drop {
31-
fn finalize() {}
27+
// FIXME(#2829) -- futures should not be copyable, because they close
28+
// over fn~'s that have pipes and so forth within!
29+
drop {}
3230
}
3331

3432
priv enum FutureState<A> {

branches/try2/src/libstd/net_tcp.rs

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -27,14 +27,11 @@ extern mod rustrt {
2727
*/
2828
struct TcpSocket {
2929
socket_data: @TcpSocketData,
30-
}
31-
32-
impl TcpSocket : Drop {
33-
fn finalize() {
30+
drop {
3431
unsafe {
3532
tear_down_socket_data(self.socket_data)
3633
}
37-
}
34+
}
3835
}
3936

4037
pub fn TcpSocket(socket_data: @TcpSocketData) -> TcpSocket {

branches/try2/src/libstd/sort.rs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1133,10 +1133,7 @@ mod big_tests {
11331133
val: uint,
11341134
key: fn(@uint),
11351135

1136-
}
1137-
1138-
impl LVal : Drop {
1139-
fn finalize() {
1136+
drop {
11401137
let x = unsafe { task::local_data::local_data_get(self.key) };
11411138
match x {
11421139
Some(@y) => {

branches/try2/src/libstd/sync.rs

Lines changed: 41 additions & 76 deletions
Original file line numberDiff line numberDiff line change
@@ -150,12 +150,7 @@ impl &Sem<~[mut Waitqueue]> {
150150
#[doc(hidden)]
151151
struct SemRelease {
152152
sem: &Sem<()>,
153-
}
154-
155-
impl SemRelease : Drop {
156-
fn finalize() {
157-
self.sem.release();
158-
}
153+
drop { self.sem.release(); }
159154
}
160155

161156
fn SemRelease(sem: &r/Sem<()>) -> SemRelease/&r {
@@ -167,12 +162,7 @@ fn SemRelease(sem: &r/Sem<()>) -> SemRelease/&r {
167162
#[doc(hidden)]
168163
struct SemAndSignalRelease {
169164
sem: &Sem<~[mut Waitqueue]>,
170-
}
171-
172-
impl SemAndSignalRelease : Drop {
173-
fn finalize() {
174-
self.sem.release();
175-
}
165+
drop { self.sem.release(); }
176166
}
177167

178168
fn SemAndSignalRelease(sem: &r/Sem<~[mut Waitqueue]>)
@@ -183,9 +173,7 @@ fn SemAndSignalRelease(sem: &r/Sem<~[mut Waitqueue]>)
183173
}
184174

185175
/// A mechanism for atomic-unlock-and-deschedule blocking and signalling.
186-
pub struct Condvar { priv sem: &Sem<~[mut Waitqueue]> }
187-
188-
impl Condvar : Drop { fn finalize() {} }
176+
pub struct Condvar { priv sem: &Sem<~[mut Waitqueue]>, drop { } }
189177

190178
impl &Condvar {
191179
/**
@@ -254,15 +242,10 @@ impl &Condvar {
254242
// bounded in when it gets released, this shouldn't hang forever.
255243
struct SemAndSignalReacquire {
256244
sem: &Sem<~[mut Waitqueue]>,
257-
}
258-
259-
impl SemAndSignalReacquire : Drop {
260-
fn finalize() {
261-
unsafe {
262-
// Needs to succeed, instead of itself dying.
263-
do task::unkillable {
264-
self.sem.acquire();
265-
}
245+
drop unsafe {
246+
// Needs to succeed, instead of itself dying.
247+
do task::unkillable {
248+
self.sem.acquire();
266249
}
267250
}
268251
}
@@ -598,26 +581,21 @@ impl &RWlock {
598581
#[doc(hidden)]
599582
struct RWlockReleaseRead {
600583
lock: &RWlock,
601-
}
602-
603-
impl RWlockReleaseRead : Drop {
604-
fn finalize() {
605-
unsafe {
606-
do task::unkillable {
607-
let mut last_reader = false;
608-
do self.lock.state.with |state| {
609-
assert state.read_mode;
610-
assert state.read_count > 0;
611-
state.read_count -= 1;
612-
if state.read_count == 0 {
613-
last_reader = true;
614-
state.read_mode = false;
615-
}
616-
}
617-
if last_reader {
618-
(&self.lock.access_lock).release();
584+
drop unsafe {
585+
do task::unkillable {
586+
let mut last_reader = false;
587+
do self.lock.state.with |state| {
588+
assert state.read_mode;
589+
assert state.read_count > 0;
590+
state.read_count -= 1;
591+
if state.read_count == 0 {
592+
last_reader = true;
593+
state.read_mode = false;
619594
}
620595
}
596+
if last_reader {
597+
(&self.lock.access_lock).release();
598+
}
621599
}
622600
}
623601
}
@@ -632,34 +610,28 @@ fn RWlockReleaseRead(lock: &r/RWlock) -> RWlockReleaseRead/&r {
632610
#[doc(hidden)]
633611
struct RWlockReleaseDowngrade {
634612
lock: &RWlock,
635-
}
636-
637-
impl RWlockReleaseDowngrade : Drop {
638-
fn finalize() {
639-
unsafe {
640-
do task::unkillable {
641-
let mut writer_or_last_reader = false;
642-
do self.lock.state.with |state| {
643-
if state.read_mode {
644-
assert state.read_count > 0;
645-
state.read_count -= 1;
646-
if state.read_count == 0 {
647-
// Case 1: Writer downgraded & was the last reader
648-
writer_or_last_reader = true;
649-
state.read_mode = false;
650-
} else {
651-
// Case 2: Writer downgraded & was not the last
652-
// reader
653-
}
654-
} else {
655-
// Case 3: Writer did not downgrade
613+
drop unsafe {
614+
do task::unkillable {
615+
let mut writer_or_last_reader = false;
616+
do self.lock.state.with |state| {
617+
if state.read_mode {
618+
assert state.read_count > 0;
619+
state.read_count -= 1;
620+
if state.read_count == 0 {
621+
// Case 1: Writer downgraded & was the last reader
656622
writer_or_last_reader = true;
623+
state.read_mode = false;
624+
} else {
625+
// Case 2: Writer downgraded & was not the last reader
657626
}
658-
}
659-
if writer_or_last_reader {
660-
(&self.lock.access_lock).release();
627+
} else {
628+
// Case 3: Writer did not downgrade
629+
writer_or_last_reader = true;
661630
}
662631
}
632+
if writer_or_last_reader {
633+
(&self.lock.access_lock).release();
634+
}
663635
}
664636
}
665637
}
@@ -671,11 +643,9 @@ fn RWlockReleaseDowngrade(lock: &r/RWlock) -> RWlockReleaseDowngrade/&r {
671643
}
672644
673645
/// The "write permission" token used for rwlock.write_downgrade().
674-
pub struct RWlockWriteMode { /* priv */ lock: &RWlock }
675-
impl RWlockWriteMode : Drop { fn finalize() {} }
646+
pub struct RWlockWriteMode { /* priv */ lock: &RWlock, drop { } }
676647
/// The "read permission" token used for rwlock.write_downgrade().
677-
pub struct RWlockReadMode { priv lock: &RWlock }
678-
impl RWlockReadMode : Drop { fn finalize() {} }
648+
pub struct RWlockReadMode { priv lock: &RWlock, drop { } }
679649

680650
impl &RWlockWriteMode {
681651
/// Access the pre-downgrade rwlock in write mode.
@@ -984,12 +954,7 @@ mod tests {
984954
}
985955
struct SendOnFailure {
986956
c: pipes::Chan<()>,
987-
}
988-
989-
impl SendOnFailure : Drop {
990-
fn finalize() {
991-
self.c.send(());
992-
}
957+
drop { self.c.send(()); }
993958
}
994959

995960
fn SendOnFailure(c: pipes::Chan<()>) -> SendOnFailure {

branches/try2/src/libstd/thread_pool.rs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,7 @@ pub struct ThreadPool<T> {
1313
channels: ~[Chan<Msg<T>>],
1414
mut next_index: uint,
1515

16-
}
17-
18-
impl<T> ThreadPool<T> {
19-
fn finalize() {
16+
drop {
2017
for self.channels.each |channel| {
2118
channel.send(Quit);
2219
}

0 commit comments

Comments
 (0)