-
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 thing
Description
Summary
When auto-fixing a particular bool_to_int_with_if
the code fix does not compile. The current suggestion does not seem to work with if let
.
Reproducer
I tried this code:
enum Kind {
A,
#[allow(dead_code)]
B,
}
fn main() {
let kind = Kind::A;
let kind_num = if let Kind::A = kind { 1u8 } else { 0 };
eprintln!("{kind_num}");
}
This produces the following bad suggestion.
let kind_num = u8::from(let Kind::A = kind);
Version
rustc 1.65.0 (897e37553 2022-11-02)
binary: rustc
commit-hash: 897e37553bba8b42751c67658967889d11ecd120
commit-date: 2022-11-02
host: x86_64-unknown-linux-gnu
release: 1.65.0
LLVM version: 15.0.0
Additional Labels
No response
Metadata
Metadata
Assignees
Labels
C-bugCategory: Clippy is not doing the correct thingCategory: Clippy is not doing the correct thing