about summary refs log tree commit diff
path: root/src/tools/miri/tests/pass/both_borrows/unsafe_pinned.rs
blob: 0c75a07bfa2af4d9e28136a76bcafed99ac052c6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
//@revisions: stack tree
//@[tree]compile-flags: -Zmiri-tree-borrows
#![feature(unsafe_pinned)]

use std::pin::UnsafePinned;

fn mutate(x: &UnsafePinned<i32>) {
    let ptr = x as *const _ as *mut i32;
    unsafe { ptr.write(42) };
}

fn main() {
    let x = UnsafePinned::new(0);
    mutate(&x);
    assert_eq!(x.into_inner(), 42);
}