servo: Merge #8731 - Fix false positive in unrooted_must_root lint (from eefriedman:root-lint-pattern); r=Manishearth

Encountered in #8725.

Source-Repo: https://github.com/servo/servo
Source-Revision: 2a125b56135cdaa86b49783e8a52e9f1e9c7c126
This commit is contained in:
Eli Friedman 2015-11-30 23:55:03 +05:01
Родитель 9d66fcc7fd
Коммит dec6565089
1 изменённых файлов: 8 добавлений и 5 удалений

Просмотреть файл

@ -4,6 +4,7 @@
use rustc::front::map as ast_map; use rustc::front::map as ast_map;
use rustc::lint::{LateContext, LintPass, LintArray, LateLintPass, LintContext}; use rustc::lint::{LateContext, LintPass, LintArray, LateLintPass, LintContext};
use rustc::middle::pat_util::pat_is_binding;
use rustc::middle::ty; use rustc::middle::ty;
use rustc_front::hir; use rustc_front::hir;
use rustc_front::intravisit as visit; use rustc_front::intravisit as visit;
@ -206,11 +207,13 @@ impl<'a, 'b: 'a, 'tcx: 'a+'b> visit::Visitor<'a> for FnDefVisitor<'a, 'b, 'tcx>
let cx = self.cx; let cx = self.cx;
if let hir::PatIdent(hir::BindByValue(_), _, _) = pat.node { if let hir::PatIdent(hir::BindByValue(_), _, _) = pat.node {
let ty = cx.tcx.pat_ty(pat); if pat_is_binding(&cx.tcx.def_map.borrow(), pat) {
if is_unrooted_ty(cx, ty, self.in_new_function) { let ty = cx.tcx.pat_ty(pat);
cx.span_lint(UNROOTED_MUST_ROOT, if is_unrooted_ty(cx, ty, self.in_new_function) {
pat.span, cx.span_lint(UNROOTED_MUST_ROOT,
&format!("Expression of type {:?} must be rooted", ty)) pat.span,
&format!("Expression of type {:?} must be rooted", ty))
}
} }
} }