|
|
|
|
|
by vollbrecht
340 days ago
|
|
Hmm i just tested out the claim that the following rust code would be rejected ( Example 4 in the paper). And it seams to not be the case on the stable compiler version? fn write(x: &mut i32) {*x = 10}
fn main() {
let x = &mut 0;
let y = x as *mut i32;
//write(x); // this should use the mention implicit twophase borrow
*x = 10; // this should not and therefore be rejected by the compiler
unsafe {*y = 15 };
}
|
|
rustc itself has no reason to reject either version, because y is a *mut and thus has no borrow/lifetime relation to the &mut that x is, from a compile-time/typesystem perspective.