-
Notifications
You must be signed in to change notification settings - Fork 424
Closed
Labels
A-aliasingArea: This affects the aliasing model (Stacked/Tree Borrows)Area: This affects the aliasing model (Stacked/Tree Borrows)
Description
Build borrow record like below,
Then I can access user.y via ptr successfully.
#![allow(unused)]
fn main() {
use std::slice;
struct Test {
x: [i32; 3],
y: i32,
}
let user = Test { x: [1, 2, 3], y: 4 };
let ptr = &(user.x) as *const i32;
let ptr2 = &(user.y) as *const i32; // build borrow record
for i in 0..4 {
unsafe { println!("ptr offset {} : {:?} addr{:?}", i, ptr.offset(i), *ptr.offset(i)) };
}
let slice = unsafe { slice::from_raw_parts(ptr, 4) };
println!("slice[3] : {:?}", slice[3]);
}Metadata
Metadata
Assignees
Labels
A-aliasingArea: This affects the aliasing model (Stacked/Tree Borrows)Area: This affects the aliasing model (Stacked/Tree Borrows)