Open
Description
Summary
Incorrect suggestion by manual_is_variant_and
Reproducer
I tried this code:
#![deny(clippy::manual_is_variant_and)]
fn main() {
let xs = [None, Some(b'_'), Some(b'1')];
for x in xs {
let a1 = dbg!(x.map(|b| b.is_ascii_digit()) != Some(true));
let a2 = dbg!(x.is_none_or(|b| b.is_ascii_digit()));
assert_eq!(a1, a2);
}
}
error: called `.map() != Some()`
--> src/main.rs:6:18
|
6 | let a1 = x.map(|b| b.is_ascii_digit()) != Some(true);
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use: `x.is_none_or(|b| b.is_ascii_digit())`
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#manual_is_variant_and
note: the lint level is defined here
--> src/main.rs:1:9
|
1 | #![deny(clippy::manual_is_variant_and)]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
I expected to see this happen:
Instead, this happened:
Compiling playground v0.0.1 (/playground)
Finished `dev` profile [unoptimized + debuginfo] target(s) in 0.45s
Running `target/debug/playground`
[src/main.rs:6:18] x.map(|b| b.is_ascii_digit()) != Some(true) = true
[src/main.rs:7:18] x.is_none_or(|b| b.is_ascii_digit()) = true
[src/main.rs:6:18] x.map(|b| b.is_ascii_digit()) != Some(true) = true
[src/main.rs:7:18] x.is_none_or(|b| b.is_ascii_digit()) = false
thread 'main' panicked at src/main.rs:8:9:
assertion `left == right` failed
left: true
right: false
Version
rustc 1.90.0-nightly (667787527 2025-07-02)
binary: rustc
commit-hash: 6677875279b560442a07a08d5119b4cd6b3c5593
commit-date: 2025-07-02
host: x86_64-unknown-linux-gnu
release: 1.90.0-nightly
LLVM version: 20.1.7
Additional Labels
@rustbot label +I-suggestion-causes-bug