Skip to content

Commit

Permalink
Fix unused_unit false positive
Browse files Browse the repository at this point in the history
Fixes #4076
  • Loading branch information
phansch committed Aug 24, 2019
1 parent 56f51b3 commit f36f520
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
2 changes: 1 addition & 1 deletion clippy_lints/src/returns.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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| {
Expand Down
13 changes: 13 additions & 0 deletions tests/ui/unused_unit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,3 +43,16 @@ fn main() {
}
return();
}

// https://github.com/rust-lang/rust-clippy/issues/4076
fn foo() {
macro_rules! foo {
(recv($r:expr) -> $res:pat => $body:expr) => {
$body
}
}

foo! {
recv(rx) -> _x => ()
}
}

0 comments on commit f36f520

Please sign in to comment.