Skip to content

Commit

Permalink
Fix false positive in unrooted_must_root lint.
Browse files Browse the repository at this point in the history
Encountered in #8725.
  • Loading branch information
eefriedman committed Nov 30, 2015
1 parent 2d164f2 commit 962c06e
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions components/plugins/lints/unrooted_must_root.rs
Expand Up @@ -4,6 +4,7 @@

use rustc::front::map as ast_map;
use rustc::lint::{LateContext, LintPass, LintArray, LateLintPass, LintContext};
use rustc::middle::pat_util::pat_is_binding;
use rustc::middle::ty;
use rustc_front::hir;
use rustc_front::intravisit as visit;
Expand Down Expand Up @@ -206,11 +207,13 @@ impl<'a, 'b: 'a, 'tcx: 'a+'b> visit::Visitor<'a> for FnDefVisitor<'a, 'b, 'tcx>
let cx = self.cx;

if let hir::PatIdent(hir::BindByValue(_), _, _) = pat.node {
let ty = cx.tcx.pat_ty(pat);
if is_unrooted_ty(cx, ty, self.in_new_function) {
cx.span_lint(UNROOTED_MUST_ROOT,
pat.span,
&format!("Expression of type {:?} must be rooted", ty))
if pat_is_binding(&cx.tcx.def_map.borrow(), pat) {
let ty = cx.tcx.pat_ty(pat);
if is_unrooted_ty(cx, ty, self.in_new_function) {
cx.span_lint(UNROOTED_MUST_ROOT,
pat.span,
&format!("Expression of type {:?} must be rooted", ty))
}
}
}

Expand Down

0 comments on commit 962c06e

Please sign in to comment.