mirror of
https://github.com/servo/servo.git
synced 2025-07-30 18:50:36 +01:00
Don't allow unrooted values in function arguments.
This commit is contained in:
parent
81ecf7824c
commit
a9ef40c716
4 changed files with 17 additions and 10 deletions
|
@ -129,17 +129,18 @@ impl LateLintPass for UnrootedPass {
|
||||||
visit::FnKind::Closure => return,
|
visit::FnKind::Closure => return,
|
||||||
};
|
};
|
||||||
|
|
||||||
if !in_new_function {
|
for arg in &decl.inputs {
|
||||||
for arg in &decl.inputs {
|
cx.tcx.ast_ty_to_ty_cache.borrow().get(&arg.ty.id).map(|t| {
|
||||||
cx.tcx.ast_ty_to_ty_cache.borrow().get(&arg.ty.id).map(|t| {
|
if is_unrooted_ty(cx, t, false) {
|
||||||
if is_unrooted_ty(cx, t, false) {
|
if in_derive_expn(cx, span) {
|
||||||
if in_derive_expn(cx, span) {
|
return;
|
||||||
return;
|
|
||||||
}
|
|
||||||
cx.span_lint(UNROOTED_MUST_ROOT, arg.ty.span, "Type must be rooted")
|
|
||||||
}
|
}
|
||||||
});
|
cx.span_lint(UNROOTED_MUST_ROOT, arg.ty.span, "Type must be rooted")
|
||||||
}
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
if !in_new_function {
|
||||||
if let hir::Return(ref ty) = decl.output {
|
if let hir::Return(ref ty) = decl.output {
|
||||||
cx.tcx.ast_ty_to_ty_cache.borrow().get(&ty.id).map(|t| {
|
cx.tcx.ast_ty_to_ty_cache.borrow().get(&ty.id).map(|t| {
|
||||||
if is_unrooted_ty(cx, t, false) {
|
if is_unrooted_ty(cx, t, false) {
|
||||||
|
|
|
@ -18,6 +18,7 @@ pub struct FileList {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl FileList {
|
impl FileList {
|
||||||
|
#[allow(unrooted_must_root)]
|
||||||
fn new_inherited(files: Vec<JS<File>>) -> FileList {
|
fn new_inherited(files: Vec<JS<File>>) -> FileList {
|
||||||
FileList {
|
FileList {
|
||||||
reflector_: Reflector::new(),
|
reflector_: Reflector::new(),
|
||||||
|
@ -25,6 +26,7 @@ impl FileList {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[allow(unrooted_must_root)]
|
||||||
pub fn new(window: &Window, files: Vec<JS<File>>) -> Root<FileList> {
|
pub fn new(window: &Window, files: Vec<JS<File>>) -> Root<FileList> {
|
||||||
reflect_dom_object(box FileList::new_inherited(files), GlobalRef::Window(window), FileListBinding::Wrap)
|
reflect_dom_object(box FileList::new_inherited(files), GlobalRef::Window(window), FileListBinding::Wrap)
|
||||||
}
|
}
|
||||||
|
|
|
@ -32,6 +32,7 @@ pub struct HTMLCollection {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl HTMLCollection {
|
impl HTMLCollection {
|
||||||
|
#[allow(unrooted_must_root)]
|
||||||
fn new_inherited(collection: Collection) -> HTMLCollection {
|
fn new_inherited(collection: Collection) -> HTMLCollection {
|
||||||
HTMLCollection {
|
HTMLCollection {
|
||||||
reflector_: Reflector::new(),
|
reflector_: Reflector::new(),
|
||||||
|
@ -39,6 +40,7 @@ impl HTMLCollection {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[allow(unrooted_must_root)]
|
||||||
pub fn new(window: &Window, collection: Collection) -> Root<HTMLCollection> {
|
pub fn new(window: &Window, collection: Collection) -> Root<HTMLCollection> {
|
||||||
reflect_dom_object(box HTMLCollection::new_inherited(collection),
|
reflect_dom_object(box HTMLCollection::new_inherited(collection),
|
||||||
GlobalRef::Window(window), HTMLCollectionBinding::Wrap)
|
GlobalRef::Window(window), HTMLCollectionBinding::Wrap)
|
||||||
|
|
|
@ -27,6 +27,7 @@ pub struct NodeList {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl NodeList {
|
impl NodeList {
|
||||||
|
#[allow(unrooted_must_root)]
|
||||||
fn new_inherited(list_type: NodeListType) -> NodeList {
|
fn new_inherited(list_type: NodeListType) -> NodeList {
|
||||||
NodeList {
|
NodeList {
|
||||||
reflector_: Reflector::new(),
|
reflector_: Reflector::new(),
|
||||||
|
@ -34,6 +35,7 @@ impl NodeList {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[allow(unrooted_must_root)]
|
||||||
pub fn new(window: &Window,
|
pub fn new(window: &Window,
|
||||||
list_type: NodeListType) -> Root<NodeList> {
|
list_type: NodeListType) -> Root<NodeList> {
|
||||||
reflect_dom_object(box NodeList::new_inherited(list_type),
|
reflect_dom_object(box NodeList::new_inherited(list_type),
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue