1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
//! Compile-time witness that boxed-term storage stays put for a borrow.
//!
//! Boxed terms are tagged pointers into storage a [`Term`](crate::term::Term)
//! does not name: a process heap region, or a plain word array in a test. The
//! byte- and limb-returning accessors need a lifetime for the slices they hand
//! out, and the only honest source for it is a *shared borrow of that storage*.
//!
//! [`HeapBorrow`] is that borrow, carried as a value. It is produced from a
//! shared reference — `Heap::borrow_terms`, `Process::borrow_terms`,
//! `ProcessContext::borrow_terms`, or [`HeapBorrow::of_words`] — so its
//! lifetime parameter is constrained by an *argument*, never inferred by the
//! caller. Every allocating or collecting path in the VM takes `&mut Heap` or
//! `&mut Process`, so a live `HeapBorrow` makes that `&mut` unobtainable: the
//! borrow checker rejects "hold a slice across a GC-triggering allocation"
//! before it can be written.
use PhantomData;
/// A shared borrow of the word storage that backs boxed terms.
///
/// Copy and zero-sized: it carries no data, only the borrow region. Holding one
/// keeps the shared borrow it was made from alive, which is the whole mechanism
/// — see the module documentation.