-
Notifications
You must be signed in to change notification settings - Fork 13.3k
librustc: Fix up mutability in method autoderefs if incorrect, and #17501
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
librustc: Fix up mutability in method autoderefs if incorrect, and #17501
Conversation
Can't explicit derefs also be fixed up? Are there issues with that? |
On Wed, Sep 24, 2014 at 01:35:19AM -0700, Eduard Burtescu wrote:
I was expecting to fixup explicit derefs as well. |
@pcwalton based on a read through, this patch seemed pretty small -- mostly unintended side-effects -- so it seems like it's worth trying to fix this the full way, which would mean basically patching up the tables also for the receiver expression (I had envisioned walking the receiver a second time and flipping traits from Deref to DerefMut). |
@nikomatsakis Recursively too? |
2c03f15
to
f936419
Compare
re-r? @nikomatsakis |
Some(MethodCall::expr(self_expr.id)), | ||
Some(self_expr), | ||
self_ty, | ||
PreferMutLvalue)); |
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.
This loop should also consider recurse on field accesses and indexing, I think, and consider autoderefs on those expressions we pass through. This is why expressions like guard.access.pending.remove()
require an explicit &mut
(which I think they should not).
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.
Adjusted the loop above in this way.
f936419
to
20e89f7
Compare
re-r? @nikomatsakis |
20e89f7
to
afa9303
Compare
re-r? @nikomatsakis |
afa9303
to
f800d86
Compare
This basically looks good... the only thing that seems to be missing are advanced tests covering scenarios like r+ modulo tests. |
prefer `Deref` over `DerefMut` in all other circumstances. Closes rust-lang#12825.
f800d86
to
496cc4c
Compare
@bors: retry |
… r=nikomatsakis prefer `Deref` over `DerefMut` in all other circumstances. Because the compiler now prefers `Deref`, this can break code that looked like: let mut foo = bar.borrow_mut(); (*foo).call_something_that_requires_mutable_self(); Replace this code with: let mut foo = bar.baz(); (&mut *foo).call_something_that_requires_mutable_self(); Closes #12825. [breaking-change] r? @nikomatsakis
Allow non org members to assign area labels
prefer
Deref
overDerefMut
in all other circumstances.Because the compiler now prefers
Deref
, this can break code thatlooked like:
Replace this code with:
Closes #12825.
[breaking-change]
r? @nikomatsakis