Skip to content

semicolon_inside_block turns stmts into exprs, breaking attributes #15388

@ada4a

Description

@ada4a

Description

This code:

#![allow(clippy::no_effect, unused_must_use)]
#![warn(clippy::semicolon_inside_block)]

pub fn main() {
    #[rustfmt::skip]
    {0; 0};
}

caused the following diagnostics:

warning: consider moving the `;` inside the block for consistent formatting
 --> src/main.rs:6:5
  |
6 |     {0; 0};
  |     ^^^^^^^
  |
  = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#semicolon_inside_block
note: the lint level is defined here
 --> src/main.rs:2:9
  |
2 | #![warn(clippy::semicolon_inside_block)]
  |         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
help: put the `;` here
  |
6 -     {0; 0};
6 +     {0; 0;}
  |

However after applying these diagnostics, the resulting code:

#![allow(clippy::no_effect, unused_must_use)]
#![warn(clippy::semicolon_inside_block)]

pub fn main() {
    #[rustfmt::skip]
    {0; 0;}
}

no longer compiled:

error[E0658]: attributes on expressions are experimental
 --> src/main.rs:5:5
  |
5 |     #[rustfmt::skip]
  |     ^^^^^^^^^^^^^^^^
  |
  = note: see issue #15701 <https://github.com/rust-lang/rust/issues/15701> for more information
  = help: add `#![feature(stmt_expr_attributes)]` to the crate attributes to enable
  = note: this compiler was built on 2025-08-01; consider upgrading it if it is out of date

For more information about this error, try `rustc --explain E0658`.

Version

rustc 1.90.0-nightly (cc0a5b730 2025-07-31)
binary: rustc
commit-hash: cc0a5b73053c62a3df5f84b3ee85079c9b65fa87
commit-date: 2025-07-31
host: x86_64-unknown-linux-gnu
release: 1.90.0-nightly
LLVM version: 20.1.8

Additional Labels

@rustbot label +I-suggestion-causes-error

Metadata

Metadata

Assignees

No one assigned

    Labels

    I-suggestion-causes-errorIssue: The suggestions provided by this Lint cause an ICE/error when applied

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions