Skip to content

Commit

Permalink
Be careful with expressions with attributes
Browse files Browse the repository at this point in the history
  • Loading branch information
sanxiyn committed Feb 20, 2024
1 parent 6aa5f1a commit cd45d5a
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 0 deletions.
1 change: 1 addition & 0 deletions clippy_lints/src/unused_unit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
7 changes: 7 additions & 0 deletions tests/ui/unused_unit.fixed
Original file line number Diff line number Diff line change
Expand Up @@ -94,3 +94,10 @@ mod issue9748 {
let _ = for<'a> |_: &'a u32| -> () {};
}
}

mod issue9949 {
fn main() {
#[doc = "documentation"]
()
}
}
7 changes: 7 additions & 0 deletions tests/ui/unused_unit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -94,3 +94,10 @@ mod issue9748 {
let _ = for<'a> |_: &'a u32| -> () {};
}
}

mod issue9949 {
fn main() {
#[doc = "documentation"]
()
}
}

0 comments on commit cd45d5a

Please sign in to comment.