diff options
| author | bors <bors@rust-lang.org> | 2024-02-24 10:52:55 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2024-02-24 10:52:55 +0000 |
| commit | 64054693eb35cd0b80d3eee598f723a2b2df2e8f (patch) | |
| tree | f2b59c80692ebc6ba417d0c379370488f5388900 | |
| parent | 05978388922a0734fe67dd75d884794b0c0d2f59 (diff) | |
| parent | cd45d5a81c239ccced418604c8f60a4e5338c1e0 (diff) | |
| download | rust-64054693eb35cd0b80d3eee598f723a2b2df2e8f.tar.gz rust-64054693eb35cd0b80d3eee598f723a2b2df2e8f.zip | |
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
| -rw-r--r-- | clippy_lints/src/unused_unit.rs | 1 | ||||
| -rw-r--r-- | tests/ui/unused_unit.fixed | 7 | ||||
| -rw-r--r-- | tests/ui/unused_unit.rs | 7 |
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"] + () + } +} |
