Skip to content

Commit

Permalink
Fix comments; minor refactoring
Browse files Browse the repository at this point in the history
  • Loading branch information
Michael Wright committed May 12, 2019
1 parent e6e3f24 commit 2efd8c6
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions clippy_lints/src/methods/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1060,13 +1060,15 @@ fn lint_or_fun_call<'a, 'tcx: 'a>(

impl<'a, 'tcx> intravisit::Visitor<'tcx> for FunCallFinder<'a, 'tcx> {
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::MethodCall(..) => true,
_ => 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 promotable = self
.cx
Expand Down Expand Up @@ -1162,7 +1164,6 @@ fn lint_or_fun_call<'a, 'tcx: 'a>(
return;
}

// ignore enum and struct constructors
let mut finder = FunCallFinder { cx: &cx, found: false };
finder.visit_expr(&arg);
if !finder.found {
Expand Down

0 comments on commit 2efd8c6

Please sign in to comment.