Skip to content

FP unnecessary-semicolon #14100

@matthiaskrgr

Description

@matthiaskrgr

Summary

.

Lint Name

unnecessary-semicolon

Reproducer

I tried this code:

//@ run-pass

#![allow(irrefutable_let_patterns)]

fn _f1() -> bool {
	if let _ = return true && false {};
}

pub fn main() {}

I saw this happen:

warning: unnecessary semicolon
 --> ./tests/ui/rfcs/rfc-2497-if-let-chains/protect-precedences.rs:6:36
  |
6 |     if let _ = return true && false {};
  |                                       ^ help: remove
  |
  = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#unnecessary_semicolon
  = note: requested on the command line with `--force-warn clippy::unnecessary-semicolon`

warning: 3 warnings emitted

I expected to see this happen:
removing it breaks the build

error[E0308]: mismatched types
 --> o.rs:4:34
  |
4 |     if let _ = return true && false {}
  |                                     ^^ expected `bool`, found `()`

error: aborting due to 1 previous error; 1 warning emitted

Version

rustc 1.86.0-nightly (ccc9ba5c3 2025-01-29)
binary: rustc
commit-hash: ccc9ba5c30c675824e9ca62b960830ff4a1858ea
commit-date: 2025-01-29
host: x86_64-unknown-linux-gnu
release: 1.86.0-nightly
LLVM version: 19.1.7

Additional Labels

No response

Metadata

Metadata

Assignees

Labels

C-bugCategory: Clippy is not doing the correct thingI-false-positiveIssue: The lint was triggered on code it shouldn't haveI-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