Skip to content

question_mark false negative with and_then #16893

@xtqqczze

Description

@xtqqczze

Summary

The lint does not trigger for and_then calls even when they are in return position.

Context: uutils/coreutils@2df9af6
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)

Metadata

Metadata

Assignees

Labels

C-bugCategory: Clippy is not doing the correct thingI-false-negativeIssue: The lint should have been triggered on code, but wasn't

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions