else block in let-else can have different behaviour depending on build configuration. Clippy ignores it and suggests replacing let-else block with ?, completely removing #[cfg]-ed out logic.
As Clippy can’t look inside #[cfg]-ed out statements, probably it shouldn’t ever suggest removing such code.
Summary
else
block inlet-else
can have different behaviour depending on build configuration. Clippy ignores it and suggests replacinglet-else
block with?
, completely removing#[cfg]
-ed out logic.As Clippy can’t look inside
#[cfg]
-ed out statements, probably it shouldn’t ever suggest removing such code.Lint Name
clippy::question_mark
Reproducer
I tried this code:
I saw this happen:
I expected to see this happen: (no output).
Version
rustc 1.79.0 (129f3b996 2024-06-10) binary: rustc commit-hash: 129f3b9964af4d4a709d1383930ade12dfe7c081 commit-date: 2024-06-10 host: x86_64-unknown-linux-gnu release: 1.79.0 LLVM version: 18.1.7
Additional Labels
@rustbot label +I-suggestion-causes-bug