about summary refs log tree commit diff
path: root/clippy_lints
diff options
context:
space:
mode:
authorAda Alakbarova <ada.alakbarova@proton.me>2025-08-12 19:06:28 +0200
committerAda Alakbarova <ada.alakbarova@proton.me>2025-08-12 19:12:47 +0200
commitaf2dd2d3bcfe5ed049068a9fd8eb6e295bed654b (patch)
tree81d0d6a1e06c789e18d913a0132327cd9b9ae680 /clippy_lints
parent874f1c8dc0b3362799173f9e690b1cad8f081eaf (diff)
downloadrust-af2dd2d3bcfe5ed049068a9fd8eb6e295bed654b.tar.gz
rust-af2dd2d3bcfe5ed049068a9fd8eb6e295bed654b.zip
fix `unnecessary_semicolon`: don't lint on stmts with attrs
Diffstat (limited to 'clippy_lints')
-rw-r--r--clippy_lints/src/unnecessary_semicolon.rs2
1 files changed, 2 insertions, 0 deletions
diff --git a/clippy_lints/src/unnecessary_semicolon.rs b/clippy_lints/src/unnecessary_semicolon.rs
index f1d1a76d0c2..3d660a267a6 100644
--- a/clippy_lints/src/unnecessary_semicolon.rs
+++ b/clippy_lints/src/unnecessary_semicolon.rs
@@ -87,6 +87,8 @@ impl<'tcx> LateLintPass<'tcx> for UnnecessarySemicolon {
                 ExprKind::If(..) | ExprKind::Match(_, _, MatchSource::Normal | MatchSource::Postfix)
             )
             && cx.typeck_results().expr_ty(expr) == cx.tcx.types.unit
+            // if a stmt has attrs, then turning it into an expr will break the code, since attrs aren't allowed on exprs
+            && cx.tcx.hir_attrs(stmt.hir_id).is_empty()
         {
             if let Some(block_is_unit) = self.is_last_in_block(stmt) {
                 if cx.tcx.sess.edition() <= Edition2021 && leaks_droppable_temporary_with_limited_lifetime(cx, expr) {