auto merge of #4713 : Ms2ger/servo/unsafe_get-const, r=jdm

This commit is contained in:
bors-servo 2015-01-24 08:48:48 -07:00
commit ff8cbff810
2 changed files with 5 additions and 7 deletions

View file

@ -369,10 +369,8 @@ impl<'ln> TNode<'ln, LayoutElement<'ln>> for LayoutNode<'ln> {
None => panic!("not an element")
};
let element = &*elem.unsafe_get();
LayoutElement {
element: mem::transmute(element),
element: &*elem.unsafe_get(),
}
}
}
@ -719,7 +717,7 @@ impl<'ln> TLayoutNode for ThreadSafeLayoutNode<'ln> {
}
unsafe fn get<'a>(&'a self) -> &'a Node { // this change.
mem::transmute::<*mut Node,&'a Node>(self.get_jsmanaged().unsafe_get())
&*self.get_jsmanaged().unsafe_get()
}
fn first_child(&self) -> Option<ThreadSafeLayoutNode<'ln>> {
@ -819,7 +817,7 @@ impl<'ln> ThreadSafeLayoutNode<'ln> {
// FIXME(pcwalton): Workaround until Rust gets multiple lifetime parameters on
// implementations.
ThreadSafeLayoutElement {
element: &mut *element,
element: &*element,
}
}
}

View file

@ -311,8 +311,8 @@ impl<T: Reflectable> JS<T> {
/// Returns an unsafe pointer to the interior of this object. This is the
/// only method that be safely accessed from layout. (The fact that this is
/// unsafe is what necessitates the layout wrappers.)
pub unsafe fn unsafe_get(&self) -> *mut T {
self.ptr as *mut T
pub unsafe fn unsafe_get(&self) -> *const T {
self.ptr
}
/// Store an unrooted value in this field. This is safe under the assumption that JS<T>