-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Closed
Labels
C-bugCategory: Clippy is not doing the correct thingCategory: Clippy is not doing the correct thingI-suggestion-causes-errorIssue: The suggestions provided by this Lint cause an ICE/error when appliedIssue: The suggestions provided by this Lint cause an ICE/error when applied
Description
Summary
I tried to run cargo clippy --fix
and received the following error:
after fixes were automatically applied the compiler reported errors within these files:
* src/reader/reader.rs
The following errors were reported:
error: expected one of `,`, `.`, `?`, `}`, or an operator, found `;`
--> src/reader/reader.rs:141:52
|
141 | Char::Char(ch) => self.next(ch);,
| -- ^ expected one of `,`, `.`, `?`, `}`, or an operator
| |
| while parsing the `match` arm starting here
This is the warning it was trying to fix before crashing:
warning: this let-binding has unit value
--> src/reader/reader.rs:141:39
|
141 | Char::Char(ch) => _ = self.next(ch),
| ^^^^^^^^^^^^^^^^^ help: omit the `let` binding: `self.next(ch);`
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#let_unit_value
= note: `#[warn(clippy::let_unit_value)]` on by default
It should not be inserting a semicolon in that location.
Reproducer
I tried this code:
fn do_nothing() -> () {
()
}
fn main() {
match "Example String" {
_ => _ = do_nothing(),
}
}
I expected to see this happen:
The useless let binding to be removed, and the fix to be successful.
Instead, this happened:
Clippy inserted a semi-colon where there should not be one, leading to a syntax error.
Version
rustc 1.90.0 (1159e78c4 2025-09-14)
binary: rustc
commit-hash: 1159e78c4747b02ef996e55082b704c09b970588
commit-date: 2025-09-14
host: x86_64-unknown-linux-gnu
release: 1.90.0
LLVM version: 20.1.8
Additional Labels
@rustbot label +I-suggestion-causes-error
Metadata
Metadata
Assignees
Labels
C-bugCategory: Clippy is not doing the correct thingCategory: Clippy is not doing the correct thingI-suggestion-causes-errorIssue: The suggestions provided by this Lint cause an ICE/error when appliedIssue: The suggestions provided by this Lint cause an ICE/error when applied