Summary
Clippy suggest changing an Option::and_then usage with required mutable access into a Option::filter, when the manual_filter lint is active.
Reproducer
I have the following in my code:
Uart16550Tty::new_port(0x3f8, Config::DEFAULT)
.ok()
.and_then(|mut uart| {
if uart.inner_mut().check_present() && uart.inner_mut().check_connected().is_ok() {
Some(uart)
} else {
None
}
})
clippy suggest i replace the it with
Uart16550Tty::new_port(0x3f8, Config::DEFAULT)
.ok()
.filter(|mut uart| uart.inner_mut().check_present() && uart.inner_mut().check_connected().is_ok())
which is quite obviously incorrect and doesn't compile.
Version
rustc 1.100.0-nightly (feaadeeac 2026-09-19)
binary: rustc
commit-hash: feaadeeaca7db0594da854e7c8c07495341c7439
commit-date: 2026-09-19
host: x86_64-unknown-linux-gnu
release: 1.100.0-nightly
LLVM version: 23.1.1
Additional Labels
@rustbot label +I-suggestion-causes-error
Summary
Clippy suggest changing an
Option::and_thenusage with required mutable access into aOption::filter, when themanual_filterlint is active.Reproducer
I have the following in my code:
clippy suggest i replace the it with
which is quite obviously incorrect and doesn't compile.
Version
Additional Labels
@rustbot label +I-suggestion-causes-error