Fix LayoutDom::unsafe_get

The raw pointer can be used to extend the lifetime of the inner T
to beyond 'dom.
This commit is contained in:
Anthony Ramine 2020-03-29 19:57:47 +02:00
parent 4279fe5933
commit ea9e62bdca

View file

@ -748,12 +748,11 @@ impl<'dom, T> LayoutDom<'dom, T>
where where
T: 'dom + DomObject, T: 'dom + DomObject,
{ {
/// Returns an unsafe pointer to the interior of this JS object. This is /// Returns a reference to the interior of this JS object. The fact
/// the only method that be safely accessed from layout. (The fact that /// that this is unsafe is what necessitates the layout wrappers.
/// this is unsafe is what necessitates the layout wrappers.) pub unsafe fn unsafe_get(self) -> &'dom T {
pub unsafe fn unsafe_get(&self) -> *const T {
debug_assert!(thread_state::get().is_layout()); debug_assert!(thread_state::get().is_layout());
self.ptr.as_ptr() &*self.ptr.as_ptr()
} }
} }