Fix comments; minor refactoring

This commit is contained in:
Michael Wright 2019-05-12 10:32:19 +02:00
parent e6e3f24e0c
commit 2efd8c6e05

View File

@ -1060,13 +1060,15 @@ fn lint_or_fun_call<'a, 'tcx: 'a>(
impl<'a, 'tcx> intravisit::Visitor<'tcx> for FunCallFinder<'a, 'tcx> { impl<'a, 'tcx> intravisit::Visitor<'tcx> for FunCallFinder<'a, 'tcx> {
fn visit_expr(&mut self, expr: &'tcx hir::Expr) { fn visit_expr(&mut self, expr: &'tcx hir::Expr) {
let found = match &expr.node { let call_found = match &expr.node {
// ignore enum and struct constructors
hir::ExprKind::Call(..) => !is_ctor_function(self.cx, expr), hir::ExprKind::Call(..) => !is_ctor_function(self.cx, expr),
hir::ExprKind::MethodCall(..) => true, hir::ExprKind::MethodCall(..) => true,
_ => false, _ => false,
}; };
if found { if call_found {
// don't lint for constant values
let owner_def = self.cx.tcx.hir().get_parent_did_by_hir_id(expr.hir_id); let owner_def = self.cx.tcx.hir().get_parent_did_by_hir_id(expr.hir_id);
let promotable = self let promotable = self
.cx .cx
@ -1162,7 +1164,6 @@ fn lint_or_fun_call<'a, 'tcx: 'a>(
return; return;
} }
// ignore enum and struct constructors
let mut finder = FunCallFinder { cx: &cx, found: false }; let mut finder = FunCallFinder { cx: &cx, found: false };
finder.visit_expr(&arg); finder.visit_expr(&arg);
if !finder.found { if !finder.found {