fix no_effect lint

This commit is contained in:
Oliver Schneider 2016-05-25 18:51:35 +02:00
parent 77ed899941
commit bb69e60b30
No known key found for this signature in database
GPG key ID: 56D6EEA0FC67AC46
2 changed files with 11 additions and 5 deletions

View file

@ -1,6 +1,6 @@
use rustc::lint::{LateContext, LateLintPass, LintArray, LintPass};
use rustc::hir::def::{Def, PathResolution};
use rustc::hir::{Expr, Expr_, Stmt, StmtSemi};
use rustc::hir::{Expr, Expr_, Stmt, StmtSemi, BlockCheckMode, UnsafeSource};
use utils::{in_macro, span_lint, snippet_opt, span_lint_and_then};
use std::ops::Deref;
@ -140,11 +140,11 @@ fn reduce_expression<'a>(cx: &LateContext, expr: &'a Expr) -> Option<Vec<&'a Exp
}
Expr_::ExprBlock(ref block) => {
if block.stmts.is_empty() {
block.expr.as_ref().and_then(|e| if e.span == expr.span {
block.expr.as_ref().and_then(|e| match block.rules {
BlockCheckMode::UnsafeBlock(UnsafeSource::UserProvided) => None,
BlockCheckMode::DefaultBlock => Some(vec![&**e]),
// in case of compiler-inserted signaling blocks
reduce_expression(cx, e)
} else {
Some(vec![e])
_ => reduce_expression(cx, e),
})
} else {
None