-
Notifications
You must be signed in to change notification settings - Fork 13.4k
Accessing &mut through & oddities #11913
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Comments
Adding more info (perhaps not actually necessary for this bug). Treating everything as mutable succeeds as well.
|
Agreed, this is wrong. The mutable borrow in the second case should definitely be disallowed. |
Nominating. |
1.0, P-backcompat-lang |
The problem seems to be that we removed RESTR_ALIAS from the list of things to be restricted, probably when removing const loans. |
…ble-loc, r=pcwalton Repair a rather embarassingly obvious hole that I created as part of #9629. In particular, prevent `&mut` borrows of data in an aliasable location. This used to be prevented through the restrictions mechanism, but in #9629 I modified those rules incorrectly. r? @pcwalton Fixes #11913
@nikomatsakis Would you mind to explain what can go wrong if we allow this? (I started playing with Rust recently, and encountered a problem that this can solve. So I wondered what can go wrong by allowing this) |
@kkimdev You can get multiple |
@gankro I see, that makes sense! |
…-null, r=llogiq fix(ptr_as_ptr): handle `std::ptr::null{_mut}` close rust-lang#11066 close rust-lang#11665 close rust-lang#11911 *Please write a short comment explaining your change (or "none" for internal only changes)* changelog: [`ptr_as_ptr`]: handle `std::ptr::null` and `std::ptr::null_mut`
This program fails to compile:
whereas this program succeeds to compile
These seem to be doing the same thing to me, so I would expect both of them to be rejected or both of them be accepted.
cc @nikomatsakis
The text was updated successfully, but these errors were encountered: