Auto merge of #12322 - sanxiyn:expression-with-attribute, r=llogiq

Be careful with expressions with attributes

Fix #9949.

changelog: [`unused_unit`]: skip expressions with attributes
This commit is contained in:
bors 2024-02-24 10:52:55 +00:00
commit 64054693eb
3 changed files with 15 additions and 0 deletions

View file

@ -58,6 +58,7 @@ impl EarlyLintPass for UnusedUnit {
&& let ctxt = block.span.ctxt()
&& stmt.span.ctxt() == ctxt
&& expr.span.ctxt() == ctxt
&& expr.attrs.is_empty()
{
let sp = expr.span;
span_lint_and_sugg(

View file

@ -94,3 +94,10 @@ mod issue9748 {
let _ = for<'a> |_: &'a u32| -> () {};
}
}
mod issue9949 {
fn main() {
#[doc = "documentation"]
()
}
}

View file

@ -94,3 +94,10 @@ mod issue9748 {
let _ = for<'a> |_: &'a u32| -> () {};
}
}
mod issue9949 {
fn main() {
#[doc = "documentation"]
()
}
}