about summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--clippy_lints/src/unused_unit.rs1
-rw-r--r--tests/ui/unused_unit.fixed7
-rw-r--r--tests/ui/unused_unit.rs7
3 files changed, 15 insertions, 0 deletions
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 @@ 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(
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 @@ mod issue9748 {
         let _ = for<'a> |_: &'a u32| -> () {};
     }
 }
+
+mod issue9949 {
+    fn main() {
+        #[doc = "documentation"]
+        ()
+    }
+}