File tree Expand file tree Collapse file tree 1 file changed +12
-0
lines changed
src/tools/miri/tests/pass/tree_borrows Expand file tree Collapse file tree 1 file changed +12
-0
lines changed Original file line number Diff line number Diff line change @@ -11,6 +11,7 @@ fn main() {
1111 string_as_mut_ptr ( ) ;
1212 two_mut_protected_same_alloc ( ) ;
1313 direct_mut_to_const_raw ( ) ;
14+ local_addr_of_mut ( ) ;
1415
1516 // Stacked Borrows tests
1617 read_does_not_invalidate1 ( ) ;
@@ -31,6 +32,17 @@ fn main() {
3132 write_does_not_invalidate_all_aliases ( ) ;
3233}
3334
35+ #[ allow( unused_assignments) ]
36+ fn local_addr_of_mut ( ) {
37+ let mut local = 0 ;
38+ let ptr = ptr:: addr_of_mut!( local) ;
39+ // In SB, `local` and `*ptr` would have different tags, but in TB they have the same tag.
40+ local = 1 ;
41+ unsafe { * ptr = 2 } ;
42+ local = 3 ;
43+ unsafe { * ptr = 4 } ;
44+ }
45+
3446// Tree Borrows has no issue with several mutable references existing
3547// at the same time, as long as they are used only immutably.
3648// I.e. multiple Reserved can coexist.
You can’t perform that action at this time.
0 commit comments