]> git.lizzy.rs Git - rust.git/blob - src/tools/miri/tests/fail/stacked_borrows/raw_tracking.rs
Merge commit '4f142aa1058f14f153f8bfd2d82f04ddb9982388' into clippyup
[rust.git] / src / tools / miri / tests / fail / stacked_borrows / raw_tracking.rs
1 //! This demonstrates a provenance problem that requires tracking of raw pointers to be detected.
2
3 fn main() {
4     let mut l = 13;
5     let raw1 = &mut l as *mut _;
6     let raw2 = &mut l as *mut _; // invalidates raw1
7     // Without raw pointer tracking, Stacked Borrows cannot distinguish raw1 and raw2, and thus
8     // fails to realize that raw1 should not be used any more.
9     unsafe { *raw1 = 13 }; //~ ERROR: /write access .* tag does not exist in the borrow stack/
10     unsafe { *raw2 = 13 };
11 }