diff options
| author | Ralf Jung <post@ralfj.de> | 2023-08-02 18:31:54 +0200 |
|---|---|---|
| committer | Ralf Jung <post@ralfj.de> | 2023-08-02 18:33:01 +0200 |
| commit | df3b25f38605c65737c08bac684bf84dde56b2f1 (patch) | |
| tree | b845ea90d95101c2e20eed404f8767ae7a3c5518 | |
| parent | c9512084bd250c92d898137863bc7d1f6374a6a3 (diff) | |
| download | rust-df3b25f38605c65737c08bac684bf84dde56b2f1.tar.gz rust-df3b25f38605c65737c08bac684bf84dde56b2f1.zip | |
add local_addr_of_mut test
| -rw-r--r-- | src/tools/miri/tests/pass/tree_borrows/tree-borrows.rs | 12 |
1 files changed, 12 insertions, 0 deletions
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. |
