mirror of
https://github.com/servo/servo.git
synced 2025-07-29 10:10:34 +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,
|
||||
};
|
||||
|
||||
if !in_new_function {
|
||||
for arg in &decl.inputs {
|
||||
cx.tcx.ast_ty_to_ty_cache.borrow().get(&arg.ty.id).map(|t| {
|
||||
if is_unrooted_ty(cx, t, false) {
|
||||
if in_derive_expn(cx, span) {
|
||||
return;
|
||||
}
|
||||
cx.span_lint(UNROOTED_MUST_ROOT, arg.ty.span, "Type must be rooted")
|
||||
for arg in &decl.inputs {
|
||||
cx.tcx.ast_ty_to_ty_cache.borrow().get(&arg.ty.id).map(|t| {
|
||||
if is_unrooted_ty(cx, t, false) {
|
||||
if in_derive_expn(cx, span) {
|
||||
return;
|
||||
}
|
||||
});
|
||||
}
|
||||
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 {
|
||||
cx.tcx.ast_ty_to_ty_cache.borrow().get(&ty.id).map(|t| {
|
||||
if is_unrooted_ty(cx, t, false) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue