Skip to content

semicolon_inside_block creates what looks like a function call #15389

@ada4a

Description

@ada4a

Description

Description

This code:

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

pub fn main() {
    ({0});
    (0);
}

caused the following diagnostics:

warning: consider moving the `;` inside the block for consistent formatting
 --> src/main.rs:5:5
  |
5 |     ({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
  |
5 -     ({0});
5 +     ({0;}
  |

The suggestion actually needed to look like as follows:

({0;})

but is currently broken because of #15380

However, even if I apply the latter suggestion, the resulting code:

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

pub fn main() {
    ({0;})
    (0);
}

will no longer compile:

error[E0618]: expected function, found `()`
 --> src/lib.rs:5:5
  |
5 |       ({0;})
  |       -^^^^^- help: consider using a semicolon here to finish the statement: `;`
  |  _____|
  | |
6 | |     (0);
  | |_______- call expression requires function

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

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