clippy::question_mark suggests code that's more confusing than before #7967
Labels
C-bug
Category: Clippy is not doing the correct thing
I-false-positive
Issue: The lint was triggered on code it shouldn't have
Lint name:
clippy::question_mark
I tried this code:
(for more context, see https://github.com/kangalioo/poise/blob/19bcc0afef2c77533a4e2f0a4aaffa4baea74f2a/src/prefix/track_edits.rs#L85-L92)
I expected to see this happen: no warning is emitted
Why: semantically, the
?
operator is meant for propagating exceptional values which the current function doesn't want to deal with. The semantics in this code are different, so usage of?
would be confusing and make it harder to figure what is actually happening hereInstead, this happened: Clippy suggested to replace the check with
user_msg_update.content.as_ref()?;
I am not sure how or if Clippy can detect intended semantics of
if value.is_none() { return None; }
. The best course of action may be to keep this lint as is, if it's not worth it to accommodate this small issueMeta
Rust version (
rustc -Vv
):The text was updated successfully, but these errors were encountered: