Auto merge of #13173 - servo:transmute_copy, r=Manishearth

Stop using mem::transmute_copy.

<!-- Reviewable:start -->
This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/13173)
<!-- Reviewable:end -->
This commit is contained in:
bors-servo 2016-09-05 03:11:48 -05:00 committed by GitHub
commit 5f702d6e7f
2 changed files with 10 additions and 5 deletions

View file

@ -126,7 +126,10 @@ impl<T: Castable> LayoutJS<T> {
T: DerivedFrom<U>
{
debug_assert!(thread_state::get().is_layout());
unsafe { mem::transmute_copy(self) }
let ptr: *const T = *self.ptr;
LayoutJS {
ptr: unsafe { NonZero::new(ptr as *const U) },
}
}
/// Cast a DOM object downwards to one of the interfaces it might implement.
@ -136,7 +139,10 @@ impl<T: Castable> LayoutJS<T> {
debug_assert!(thread_state::get().is_layout());
unsafe {
if (*self.unsafe_get()).is::<U>() {
Some(mem::transmute_copy(self))
let ptr: *const T = *self.ptr;
Some(LayoutJS {
ptr: NonZero::new(ptr as *const U),
})
} else {
None
}

View file

@ -51,7 +51,7 @@ use selectors::matching::ElementFlags;
use selectors::parser::{AttrSelector, NamespaceConstraint};
use std::fmt;
use std::marker::PhantomData;
use std::mem::{transmute, transmute_copy};
use std::mem::transmute;
use std::sync::Arc;
use string_cache::{Atom, Namespace};
use style::attr::AttrValue;
@ -119,8 +119,7 @@ impl<'ln> TNode for ServoLayoutNode<'ln> {
fn to_unsafe(&self) -> UnsafeNode {
unsafe {
let ptr: usize = transmute_copy(self);
(ptr, 0)
(self.node.unsafe_get() as usize, 0)
}
}