Skip to content

Commit befc561

Browse files
committed
remove unnecessary transmutes
1 parent 29cdf58 commit befc561

File tree

4 files changed

+8
-28
lines changed

4 files changed

+8
-28
lines changed

src/libextra/workcache.rs

-1
Original file line numberDiff line numberDiff line change
@@ -198,7 +198,6 @@ impl Database {
198198
}
199199
}
200200

201-
// FIXME #4330: use &mut self here
202201
#[unsafe_destructor]
203202
impl Drop for Database {
204203
fn drop(&mut self) {

src/libstd/rt/rc.rs

+3-6
Original file line numberDiff line numberDiff line change
@@ -78,17 +78,14 @@ impl<T> Drop for RC<T> {
7878
assert!(self.refcount() > 0);
7979

8080
unsafe {
81-
// FIXME(#4330) Need self by value to get mutability.
82-
let this: &mut RC<T> = cast::transmute_mut(self);
83-
84-
match *this.get_mut_state() {
81+
match *self.get_mut_state() {
8582
(ref mut count, _) => {
8683
*count = *count - 1
8784
}
8885
}
8986

90-
if this.refcount() == 0 {
91-
let _: ~(uint, T) = cast::transmute(this.p);
87+
if self.refcount() == 0 {
88+
let _: ~(uint, T) = cast::transmute(self.p);
9289
}
9390
}
9491
}

src/libstd/rt/uv/uvio.rs

+4-14
Original file line numberDiff line numberDiff line change
@@ -188,11 +188,7 @@ impl UvEventLoop {
188188

189189
impl Drop for UvEventLoop {
190190
fn drop(&mut self) {
191-
// XXX: Need mutable finalizer
192-
let this = unsafe {
193-
transmute::<&UvEventLoop, &mut UvEventLoop>(self)
194-
};
195-
this.uvio.uv_loop().close();
191+
self.uvio.uv_loop().close();
196192
}
197193
}
198194

@@ -648,9 +644,7 @@ impl UvTcpListener {
648644

649645
impl Drop for UvTcpListener {
650646
fn drop(&mut self) {
651-
// XXX need mutable finalizer
652-
let self_ = unsafe { transmute::<&UvTcpListener, &mut UvTcpListener>(self) };
653-
do self_.home_for_io_with_sched |self_, scheduler| {
647+
do self.home_for_io_with_sched |self_, scheduler| {
654648
do scheduler.deschedule_running_task_and_then |_, task| {
655649
let task = Cell::new(task);
656650
do self_.watcher.as_stream().close {
@@ -763,9 +757,7 @@ impl HomingIO for UvTcpStream {
763757

764758
impl Drop for UvTcpStream {
765759
fn drop(&mut self) {
766-
// XXX need mutable finalizer
767-
let this = unsafe { transmute::<&UvTcpStream, &mut UvTcpStream>(self) };
768-
do this.home_for_io_with_sched |self_, scheduler| {
760+
do self.home_for_io_with_sched |self_, scheduler| {
769761
do scheduler.deschedule_running_task_and_then |_, task| {
770762
let task_cell = Cell::new(task);
771763
do self_.watcher.as_stream().close {
@@ -922,9 +914,7 @@ impl HomingIO for UvUdpSocket {
922914

923915
impl Drop for UvUdpSocket {
924916
fn drop(&mut self) {
925-
// XXX need mutable finalizer
926-
let this = unsafe { transmute::<&UvUdpSocket, &mut UvUdpSocket>(self) };
927-
do this.home_for_io_with_sched |self_, scheduler| {
917+
do self.home_for_io_with_sched |self_, scheduler| {
928918
do scheduler.deschedule_running_task_and_then |_, task| {
929919
let task_cell = Cell::new(task);
930920
do self_.watcher.close {

src/libstd/unstable/atomics.rs

+1-7
Original file line numberDiff line numberDiff line change
@@ -339,13 +339,7 @@ impl<T> AtomicOption<T> {
339339
#[unsafe_destructor]
340340
impl<T> Drop for AtomicOption<T> {
341341
fn drop(&mut self) {
342-
// This will ensure that the contained data is
343-
// destroyed, unless it's null.
344-
unsafe {
345-
// FIXME(#4330) Need self by value to get mutability.
346-
let this : &mut AtomicOption<T> = cast::transmute(self);
347-
let _ = this.take(SeqCst);
348-
}
342+
let _ = self.take(SeqCst);
349343
}
350344
}
351345

0 commit comments

Comments
 (0)