Skip to content

Commit 6405469

Browse files
committed
Auto merge of rust-lang#12322 - sanxiyn:expression-with-attribute, r=llogiq
Be careful with expressions with attributes Fix rust-lang#9949. changelog: [`unused_unit`]: skip expressions with attributes
2 parents 0597838 + cd45d5a commit 6405469

File tree

3 files changed

+15
-0
lines changed

3 files changed

+15
-0
lines changed

clippy_lints/src/unused_unit.rs

+1
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ impl EarlyLintPass for UnusedUnit {
5858
&& let ctxt = block.span.ctxt()
5959
&& stmt.span.ctxt() == ctxt
6060
&& expr.span.ctxt() == ctxt
61+
&& expr.attrs.is_empty()
6162
{
6263
let sp = expr.span;
6364
span_lint_and_sugg(

tests/ui/unused_unit.fixed

+7
Original file line numberDiff line numberDiff line change
@@ -94,3 +94,10 @@ mod issue9748 {
9494
let _ = for<'a> |_: &'a u32| -> () {};
9595
}
9696
}
97+
98+
mod issue9949 {
99+
fn main() {
100+
#[doc = "documentation"]
101+
()
102+
}
103+
}

tests/ui/unused_unit.rs

+7
Original file line numberDiff line numberDiff line change
@@ -94,3 +94,10 @@ mod issue9748 {
9494
let _ = for<'a> |_: &'a u32| -> () {};
9595
}
9696
}
97+
98+
mod issue9949 {
99+
fn main() {
100+
#[doc = "documentation"]
101+
()
102+
}
103+
}

0 commit comments

Comments
 (0)