@@ -226,7 +226,13 @@ pub enum BorrowTrackerMethod {
226
226
/// Stacked Borrows, as implemented in borrow_tracker/stacked_borrows
227
227
StackedBorrows ,
228
228
/// Tree borrows, as implemented in borrow_tracker/tree_borrows
229
- TreeBorrows ,
229
+ TreeBorrows ( TreeBorrowsParams ) ,
230
+ }
231
+
232
+ /// Parameters that Tree Borrows can take.
233
+ #[ derive( Debug , Copy , Clone , PartialEq , Eq ) ]
234
+ pub struct TreeBorrowsParams {
235
+ pub precise_interior_mut : bool ,
230
236
}
231
237
232
238
impl BorrowTrackerMethod {
@@ -237,6 +243,13 @@ impl BorrowTrackerMethod {
237
243
config. retag_fields ,
238
244
) )
239
245
}
246
+
247
+ pub fn get_tree_borrows_params ( self ) -> TreeBorrowsParams {
248
+ match self {
249
+ BorrowTrackerMethod :: TreeBorrows ( params) => params,
250
+ _ => panic ! ( "can only be called when `BorrowTrackerMethod` is `TreeBorrows`" ) ,
251
+ }
252
+ }
240
253
}
241
254
242
255
impl GlobalStateInner {
@@ -252,7 +265,7 @@ impl GlobalStateInner {
252
265
AllocState :: StackedBorrows ( Box :: new ( RefCell :: new ( Stacks :: new_allocation (
253
266
id, alloc_size, self , kind, machine,
254
267
) ) ) ) ,
255
- BorrowTrackerMethod :: TreeBorrows =>
268
+ BorrowTrackerMethod :: TreeBorrows { .. } =>
256
269
AllocState :: TreeBorrows ( Box :: new ( RefCell :: new ( Tree :: new_allocation (
257
270
id, alloc_size, self , kind, machine,
258
271
) ) ) ) ,
@@ -271,7 +284,7 @@ pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> {
271
284
let method = this. machine . borrow_tracker . as_ref ( ) . unwrap ( ) . borrow ( ) . borrow_tracker_method ;
272
285
match method {
273
286
BorrowTrackerMethod :: StackedBorrows => this. sb_retag_ptr_value ( kind, val) ,
274
- BorrowTrackerMethod :: TreeBorrows => this. tb_retag_ptr_value ( kind, val) ,
287
+ BorrowTrackerMethod :: TreeBorrows { .. } => this. tb_retag_ptr_value ( kind, val) ,
275
288
}
276
289
}
277
290
@@ -284,7 +297,7 @@ pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> {
284
297
let method = this. machine . borrow_tracker . as_ref ( ) . unwrap ( ) . borrow ( ) . borrow_tracker_method ;
285
298
match method {
286
299
BorrowTrackerMethod :: StackedBorrows => this. sb_retag_place_contents ( kind, place) ,
287
- BorrowTrackerMethod :: TreeBorrows => this. tb_retag_place_contents ( kind, place) ,
300
+ BorrowTrackerMethod :: TreeBorrows { .. } => this. tb_retag_place_contents ( kind, place) ,
288
301
}
289
302
}
290
303
@@ -293,7 +306,7 @@ pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> {
293
306
let method = this. machine . borrow_tracker . as_ref ( ) . unwrap ( ) . borrow ( ) . borrow_tracker_method ;
294
307
match method {
295
308
BorrowTrackerMethod :: StackedBorrows => this. sb_protect_place ( place) ,
296
- BorrowTrackerMethod :: TreeBorrows => this. tb_protect_place ( place) ,
309
+ BorrowTrackerMethod :: TreeBorrows { .. } => this. tb_protect_place ( place) ,
297
310
}
298
311
}
299
312
@@ -302,7 +315,7 @@ pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> {
302
315
let method = this. machine . borrow_tracker . as_ref ( ) . unwrap ( ) . borrow ( ) . borrow_tracker_method ;
303
316
match method {
304
317
BorrowTrackerMethod :: StackedBorrows => this. sb_expose_tag ( alloc_id, tag) ,
305
- BorrowTrackerMethod :: TreeBorrows => this. tb_expose_tag ( alloc_id, tag) ,
318
+ BorrowTrackerMethod :: TreeBorrows { .. } => this. tb_expose_tag ( alloc_id, tag) ,
306
319
}
307
320
}
308
321
@@ -319,7 +332,7 @@ pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> {
319
332
this. tcx . tcx . dcx ( ) . warn ( "Stacked Borrows does not support named pointers; `miri_pointer_name` is a no-op" ) ;
320
333
interp_ok ( ( ) )
321
334
}
322
- BorrowTrackerMethod :: TreeBorrows =>
335
+ BorrowTrackerMethod :: TreeBorrows { .. } =>
323
336
this. tb_give_pointer_debug_name ( ptr, nth_parent, name) ,
324
337
}
325
338
}
@@ -333,7 +346,7 @@ pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> {
333
346
let method = borrow_tracker. borrow ( ) . borrow_tracker_method ;
334
347
match method {
335
348
BorrowTrackerMethod :: StackedBorrows => this. print_stacks ( alloc_id) ,
336
- BorrowTrackerMethod :: TreeBorrows => this. print_tree ( alloc_id, show_unnamed) ,
349
+ BorrowTrackerMethod :: TreeBorrows { .. } => this. print_tree ( alloc_id, show_unnamed) ,
337
350
}
338
351
}
339
352
0 commit comments