Closed
Description
Summary
#[allow(clippy::needless_question_mark)]
does not seems to prevent the lint from firing when it's applied on the last statement of a block, and is implicitly returned.
It's properly taken into account when using #![allow(clippy::needless_question_mark)]
on the whole block, or when assigning let _ = Some(a?);
.
Lint Name
needless_question_mark
Reproducer
I tried this code:
#![deny(clippy::all)]
fn some_function() -> Option<()> {
let a = Some(());
#[allow(clippy::needless_question_mark)]
Some(a?)
}
I saw this happen:
error: question mark operator is useless here
--> src/lib.rs:6:5
|
6 | Some(a?)
| ^^^^^^^^ help: try removing question mark and `Some()`: `a`
|
note: the lint level is defined here
--> src/lib.rs:1:9
|
1 | #![deny(clippy::all)]
| ^^^^^^^^^^^
= note: `#[deny(clippy::needless_question_mark)]` implied by `#[deny(clippy::all)]`
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_question_mark
I expected to see this happen:
No error since this lint is disabled.
Version
rustc 1.60.0-nightly (27f5d830e 2022-02-02)
binary: rustc
commit-hash: 27f5d830eb11cd7bdc834d6f0d78120976f75443
commit-date: 2022-02-02
host: x86_64-unknown-linux-gnu
release: 1.60.0-nightly
LLVM version: 13.0.0
Additional Labels
No response