@@ -226,7 +226,13 @@ pub enum BorrowTrackerMethod {
226226 /// Stacked Borrows, as implemented in borrow_tracker/stacked_borrows
227227 StackedBorrows ,
228228 /// 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 ,
230236}
231237
232238impl BorrowTrackerMethod {
@@ -237,6 +243,13 @@ impl BorrowTrackerMethod {
237243 config. retag_fields ,
238244 ) )
239245 }
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+ }
240253}
241254
242255impl GlobalStateInner {
@@ -252,7 +265,7 @@ impl GlobalStateInner {
252265 AllocState :: StackedBorrows ( Box :: new ( RefCell :: new ( Stacks :: new_allocation (
253266 id, alloc_size, self , kind, machine,
254267 ) ) ) ) ,
255- BorrowTrackerMethod :: TreeBorrows =>
268+ BorrowTrackerMethod :: TreeBorrows { .. } =>
256269 AllocState :: TreeBorrows ( Box :: new ( RefCell :: new ( Tree :: new_allocation (
257270 id, alloc_size, self , kind, machine,
258271 ) ) ) ) ,
@@ -271,7 +284,7 @@ pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> {
271284 let method = this. machine . borrow_tracker . as_ref ( ) . unwrap ( ) . borrow ( ) . borrow_tracker_method ;
272285 match method {
273286 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) ,
275288 }
276289 }
277290
@@ -284,7 +297,7 @@ pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> {
284297 let method = this. machine . borrow_tracker . as_ref ( ) . unwrap ( ) . borrow ( ) . borrow_tracker_method ;
285298 match method {
286299 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) ,
288301 }
289302 }
290303
@@ -293,7 +306,7 @@ pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> {
293306 let method = this. machine . borrow_tracker . as_ref ( ) . unwrap ( ) . borrow ( ) . borrow_tracker_method ;
294307 match method {
295308 BorrowTrackerMethod :: StackedBorrows => this. sb_protect_place ( place) ,
296- BorrowTrackerMethod :: TreeBorrows => this. tb_protect_place ( place) ,
309+ BorrowTrackerMethod :: TreeBorrows { .. } => this. tb_protect_place ( place) ,
297310 }
298311 }
299312
@@ -302,7 +315,7 @@ pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> {
302315 let method = this. machine . borrow_tracker . as_ref ( ) . unwrap ( ) . borrow ( ) . borrow_tracker_method ;
303316 match method {
304317 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) ,
306319 }
307320 }
308321
@@ -319,7 +332,7 @@ pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> {
319332 this. tcx . tcx . dcx ( ) . warn ( "Stacked Borrows does not support named pointers; `miri_pointer_name` is a no-op" ) ;
320333 interp_ok ( ( ) )
321334 }
322- BorrowTrackerMethod :: TreeBorrows =>
335+ BorrowTrackerMethod :: TreeBorrows { .. } =>
323336 this. tb_give_pointer_debug_name ( ptr, nth_parent, name) ,
324337 }
325338 }
@@ -333,7 +346,7 @@ pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> {
333346 let method = borrow_tracker. borrow ( ) . borrow_tracker_method ;
334347 match method {
335348 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) ,
337350 }
338351 }
339352
0 commit comments