Fix unwrap.rs

This commit is contained in:
Manish Goregaokar 2019-05-10 19:13:15 -07:00
parent e7af60f258
commit 62897747fd

View File

@ -2,7 +2,7 @@
use rustc::lint::{LateContext, LateLintPass, LintArray, LintPass};
use rustc::{declare_lint_pass, declare_tool_lint};
use crate::utils::{in_macro, match_type, paths, span_lint_and_then, usage::is_potentially_mutated};
use crate::utils::{higher::if_block, in_macro, match_type, paths, span_lint_and_then, usage::is_potentially_mutated};
use rustc::hir::intravisit::*;
use rustc::hir::*;
use syntax::source_map::Span;
@ -130,7 +130,7 @@ fn visit_branch(&mut self, cond: &'tcx Expr, branch: &'tcx Expr, else_branch: bo
impl<'a, 'tcx: 'a> Visitor<'tcx> for UnwrappableVariablesVisitor<'a, 'tcx> {
fn visit_expr(&mut self, expr: &'tcx Expr) {
if let ExprKind::If(cond, then, els) = &expr.node {
if let Some((cond, then, els)) = if_block(&expr) {
walk_expr(self, cond);
self.visit_branch(cond, then, false);
if let Some(els) = els {