mirror of
https://github.com/rust-lang/rust.git
synced 2025-05-14 02:49:40 +00:00
Auto merge of #7167 - camsteffen:unused-unit-macro, r=flip1995
Fix unused_unit macro false positive changelog: Fix [`unused_unit`] false positive with macros Fixes #7055
This commit is contained in:
commit
7e538e3522
@ -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 New Issue
Block a user