Skip to content

question_mark doesn't identify the canonical form of ? for Result #15679

@samueltardieu

Description

@samueltardieu

Summary

The expansion of x? when x is a Result looks like:

match x {
    Ok(v) => v,
    Err(e) => return Err(e.into()),
}

The question_mark doesn't recognize this, it only recognizes the simplest form without .into() while this is applicable only when the type of the Err variant stays unchanged.

Lint Name

question_mark

Reproducer

This was noticed by @cakebaker and @sylvestre in a uutils code review.

Reproducers will be included as tests in the PR to come.

Version

rustc 1.92.0-nightly (52618eb33 2025-09-14)
binary: rustc
commit-hash: 52618eb338609df44978b0ca4451ab7941fd1c7a
commit-date: 2025-09-14
host: x86_64-unknown-linux-gnu
release: 1.92.0-nightly
LLVM version: 21.1.1

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

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions