1
- //@revisions: default
2
1
// We disable the GC for this test because it would change what is printed.
3
2
//@compile-flags: -Zmiri-tree-borrows -Zmiri-provenance-gc=0
4
3
@@ -11,6 +10,8 @@ mod utils;
11
10
use core:: ptr:: Unique ;
12
11
13
12
// Check general handling of Unique
13
+ // Currently, this test just tests that Unique is not handled special in any way.
14
+ // In particular, it remains `Active` throughout the test.
14
15
15
16
fn main ( ) {
16
17
unsafe {
@@ -21,45 +22,17 @@ fn main() {
21
22
let raw = & mut * base as * mut u8 ;
22
23
name ! ( raw) ;
23
24
24
- // We create a `Unique` and expect it to have a fresh tag
25
- // and uninitialized permissions.
26
25
let uniq = Unique :: new_unchecked ( raw) ;
27
26
28
- // With `-Zmiri-unique-is-unique`, `Unique::as_ptr` (which is called by
29
- // `Vec::as_ptr`) generates pointers with a fresh tag, so to name the actual
30
- // `base` pointer we care about we have to walk up the tree a bit.
31
- //
32
- // We care about naming this specific parent tag because it is the one
33
- // that stays `Active` during the entire execution, unlike the leaves
34
- // that will be invalidated the next time `as_ptr` is called.
35
- //
36
- // (We name it twice so that we have an indicator in the output of
37
- // whether we got the distance correct:
38
- // If the output shows
39
- //
40
- // |- <XYZ: uniq>
41
- // '- <XYZ: uniq>
42
- //
43
- // then `nth_parent` is not big enough.
44
- // The correct value for `nth_parent` should be the minimum
45
- // integer for which the output shows
46
- //
47
- // '- <XYZ: uniq, uniq>
48
- // )
49
- //
50
- // Ultimately we want pointers obtained through independent
51
- // calls of `as_ptr` to be able to alias, which will probably involve
52
- // a new permission that allows aliasing when there is no protector.
53
- let nth_parent = if cfg ! ( uniq) { 2 } else { 0 } ;
54
- name ! ( uniq. as_ptr( ) =>nth_parent, "uniq" ) ;
55
- name ! ( uniq. as_ptr( ) =>nth_parent, "uniq" ) ;
27
+ name ! ( uniq. as_ptr( ) , "uniq" ) ;
56
28
print_state ! ( alloc_id) ;
57
29
58
30
// We can activate the Unique and use it mutably.
59
31
* uniq. as_ptr ( ) = 42 ;
60
32
print_state ! ( alloc_id) ;
61
33
62
- // Write through the raw parent disables the Unique
34
+ // Write through the raw parent does not disable the Unique,
35
+ // since both have the same tag.
63
36
* raw = 42 ;
64
37
print_state ! ( alloc_id) ;
65
38
}
0 commit comments