From fb7e325900658c6731290a91348f9c791c79e130 Mon Sep 17 00:00:00 2001 From: Seo Sanghyeon Date: Wed, 28 Oct 2015 01:08:46 +0900 Subject: [PATCH] Use `if let` --- src/librustc_lint/types.rs | 7 ++----- src/librustc_lint/unused.rs | 12 ++++-------- 2 files changed, 6 insertions(+), 13 deletions(-) diff --git a/src/librustc_lint/types.rs b/src/librustc_lint/types.rs index c95d8b7bf3e..feb4b0afd8a 100644 --- a/src/librustc_lint/types.rs +++ b/src/librustc_lint/types.rs @@ -659,10 +659,8 @@ impl LateLintPass for ImproperCTypes { } } - match it.node { - hir::ItemForeignMod(ref nmod) - if nmod.abi != abi::RustIntrinsic && - nmod.abi != abi::PlatformIntrinsic => { + if let hir::ItemForeignMod(ref nmod) = it.node { + if nmod.abi != abi::RustIntrinsic && nmod.abi != abi::PlatformIntrinsic { for ni in &nmod.items { match ni.node { hir::ForeignItemFn(ref decl, _) => check_foreign_fn(cx, &**decl), @@ -670,7 +668,6 @@ impl LateLintPass for ImproperCTypes { } } } - _ => (), } } } diff --git a/src/librustc_lint/unused.rs b/src/librustc_lint/unused.rs index 8ed4706b1ce..b282d1975fe 100644 --- a/src/librustc_lint/unused.rs +++ b/src/librustc_lint/unused.rs @@ -220,15 +220,11 @@ impl LintPass for PathStatements { impl LateLintPass for PathStatements { fn check_stmt(&mut self, cx: &LateContext, s: &hir::Stmt) { - match s.node { - hir::StmtSemi(ref expr, _) => { - match expr.node { - hir::ExprPath(..) => cx.span_lint(PATH_STATEMENTS, s.span, - "path statement with no effect"), - _ => () - } + if let hir::StmtSemi(ref expr, _) = s.node { + if let hir::ExprPath(..) = expr.node { + cx.span_lint(PATH_STATEMENTS, s.span, + "path statement with no effect"); } - _ => () } } }