mirror of
https://github.com/rust-lang/rust-clippy
synced 2025-03-02 14:27:19 +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_chain! {
|
||||||
if let Some(stmt) = block.stmts.last();
|
if let Some(stmt) = block.stmts.last();
|
||||||
if let ast::StmtKind::Expr(ref expr) = stmt.kind;
|
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 {
|
then {
|
||||||
let sp = expr.span;
|
let sp = expr.span;
|
||||||
span_lint_and_sugg(
|
span_lint_and_sugg(
|
||||||
|
|
|
@ -80,3 +80,10 @@ fn test2(){}
|
||||||
|
|
||||||
#[rustfmt::skip]
|
#[rustfmt::skip]
|
||||||
fn test3(){}
|
fn test3(){}
|
||||||
|
|
||||||
|
fn macro_expr() {
|
||||||
|
macro_rules! e {
|
||||||
|
() => (());
|
||||||
|
}
|
||||||
|
e!()
|
||||||
|
}
|
||||||
|
|
|
@ -80,3 +80,10 @@ fn test2() ->(){}
|
||||||
|
|
||||||
#[rustfmt::skip]
|
#[rustfmt::skip]
|
||||||
fn test3()-> (){}
|
fn test3()-> (){}
|
||||||
|
|
||||||
|
fn macro_expr() {
|
||||||
|
macro_rules! e {
|
||||||
|
() => (());
|
||||||
|
}
|
||||||
|
e!()
|
||||||
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue