@@ -79,10 +79,24 @@ impl AllocId {
79
79
pub fn get ( & self ) -> usize {
80
80
self . 0
81
81
}
82
- /// The minimum representable tag
83
- pub const fn zero ( ) -> Self {
82
+ /// An invalid allocation
83
+ pub const fn null ( ) -> Self {
84
84
AllocId ( 0 )
85
85
}
86
+
87
+ /// Represents any valid allocation
88
+ pub const fn wildcard ( ) -> Self {
89
+ AllocId ( 1 )
90
+ }
91
+
92
+ /// A global or stack allocation, which cannot be manually freed
93
+ pub const fn sticky ( ) -> Self {
94
+ AllocId ( 2 )
95
+ }
96
+
97
+ pub const fn min ( ) -> Self {
98
+ AllocId ( 3 )
99
+ }
86
100
}
87
101
88
102
impl fmt:: Debug for AllocId {
@@ -97,19 +111,12 @@ impl fmt::Debug for AllocId {
97
111
pub struct BorTag ( usize ) ;
98
112
99
113
impl BorTag {
100
- pub fn new ( i : usize ) -> Self {
114
+ pub const fn new ( i : usize ) -> Self {
101
115
BorTag ( i)
102
116
}
103
117
pub fn get ( & self ) -> usize {
104
118
self . 0
105
119
}
106
- /// The minimum representable tag
107
- pub const fn zero ( ) -> Self {
108
- BorTag ( 0 )
109
- }
110
- pub const fn one ( ) -> Self {
111
- BorTag ( 1 )
112
- }
113
120
}
114
121
115
122
impl fmt:: Debug for BorTag {
@@ -139,19 +146,18 @@ impl Provenance {
139
146
/// pointers.
140
147
const fn null ( ) -> Self {
141
148
Provenance {
142
- alloc_id : AllocId :: zero ( ) ,
143
- bor_tag : BorTag :: zero ( ) ,
149
+ alloc_id : AllocId :: null ( ) ,
150
+ bor_tag : BorTag :: new ( 0 ) ,
144
151
alloc_info : core:: ptr:: null_mut ( ) ,
145
152
}
146
153
}
147
154
148
155
/// Pointers cast from integers receive a "wildcard" provenance value, which permits
149
- /// any access. A provenance value with an `alloc_id` of zero and any non-zero `bor_tag`
150
- /// is treated as a wildcard provenance value.
156
+ /// any access.
151
157
const fn wildcard ( ) -> Self {
152
158
Provenance {
153
- alloc_id : AllocId :: zero ( ) ,
154
- bor_tag : BorTag :: one ( ) ,
159
+ alloc_id : AllocId :: wildcard ( ) ,
160
+ bor_tag : BorTag :: new ( 0 ) ,
155
161
alloc_info : core:: ptr:: null_mut ( ) ,
156
162
}
157
163
}
@@ -175,7 +181,7 @@ impl AllocInfo {
175
181
/// When we deallocate an allocation, we need to invalidate its metadata.
176
182
/// so that any uses-after-free are detectable.
177
183
fn dealloc ( & mut self ) {
178
- self . alloc_id = AllocId :: zero ( ) ;
184
+ self . alloc_id = AllocId :: null ( ) ;
179
185
self . base_addr = 0 ;
180
186
self . size = 0 ;
181
187
self . align = 1 ;
0 commit comments