-
-
Notifications
You must be signed in to change notification settings - Fork 110
Stop dereferencing followed by reborrowing in match
and if let
#1139
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
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this change is good, yes. It improves readability by removing some unnecessary noise.
@sdroege Thanks! I think I covered all instances of unnecessarily dereferencing followed by reborrowing, this is now ready for review. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me, big improvement :)
Only please don't put &
into patterns but instead use ref
/ ref mut
.
|
Yeah so do it the other way around and |
Those are unfortunately exactly the cases I need to make #1134 work. But then we can add |
I'm quite sure that even was a clippy lint at some point (or maybe it's disabled by default now). You ideally never want to have |
Not that I recall, I only know about https://rust-lang.github.io/rust-clippy/master/#pattern_type_mismatch. Changes have been reverted now :) |
This is the churn part of #1134, initially intended to remove
derive(Copy)
fromenum Fundamental
to fit aString
in there. Those were just addressing the compiler errors, but there are a lot - and I mean a lot - more cases where objects are first dereferenced (copied) likematch *self {}
and then later re-(mutably)-borrowed withref
andref mut
in match arms. This is not necessary anymore (both the*
andref
/ref mut
are simply removed) and makes the code more pleasant to read.OTOH doing it this way satisfies https://rust-lang.github.io/rust-clippy/master/#pattern_type_mismatch.... Curious to all your thoughts!
If this is okay I'll go ahead and finish the remainder of the offenders.Finished!