-
Notifications
You must be signed in to change notification settings - Fork 12.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Lint for superfluous let/match #11088
Comments
Yes, this should probably wait until #10488 is actually implemented. |
(and that is an interesting question about what the semantics of |
Currently |
I just noticed this is in tension with #2974. |
…lly do anything (irrefutable, no bindings). Will be useful once the semantics of _ in patterns changes to "ignore" instead of "drop" (rust-lang#10488). Closes rust-lang#11088.
Triage bump: nothing has changed. |
I believe this shouldn't be linted as described, |
Yup, this seems really bad. Since I'm the only one who's commented since 2013, I'm going to give this a close. A lot of the semantics here have changed since then. |
Following the conversation in #10488, now that
let _ = $foo;
will be equivalent to just$foo;
, we should have a lint to protect against people writing it, because anyone who does is likely doing so based on mistaken assumptions (i.e. that it does anything at all).Going further, we should flag any
let
ormatch
whose meaning is equivalent to just its inner/RHS expression.My thinking w.r.t. the precise criteria is that we should flag a lint [what's the right verbage here?] unless either of the following are true:
match
with more than one arm, in which case it's presumably doing a branch (if not, there are other lints for that)PatIdent
(one which is actually an identifier and not a nullary enum) at any point, in which case the following code presumably uses the binding (if not, again there's another lint for that)My question is whether this list should also include the presence of
PatBox
,PatUniq
, and/orPatRegion
. With the new semantics for_
, will e.g.let ~_ = foo;
"do anything", such as move out offoo
?As far as I can tell the change in
_
semantics hasn't happened yet, but I'm thinking the lint could go in either before or after, with the potential difference that if it goes in before, the lint message should perhaps be in future tense.The text was updated successfully, but these errors were encountered: