File tree Expand file tree Collapse file tree 5 files changed +15
-3
lines changed
compile-fail/stacked_borrows Expand file tree Collapse file tree 5 files changed +15
-3
lines changed Original file line number Diff line number Diff line change
1
+ // compile-flags: -Zmiri-track-raw-pointers
2
+ // ignore-windows (FIXME: tracking raw pointers does not work on Windows)
3
+ //! This demonstrates a provenance problem that requires tracking of raw pointers to be detected.
4
+
5
+ fn main ( ) {
6
+ let mut l = 13 ;
7
+ let raw1 = & mut l as * mut _ ;
8
+ let raw2 = & mut l as * mut _ ; // invalidates raw1
9
+ // Without raw pointer tracking, Stacked Borrows cannot distinguish raw1 and raw2, and thus
10
+ // fails to realize that raw1 should not be used any more.
11
+ unsafe { * raw1 = 13 ; } //~ ERROR no item granting write access to tag
12
+ unsafe { * raw2 = 13 ; }
13
+ }
Original file line number Diff line number Diff line change 1
- // compile-flags: -Zmiri-track-raw-pointers
2
-
3
1
fn main ( ) {
4
2
println ! ( "Hello {}" , 13 ) ;
5
3
println ! ( "{:0<width$}" , "hello" , width = 10 ) ;
Original file line number Diff line number Diff line change 1
- // compile-flags: -Zmiri-track-raw-pointers
2
1
#![ feature( new_uninit) ]
3
2
4
3
use std:: slice;
Original file line number Diff line number Diff line change 1
1
// compile-flags: -Zmiri-track-raw-pointers
2
+ // ignore-windows (FIXME: tracking raw pointers does not work on Windows)
2
3
// Gather all references from a mutable iterator and make sure Miri notices if
3
4
// using them is dangerous.
4
5
fn test_all_refs < ' a , T : ' a > ( dummy : & mut T , iter : impl Iterator < Item = & ' a mut T > ) {
Original file line number Diff line number Diff line change 1
1
// compile-flags: -Zmiri-track-raw-pointers
2
+ // ignore-windows (FIXME: tracking raw pointers does not work on Windows)
2
3
use std:: collections:: VecDeque ;
3
4
4
5
fn test_all_refs < ' a , T : ' a > ( dummy : & mut T , iter : impl Iterator < Item = & ' a mut T > ) {
You can’t perform that action at this time.
0 commit comments