mirror of
https://github.com/rust-lang/rust-clippy
synced 2024-11-10 15:14:29 +00:00
Fix unused_unit macro false positive
This commit is contained in:
parent
a8f28b6365
commit
83329ec705
3 changed files with 17 additions and 1 deletions
|
@ -47,7 +47,9 @@ impl EarlyLintPass for UnusedUnit {
|
|||
if_chain! {
|
||||
if let Some(stmt) = block.stmts.last();
|
||||
if let ast::StmtKind::Expr(ref expr) = stmt.kind;
|
||||
if is_unit_expr(expr) && !stmt.span.from_expansion();
|
||||
if is_unit_expr(expr);
|
||||
let ctxt = block.span.ctxt();
|
||||
if stmt.span.ctxt() == ctxt && expr.span.ctxt() == ctxt;
|
||||
then {
|
||||
let sp = expr.span;
|
||||
span_lint_and_sugg(
|
||||
|
|
|
@ -80,3 +80,10 @@ fn test2(){}
|
|||
|
||||
#[rustfmt::skip]
|
||||
fn test3(){}
|
||||
|
||||
fn macro_expr() {
|
||||
macro_rules! e {
|
||||
() => (());
|
||||
}
|
||||
e!()
|
||||
}
|
||||
|
|
|
@ -80,3 +80,10 @@ fn test2() ->(){}
|
|||
|
||||
#[rustfmt::skip]
|
||||
fn test3()-> (){}
|
||||
|
||||
fn macro_expr() {
|
||||
macro_rules! e {
|
||||
() => (());
|
||||
}
|
||||
e!()
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue