diff --git a/clippy_lints/src/unused_unit.rs b/clippy_lints/src/unused_unit.rs index 0a73da202ec..b70aa768b46 100644 --- a/clippy_lints/src/unused_unit.rs +++ b/clippy_lints/src/unused_unit.rs @@ -58,6 +58,7 @@ fn check_block(&mut self, cx: &EarlyContext<'_>, block: &ast::Block) { && 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( diff --git a/tests/ui/unused_unit.fixed b/tests/ui/unused_unit.fixed index 16da9a25b2a..04fe2d3b7af 100644 --- a/tests/ui/unused_unit.fixed +++ b/tests/ui/unused_unit.fixed @@ -94,3 +94,10 @@ mod issue9748 { let _ = for<'a> |_: &'a u32| -> () {}; } } + +mod issue9949 { + fn main() { + #[doc = "documentation"] + () + } +} diff --git a/tests/ui/unused_unit.rs b/tests/ui/unused_unit.rs index e374031436d..25c2ed59873 100644 --- a/tests/ui/unused_unit.rs +++ b/tests/ui/unused_unit.rs @@ -94,3 +94,10 @@ fn main() { let _ = for<'a> |_: &'a u32| -> () {}; } } + +mod issue9949 { + fn main() { + #[doc = "documentation"] + () + } +}