-
Notifications
You must be signed in to change notification settings - Fork 13.2k
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
MIR-borrowck: add permisson checks to fn access_lvalue
#44837
Comments
To elaborate, here are some examples of the kinds of scenarios we are worried about:
|
@zilbuz also notes this example (though I think it might a bit different thing to check, since this AFAICT is about checking that the local fn main() {
let a = 1;
let _a = &a;
let __a = &mut _a;
} |
Here is some pseudocode for the various permissions I think we might want to check: https://gist.github.com/nikomatsakis/90102114e8ba5792d4e28a6960942ae6 In each case, there is a function that, given an lvalue, tells you whether it can be mutated or whether it can be moved from. The function returns |
MIR-borrowck: add permisson checks to `fn access_lvalue` WIP : Some FIXME left and some broken tests. Fix #44837
The permission checks still let you assign/mutate through an immutable reference: fn main() {
let a = &5;
*a = 6; // no MIR error !!!
} e.g. the test compile-fail/borrowck/borrowck-borrow-mut-base-ptr-in-aliasable-loc.rs |
As noted in a comment by arielb1, the
fn access_lvalue
needs to check somewhere that the accessor actually has sufficient permissions for the operation being requested, aka no mutable borrows of immutable references or moves through a non-Box
reference.The text was updated successfully, but these errors were encountered: