diff options
| author | Patrick Walton <pcwalton@mimiga.net> | 2013-03-20 18:18:57 -0700 |
|---|---|---|
| committer | Patrick Walton <pcwalton@mimiga.net> | 2013-03-21 17:31:34 -0700 |
| commit | d4fee24c7c4c8ddb1c2c681a01f666a59881acbb (patch) | |
| tree | 8e708c38984e6d54dfe823377113d6047d9f3551 /src/libstd | |
| parent | 5726fd45268d1ef3574c9321c7ce6efb7e676eac (diff) | |
| download | rust-d4fee24c7c4c8ddb1c2c681a01f666a59881acbb.tar.gz rust-d4fee24c7c4c8ddb1c2c681a01f666a59881acbb.zip | |
librustc: Forbid destructors from being attached to any structs that might contain non-Owned fields. r=nmatsakis
Diffstat (limited to 'src/libstd')
| -rw-r--r-- | src/libstd/arena.rs | 1 | ||||
| -rw-r--r-- | src/libstd/c_vec.rs | 9 | ||||
| -rw-r--r-- | src/libstd/future.rs | 1 | ||||
| -rw-r--r-- | src/libstd/net_tcp.rs | 1 | ||||
| -rw-r--r-- | src/libstd/sort.rs | 1 | ||||
| -rw-r--r-- | src/libstd/sync.rs | 12 | ||||
| -rw-r--r-- | src/libstd/task_pool.rs | 1 |
7 files changed, 22 insertions, 4 deletions
diff --git a/src/libstd/arena.rs b/src/libstd/arena.rs index 68132a1c08d..911abf95ff8 100644 --- a/src/libstd/arena.rs +++ b/src/libstd/arena.rs @@ -88,6 +88,7 @@ pub struct Arena { priv mut chunks: @List<Chunk>, } +#[unsafe_destructor] impl Drop for Arena { fn finalize(&self) { unsafe { diff --git a/src/libstd/c_vec.rs b/src/libstd/c_vec.rs index 8e75f694fa3..d9595656f05 100644 --- a/src/libstd/c_vec.rs +++ b/src/libstd/c_vec.rs @@ -54,11 +54,14 @@ struct DtorRes { dtor: Option<@fn()>, } +#[unsafe_destructor] impl Drop for DtorRes { fn finalize(&self) { - match self.dtor { - option::None => (), - option::Some(f) => f() + unsafe { + match self.dtor { + option::None => (), + option::Some(f) => f() + } } } } diff --git a/src/libstd/future.rs b/src/libstd/future.rs index 4867204ea39..fc60932b67a 100644 --- a/src/libstd/future.rs +++ b/src/libstd/future.rs @@ -35,6 +35,7 @@ pub struct Future<A> { // FIXME(#2829) -- futures should not be copyable, because they close // over ~fn's that have pipes and so forth within! +#[unsafe_destructor] impl<A> Drop for Future<A> { fn finalize(&self) {} } diff --git a/src/libstd/net_tcp.rs b/src/libstd/net_tcp.rs index a93e94e0d04..c49f65d0f99 100644 --- a/src/libstd/net_tcp.rs +++ b/src/libstd/net_tcp.rs @@ -55,6 +55,7 @@ pub struct TcpSocket { socket_data: @TcpSocketData, } +#[unsafe_destructor] impl Drop for TcpSocket { fn finalize(&self) { unsafe { diff --git a/src/libstd/sort.rs b/src/libstd/sort.rs index 40be303a147..db8311ca035 100644 --- a/src/libstd/sort.rs +++ b/src/libstd/sort.rs @@ -1190,6 +1190,7 @@ mod big_tests { key: &'self fn(@uint), } + #[unsafe_destructor] impl Drop for LVal/&self { fn finalize(&self) { let x = unsafe { task::local_data::local_data_get(self.key) }; diff --git a/src/libstd/sync.rs b/src/libstd/sync.rs index d47232cc535..00de601da6f 100644 --- a/src/libstd/sync.rs +++ b/src/libstd/sync.rs @@ -167,9 +167,12 @@ type SemRelease = SemReleaseGeneric<'self, ()>; type SemAndSignalRelease = SemReleaseGeneric<'self, ~[Waitqueue]>; struct SemReleaseGeneric<Q> { sem: &'self Sem<Q> } +#[unsafe_destructor] impl<Q:Owned> Drop for SemReleaseGeneric/&self<Q> { fn finalize(&self) { - self.sem.release(); + unsafe { + self.sem.release(); + } } } @@ -189,6 +192,7 @@ fn SemAndSignalRelease(sem: &'r Sem<~[Waitqueue]>) /// A mechanism for atomic-unlock-and-deschedule blocking and signalling. pub struct Condvar { priv sem: &'self Sem<~[Waitqueue]> } +#[unsafe_destructor] impl Drop for Condvar/&self { fn finalize(&self) {} } pub impl Condvar/&self { @@ -261,6 +265,7 @@ pub impl Condvar/&self { sem: &'self Sem<~[Waitqueue]>, } + #[unsafe_destructor] impl Drop for SemAndSignalReacquire/&self { fn finalize(&self) { unsafe { @@ -613,6 +618,7 @@ struct RWlockReleaseRead { lock: &'self RWlock, } +#[unsafe_destructor] impl Drop for RWlockReleaseRead/&self { fn finalize(&self) { unsafe { @@ -643,10 +649,12 @@ fn RWlockReleaseRead(lock: &'r RWlock) -> RWlockReleaseRead/&r { // FIXME(#3588) should go inside of downgrade() #[doc(hidden)] +#[unsafe_destructor] struct RWlockReleaseDowngrade { lock: &'self RWlock, } +#[unsafe_destructor] impl Drop for RWlockReleaseDowngrade/&self { fn finalize(&self) { unsafe { @@ -685,10 +693,12 @@ fn RWlockReleaseDowngrade(lock: &'r RWlock) -> RWlockReleaseDowngrade/&r { /// The "write permission" token used for rwlock.write_downgrade(). pub struct RWlockWriteMode { priv lock: &'self RWlock } +#[unsafe_destructor] impl Drop for RWlockWriteMode/&self { fn finalize(&self) {} } /// The "read permission" token used for rwlock.write_downgrade(). pub struct RWlockReadMode { priv lock: &'self RWlock } +#[unsafe_destructor] impl Drop for RWlockReadMode/&self { fn finalize(&self) {} } pub impl RWlockWriteMode/&self { diff --git a/src/libstd/task_pool.rs b/src/libstd/task_pool.rs index 09cab72ab21..d8ca5559f42 100644 --- a/src/libstd/task_pool.rs +++ b/src/libstd/task_pool.rs @@ -28,6 +28,7 @@ pub struct TaskPool<T> { } +#[unsafe_destructor] impl<T> Drop for TaskPool<T> { fn finalize(&self) { for self.channels.each |channel| { |
