More uses of higher::if_block

This commit is contained in:
Manish Goregaokar
2019-05-10 19:34:47 -07:00
parent 69b1da4d82
commit c9ed92ce20
4 changed files with 12 additions and 14 deletions

View File

@@ -1,5 +1,5 @@
use crate::utils::SpanlessEq;
use crate::utils::{get_item_name, match_type, paths, snippet, span_lint_and_then, walk_ptrs_ty};
use crate::utils::{get_item_name, higher, match_type, paths, snippet, span_lint_and_then, walk_ptrs_ty};
use if_chain::if_chain;
use rustc::hir::intravisit::{walk_expr, NestedVisitorMap, Visitor};
use rustc::hir::*;
@@ -41,7 +41,7 @@ declare_lint_pass!(HashMapPass => [MAP_ENTRY]);
impl<'a, 'tcx> LateLintPass<'a, 'tcx> for HashMapPass {
fn check_expr(&mut self, cx: &LateContext<'a, 'tcx>, expr: &'tcx Expr) {
if let ExprKind::If(ref check, ref then_block, ref else_block) = expr.node {
if let Some((ref check, ref then_block, ref else_block)) = higher::if_block(&expr) {
if let ExprKind::Unary(UnOp::UnNot, ref check) = check.node {
if let Some((ty, map, key)) = check_cond(cx, check) {
// in case of `if !m.contains_key(&k) { m.insert(k, v); }`