remove unnecessary transmutes

This commit is contained in:
Daniel Micay 2013-09-17 11:44:59 -04:00
parent 29cdf58861
commit befc561fa4
4 changed files with 8 additions and 28 deletions

View File

@ -198,7 +198,6 @@ impl Database {
}
}
// FIXME #4330: use &mut self here
#[unsafe_destructor]
impl Drop for Database {
fn drop(&mut self) {

View File

@ -78,17 +78,14 @@ impl<T> Drop for RC<T> {
assert!(self.refcount() > 0);
unsafe {
// FIXME(#4330) Need self by value to get mutability.
let this: &mut RC<T> = cast::transmute_mut(self);
match *this.get_mut_state() {
match *self.get_mut_state() {
(ref mut count, _) => {
*count = *count - 1
}
}
if this.refcount() == 0 {
let _: ~(uint, T) = cast::transmute(this.p);
if self.refcount() == 0 {
let _: ~(uint, T) = cast::transmute(self.p);
}
}
}

View File

@ -188,11 +188,7 @@ impl UvEventLoop {
impl Drop for UvEventLoop {
fn drop(&mut self) {
// XXX: Need mutable finalizer
let this = unsafe {
transmute::<&UvEventLoop, &mut UvEventLoop>(self)
};
this.uvio.uv_loop().close();
self.uvio.uv_loop().close();
}
}
@ -648,9 +644,7 @@ impl UvTcpListener {
impl Drop for UvTcpListener {
fn drop(&mut self) {
// XXX need mutable finalizer
let self_ = unsafe { transmute::<&UvTcpListener, &mut UvTcpListener>(self) };
do self_.home_for_io_with_sched |self_, scheduler| {
do self.home_for_io_with_sched |self_, scheduler| {
do scheduler.deschedule_running_task_and_then |_, task| {
let task = Cell::new(task);
do self_.watcher.as_stream().close {
@ -763,9 +757,7 @@ impl HomingIO for UvTcpStream {
impl Drop for UvTcpStream {
fn drop(&mut self) {
// XXX need mutable finalizer
let this = unsafe { transmute::<&UvTcpStream, &mut UvTcpStream>(self) };
do this.home_for_io_with_sched |self_, scheduler| {
do self.home_for_io_with_sched |self_, scheduler| {
do scheduler.deschedule_running_task_and_then |_, task| {
let task_cell = Cell::new(task);
do self_.watcher.as_stream().close {
@ -922,9 +914,7 @@ impl HomingIO for UvUdpSocket {
impl Drop for UvUdpSocket {
fn drop(&mut self) {
// XXX need mutable finalizer
let this = unsafe { transmute::<&UvUdpSocket, &mut UvUdpSocket>(self) };
do this.home_for_io_with_sched |self_, scheduler| {
do self.home_for_io_with_sched |self_, scheduler| {
do scheduler.deschedule_running_task_and_then |_, task| {
let task_cell = Cell::new(task);
do self_.watcher.close {

View File

@ -339,13 +339,7 @@ impl<T> AtomicOption<T> {
#[unsafe_destructor]
impl<T> Drop for AtomicOption<T> {
fn drop(&mut self) {
// This will ensure that the contained data is
// destroyed, unless it's null.
unsafe {
// FIXME(#4330) Need self by value to get mutability.
let this : &mut AtomicOption<T> = cast::transmute(self);
let _ = this.take(SeqCst);
}
let _ = self.take(SeqCst);
}
}