diff options
author | Ms2ger <ms2ger@gmail.com> | 2015-01-24 16:36:54 +0100 |
---|---|---|
committer | Ms2ger <ms2ger@gmail.com> | 2015-01-24 16:43:19 +0100 |
commit | 801949556d1a697fe93495cd2417707e54e49c7e (patch) | |
tree | 8227816edbd4dfae84a23954fd44ad4d7acb1da9 | |
parent | 4c9d7ce5d071efe1ffac9f2fbb2b08bca2ca7158 (diff) | |
download | servo-801949556d1a697fe93495cd2417707e54e49c7e.tar.gz servo-801949556d1a697fe93495cd2417707e54e49c7e.zip |
Return *const T from JS::unsafe_get() (fixes #4712).
-rw-r--r-- | components/layout/wrapper.rs | 8 | ||||
-rw-r--r-- | components/script/dom/bindings/js.rs | 4 |
2 files changed, 5 insertions, 7 deletions
diff --git a/components/layout/wrapper.rs b/components/layout/wrapper.rs index 94b536e1a4e..6b8db9b1b98 100644 --- a/components/layout/wrapper.rs +++ b/components/layout/wrapper.rs @@ -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, } } } diff --git a/components/script/dom/bindings/js.rs b/components/script/dom/bindings/js.rs index e220f181a34..bc2d52a24bd 100644 --- a/components/script/dom/bindings/js.rs +++ b/components/script/dom/bindings/js.rs @@ -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> |