You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
A valid suggestion would be produced. This is non-trivial, since clippy wants to remove the match. as_ref() works for Options, but not in the general case
Instead, this happened:
warning: this `let...else` may be rewritten with the `?` operator
--> src/main.rs:4:1
|
4 | let Some(v) = &alias else{returnNone};
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help:replace it with: `let v = &alias?;`
|
= help:for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#question_mark
= note: `#[warn(clippy::question_mark)]` on by default
warning: `playground` (bin "playground") generated 1 warning
note: The suggestion doesn't compile as it has different semantics, and applies the Try operator before taking the reference.
Version
On the playground, which indicates version 0.1.74 (2023-12-04 a28077b)
Additional Labels
No response
The text was updated successfully, but these errors were encountered:
Yet another reproducer that actually fail to compile (might be different from what @Plecra described, as reason of this failure was because &Option doesn't impl Try):
fnfoo(alias:&Option<String>) -> Option<()>{letSome(v) = &alias else{returnNone};// let v = &alias?;Some(())}
Summary
Possibly related to #11764
Reproducer
I tried this code:
I expected to see this happen:
A valid suggestion would be produced. This is non-trivial, since clippy wants to remove the match.
as_ref()
works forOption
s, but not in the general caseInstead, this happened:
note: The suggestion doesn't compile as it has different semantics, and applies the
Try
operator before taking the reference.Version
On the playground, which indicates version 0.1.74 (2023-12-04 a28077b)
Additional Labels
No response
The text was updated successfully, but these errors were encountered: