rust-lang / rust-lang/rust-clippy
`question_mark` suggestion has redundant block scope
Open
@profetia is already working on this.
Since Apr 28, 2026.
C-bug
L-suggestion
- Dominant language
- Rust
- Stars
- 13.5k
- Forks
- 2.2k
- Avg merge
- 2d 10h
- Merged PRs (30d)
- 32
Description
Summary
The current suggestion introduces an unnecessary block scope { ... } when converting the if let ... else return None pattern into the ? operator form.
Context: https://github.com/fish-shell/fish-shell/commit/f385266719297d11bd7f941f7a66221e7c715dfc
Reproducer: https://rust.godbolt.org/z/hrszPr5xc
cc: @profetia
Reproducer
Code:
if let Some(x) = Some(1) {
black_box(x);
} else {
return None;
}
Some(())
Current output:
{
let x = Some(1)?;
black_box(x);
}
Some(())
Desired output:
let x = Some(1)?;
black_box(x);
Some(())
Version
clippy 0.1.97 (0febdbab27 2026-04-18)
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.