We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent c63cab1 commit 5d071ebCopy full SHA for 5d071eb
tests/pass/tree_borrows/tree-borrows.rs
@@ -11,6 +11,7 @@ fn main() {
11
string_as_mut_ptr();
12
two_mut_protected_same_alloc();
13
direct_mut_to_const_raw();
14
+ local_addr_of_mut();
15
16
// Stacked Borrows tests
17
read_does_not_invalidate1();
@@ -31,6 +32,17 @@ fn main() {
31
32
write_does_not_invalidate_all_aliases();
33
}
34
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
+
46
// Tree Borrows has no issue with several mutable references existing
47
// at the same time, as long as they are used only immutably.
48
// I.e. multiple Reserved can coexist.
0 commit comments