mirror of
https://github.com/servo/servo.git
synced 2025-08-06 06:00:15 +01:00
Make unrooted_must_root a bit more aggressive.
Basically, instead of trying to check for specific kinds of statements, just check the types of all local variables. Also included are some commented-out proposals for some slightly more aggressive lints which might be useful (but trigger a little too frequently at the moment).
This commit is contained in:
parent
e3bcf7bab7
commit
81ecf7824c
4 changed files with 94 additions and 95 deletions
|
@ -310,11 +310,13 @@ impl<T: Reflectable> MutNullableHeap<JS<T>> {
|
|||
|
||||
/// Retrieve a copy of the inner optional `JS<T>` as `LayoutJS<T>`.
|
||||
/// For use by layout, which can't use safe types like Temporary.
|
||||
#[allow(unrooted_must_root)]
|
||||
pub unsafe fn get_inner_as_layout(&self) -> Option<LayoutJS<T>> {
|
||||
ptr::read(self.ptr.get()).map(|js| js.to_layout())
|
||||
}
|
||||
|
||||
/// Get a rooted value out of this object
|
||||
#[allow(unrooted_must_root)]
|
||||
pub fn get(&self) -> Option<Root<T>> {
|
||||
unsafe {
|
||||
ptr::read(self.ptr.get()).map(|o| o.root())
|
||||
|
|
|
@ -431,6 +431,7 @@ impl CanvasRenderingContext2DMethods for CanvasRenderingContext2D {
|
|||
self.ipc_renderer.send(CanvasMsg::Canvas2d(Canvas2dMsg::SaveContext)).unwrap();
|
||||
}
|
||||
|
||||
#[allow(unrooted_must_root)]
|
||||
// https://html.spec.whatwg.org/multipage/#dom-context-2d-restore
|
||||
fn Restore(&self) {
|
||||
let mut saved_states = self.saved_states.borrow_mut();
|
||||
|
|
|
@ -109,6 +109,7 @@ impl WebGLRenderingContext {
|
|||
})
|
||||
}
|
||||
|
||||
#[allow(unrooted_must_root)]
|
||||
pub fn new(global: GlobalRef, canvas: &HTMLCanvasElement, size: Size2D<i32>, attrs: GLContextAttributes)
|
||||
-> Option<Root<WebGLRenderingContext>> {
|
||||
match WebGLRenderingContext::new_inherited(global, canvas, size, attrs) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue