rust-lang / rust-lang/rust-clippy
`question_mark` false negative with and_then
Open
@profetia is already working on this.
Since Apr 21, 2026.
C-bug
I-false-negative
- Dominant language
- Rust
- Stars
- 13.5k
- Forks
- 2.2k
- Avg merge
- 2d 10h
- Merged PRs (30d)
- 32
Description
Summary
The lint does not trigger for and_then calls even when they are in return position.
Context: https://github.com/uutils/coreutils/commit/2df9af64783e04aba34812a51d35b9d2e73879f3
Reproducer: https://rust.godbolt.org/z/odMvevebj
Lint Name
question_mark
Reproducer
I tried this code:
fn foo(from: &Path, to: &Path) -> io::Result<()> {
make_fifo(to).and_then(|_| fs::remove_file(from))
}
I expected to see this happen:
Warning, with a suggestion
fn foo(from: &Path, to: &Path) -> io::Result<()> {
make_fifo(to)?;
fs::remove_file(from)
}
Instead, this happened:
No warning
Version
clippy 0.1.97 (52b6e2c208 2026-04-27)
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Assessment
This issue has not been assessed yet.