Fix unused_unit false positive

Fixes #4076
This commit is contained in:
Philipp Hansch
2019-08-24 21:42:39 +02:00
parent 56f51b35e8
commit 957dedb11d
4 changed files with 36 additions and 8 deletions

View File

@@ -277,7 +277,7 @@ impl EarlyLintPass for Return {
if_chain! {
if let Some(ref stmt) = block.stmts.last();
if let ast::StmtKind::Expr(ref expr) = stmt.node;
if is_unit_expr(expr) && !expr.span.from_expansion();
if is_unit_expr(expr) && !stmt.span.from_expansion();
then {
let sp = expr.span;
span_lint_and_then(cx, UNUSED_UNIT, sp, "unneeded unit expression", |db| {