diff options
Diffstat (limited to 'components/script_plugins/unrooted_must_root.rs')
-rw-r--r-- | components/script_plugins/unrooted_must_root.rs | 15 |
1 files changed, 11 insertions, 4 deletions
diff --git a/components/script_plugins/unrooted_must_root.rs b/components/script_plugins/unrooted_must_root.rs index ca7c70aeb75..844eb9b87e6 100644 --- a/components/script_plugins/unrooted_must_root.rs +++ b/components/script_plugins/unrooted_must_root.rs @@ -140,16 +140,16 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for UnrootedPass { if !in_derive_expn(span) { let def_id = cx.tcx.hir.local_def_id(id); - let sig = cx.tcx.type_of(def_id).fn_sig(); + let ty = cx.tcx.type_of(def_id); - for (arg, ty) in decl.inputs.iter().zip(sig.inputs().0.iter()) { + for (arg, ty) in decl.inputs.iter().zip(ty.fn_args().0.iter()) { if is_unrooted_ty(cx, ty, false) { cx.span_lint(UNROOTED_MUST_ROOT, arg.span, "Type must be rooted") } } if !in_new_function { - if is_unrooted_ty(cx, sig.output().0, false) { + if is_unrooted_ty(cx, ty.fn_ret().0, false) { cx.span_lint(UNROOTED_MUST_ROOT, decl.output.span(), "Type must be rooted") } } @@ -218,8 +218,15 @@ impl<'a, 'b, 'tcx> visit::Visitor<'tcx> for FnDefVisitor<'a, 'b, 'tcx> { visit::walk_pat(self, pat); } - fn visit_ty(&mut self, _: &'tcx hir::Ty) {} + fn visit_fn(&mut self, kind: visit::FnKind<'tcx>, decl: &'tcx hir::FnDecl, + body: hir::BodyId, span: codemap::Span, id: ast::NodeId) { + if let visit::FnKind::Closure(_) = kind { + visit::walk_fn(self, kind, decl, body, span, id); + } + } + fn visit_foreign_item(&mut self, _: &'tcx hir::ForeignItem) {} + fn visit_ty(&mut self, _: &'tcx hir::Ty) { } fn nested_visit_map<'this>(&'this mut self) -> hir::intravisit::NestedVisitorMap<'this, 'tcx> { hir::intravisit::NestedVisitorMap::OnlyBodies(&self.cx.tcx.hir) } |