-
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
Box<&mut int> allows for constructing an &int aliasing the &mut, while the &mut is still modifyable #14498
Comments
Nominating for P-backcompat-lang as a borrow check bug |
cc me |
1.0 P-backcompat-lang. |
Also, it doesn't fail when using fn main() {
let mut a = 3i;
let b = &mut &mut a;
let c = &b;
let d = &***c;
**b = 4i;
println!("{} {}", c, d);
}
|
I think |
Side note: the current Redex model correctly rejects this code (yay!). |
I have a simple fix for this: https://gist.github.com/zwarich/6f6bace941c87aeb7587. I'm testing on top of a lot of other borrowck changes, but this code in particular wasn't modified. I'll add a test, try again on master, and submit a PR. |
@huonw I just figured we would have run into |
Make check_for_assignment_to_restricted_or_frozen_location treat mutation through an owning pointer the same way it treats mutation through an &mut pointer, where mutability must be inherited from the base path. I also included GC pointers in this check, as that is what the corresponding code in gather_loans/restrictions.rs does, but I don't think there is a way to test this with the current language. Fixes #14498.
The text was updated successfully, but these errors were encountered: