diff --git a/src/tools/miri/tests/pass/tree_borrows/tree-borrows.rs b/src/tools/miri/tests/pass/tree_borrows/tree-borrows.rs index 476a4c85740..531543441c2 100644 --- a/src/tools/miri/tests/pass/tree_borrows/tree-borrows.rs +++ b/src/tools/miri/tests/pass/tree_borrows/tree-borrows.rs @@ -11,6 +11,7 @@ fn main() { string_as_mut_ptr(); two_mut_protected_same_alloc(); direct_mut_to_const_raw(); + local_addr_of_mut(); // Stacked Borrows tests read_does_not_invalidate1(); @@ -31,6 +32,17 @@ fn main() { write_does_not_invalidate_all_aliases(); } +#[allow(unused_assignments)] +fn local_addr_of_mut() { + let mut local = 0; + let ptr = ptr::addr_of_mut!(local); + // In SB, `local` and `*ptr` would have different tags, but in TB they have the same tag. + local = 1; + unsafe { *ptr = 2 }; + local = 3; + unsafe { *ptr = 4 }; +} + // Tree Borrows has no issue with several mutable references existing // at the same time, as long as they are used only immutably. // I.e. multiple Reserved can coexist.