@@ -18,16 +18,16 @@ pub type PtrId = NonZeroU64;
18
18
pub type CallId = NonZeroU64 ;
19
19
20
20
/// Tracking pointer provenance
21
- #[ derive( Copy , Clone , Debug , Hash , PartialEq , Eq ) ]
21
+ #[ derive( Copy , Clone , Hash , PartialEq , Eq ) ]
22
22
pub enum Tag {
23
23
Tagged ( PtrId ) ,
24
24
Untagged ,
25
25
}
26
26
27
- impl fmt:: Display for Tag {
27
+ impl fmt:: Debug for Tag {
28
28
fn fmt ( & self , f : & mut fmt:: Formatter ) -> fmt:: Result {
29
29
match self {
30
- Tag :: Tagged ( id) => write ! ( f, "{} " , id) ,
30
+ Tag :: Tagged ( id) => write ! ( f, "<{}> " , id) ,
31
31
Tag :: Untagged => write ! ( f, "<untagged>" ) ,
32
32
}
33
33
}
@@ -48,7 +48,7 @@ pub enum Permission {
48
48
}
49
49
50
50
/// An item in the per-location borrow stack.
51
- #[ derive( Copy , Clone , Debug , Hash , PartialEq , Eq ) ]
51
+ #[ derive( Copy , Clone , Hash , PartialEq , Eq ) ]
52
52
pub struct Item {
53
53
/// The permission this item grants.
54
54
perm : Permission ,
@@ -58,9 +58,9 @@ pub struct Item {
58
58
protector : Option < CallId > ,
59
59
}
60
60
61
- impl fmt:: Display for Item {
61
+ impl fmt:: Debug for Item {
62
62
fn fmt ( & self , f : & mut fmt:: Formatter ) -> fmt:: Result {
63
- write ! ( f, "[{:?} for {}" , self . perm, self . tag) ?;
63
+ write ! ( f, "[{:?} for {:? }" , self . perm, self . tag) ?;
64
64
if let Some ( call) = self . protector {
65
65
write ! ( f, " (call {})" , call) ?;
66
66
}
@@ -99,7 +99,7 @@ pub struct GlobalState {
99
99
pub type MemoryState = Rc < RefCell < GlobalState > > ;
100
100
101
101
/// Indicates which kind of access is being performed.
102
- #[ derive( Copy , Clone , Debug , Hash , PartialEq , Eq ) ]
102
+ #[ derive( Copy , Clone , Hash , PartialEq , Eq ) ]
103
103
pub enum AccessKind {
104
104
Read ,
105
105
Write ,
@@ -108,16 +108,16 @@ pub enum AccessKind {
108
108
impl fmt:: Display for AccessKind {
109
109
fn fmt ( & self , f : & mut fmt:: Formatter ) -> fmt:: Result {
110
110
match self {
111
- AccessKind :: Read => write ! ( f, "read" ) ,
112
- AccessKind :: Write => write ! ( f, "write" ) ,
111
+ AccessKind :: Read => write ! ( f, "read access " ) ,
112
+ AccessKind :: Write => write ! ( f, "write access " ) ,
113
113
}
114
114
}
115
115
}
116
116
117
117
/// Indicates which kind of reference is being created.
118
118
/// Used by high-level `reborrow` to compute which permissions to grant to the
119
119
/// new pointer.
120
- #[ derive( Copy , Clone , Debug , Hash , PartialEq , Eq ) ]
120
+ #[ derive( Copy , Clone , Hash , PartialEq , Eq ) ]
121
121
pub enum RefKind {
122
122
/// `&mut` and `Box`.
123
123
Unique { two_phase : bool } ,
@@ -261,12 +261,12 @@ impl<'tcx> Stack {
261
261
if global. is_active ( call) {
262
262
if let Some ( tag) = tag {
263
263
return err ! ( MachineError ( format!(
264
- "not granting access to tag {} because incompatible item is protected: {}" ,
264
+ "not granting access to tag {:? } because incompatible item is protected: {:? }" ,
265
265
tag, item
266
266
) ) ) ;
267
267
} else {
268
268
return err ! ( MachineError ( format!(
269
- "deallocating while item is protected: {}" , item
269
+ "deallocating while item is protected: {:? }" , item
270
270
) ) ) ;
271
271
}
272
272
}
@@ -287,7 +287,7 @@ impl<'tcx> Stack {
287
287
// Step 1: Find granting item.
288
288
let granting_idx = self . find_granting ( access, tag)
289
289
. ok_or_else ( || InterpError :: MachineError ( format ! (
290
- "no item granting {} access to tag {} found in borrow stack" ,
290
+ "no item granting {} to tag {:? } found in borrow stack" ,
291
291
access, tag,
292
292
) ) ) ?;
293
293
@@ -298,7 +298,7 @@ impl<'tcx> Stack {
298
298
// pointers become invalid on write accesses (ensures F2a, and ensures U2 for write accesses).
299
299
let first_incompatible_idx = self . find_first_write_incompaible ( granting_idx) ;
300
300
for item in self . borrows . drain ( first_incompatible_idx..) . rev ( ) {
301
- trace ! ( "access: popping item {}" , item) ;
301
+ trace ! ( "access: popping item {:? }" , item) ;
302
302
Stack :: check_protector ( & item, Some ( tag) , global) ?;
303
303
}
304
304
} else {
@@ -313,7 +313,7 @@ impl<'tcx> Stack {
313
313
for idx in ( granting_idx+1 .. self . borrows . len ( ) ) . rev ( ) {
314
314
let item = & mut self . borrows [ idx] ;
315
315
if item. perm == Permission :: Unique {
316
- trace ! ( "access: disabling item {}" , item) ;
316
+ trace ! ( "access: disabling item {:? }" , item) ;
317
317
Stack :: check_protector ( item, Some ( tag) , global) ?;
318
318
item. perm = Permission :: Disabled ;
319
319
}
@@ -334,7 +334,7 @@ impl<'tcx> Stack {
334
334
// Step 1: Find granting item.
335
335
self . find_granting ( AccessKind :: Write , tag)
336
336
. ok_or_else ( || InterpError :: MachineError ( format ! (
337
- "no item granting write access for deallocation to tag {} found in borrow stack" ,
337
+ "no item granting write access for deallocation to tag {:? } found in borrow stack" ,
338
338
tag,
339
339
) ) ) ?;
340
340
@@ -383,7 +383,7 @@ impl<'tcx> Stack {
383
383
// We use that to determine where to put the new item.
384
384
let granting_idx = self . find_granting ( access, derived_from)
385
385
. ok_or_else ( || InterpError :: MachineError ( format ! (
386
- "trying to reborrow for {:?}, but parent tag {} does not have an appropriate item in the borrow stack" , new. perm, derived_from,
386
+ "trying to reborrow for {:?}, but parent tag {:? } does not have an appropriate item in the borrow stack" , new. perm, derived_from,
387
387
) ) ) ?;
388
388
389
389
// Compute where to put the new item.
@@ -412,9 +412,9 @@ impl<'tcx> Stack {
412
412
// Put the new item there. As an optimization, deduplicate if it is equal to one of its new neighbors.
413
413
if self . borrows [ new_idx-1 ] == new || self . borrows . get ( new_idx) == Some ( & new) {
414
414
// Optimization applies, done.
415
- trace ! ( "reborrow: avoiding adding redundant item {}" , new) ;
415
+ trace ! ( "reborrow: avoiding adding redundant item {:? }" , new) ;
416
416
} else {
417
- trace ! ( "reborrow: adding item {}" , new) ;
417
+ trace ! ( "reborrow: adding item {:? }" , new) ;
418
418
self . borrows . insert ( new_idx, new) ;
419
419
}
420
420
@@ -497,7 +497,7 @@ impl AllocationExtra<Tag> for Stacks {
497
497
ptr : Pointer < Tag > ,
498
498
size : Size ,
499
499
) -> EvalResult < ' tcx > {
500
- trace ! ( "read access with tag {}: {:?}, size {}" , ptr. tag, ptr, size. bytes( ) ) ;
500
+ trace ! ( "read access with tag {:? }: {:?}, size {}" , ptr. tag, ptr, size. bytes( ) ) ;
501
501
alloc. extra . for_each ( ptr, size, |stack, global| {
502
502
stack. access ( AccessKind :: Read , ptr. tag , global) ?;
503
503
Ok ( ( ) )
@@ -510,7 +510,7 @@ impl AllocationExtra<Tag> for Stacks {
510
510
ptr : Pointer < Tag > ,
511
511
size : Size ,
512
512
) -> EvalResult < ' tcx > {
513
- trace ! ( "write access with tag {}: {:?}, size {}" , ptr. tag, ptr, size. bytes( ) ) ;
513
+ trace ! ( "write access with tag {:? }: {:?}, size {}" , ptr. tag, ptr, size. bytes( ) ) ;
514
514
alloc. extra . for_each ( ptr, size, |stack, global| {
515
515
stack. access ( AccessKind :: Write , ptr. tag , global) ?;
516
516
Ok ( ( ) )
@@ -523,7 +523,7 @@ impl AllocationExtra<Tag> for Stacks {
523
523
ptr : Pointer < Tag > ,
524
524
size : Size ,
525
525
) -> EvalResult < ' tcx > {
526
- trace ! ( "deallocation with tag {}: {:?}, size {}" , ptr. tag, ptr, size. bytes( ) ) ;
526
+ trace ! ( "deallocation with tag {:? }: {:?}, size {}" , ptr. tag, ptr, size. bytes( ) ) ;
527
527
alloc. extra . for_each ( ptr, size, |stack, global| {
528
528
stack. dealloc ( ptr. tag , global)
529
529
} )
@@ -545,7 +545,7 @@ trait EvalContextPrivExt<'a, 'mir, 'tcx: 'a+'mir>: crate::MiriEvalContextExt<'a,
545
545
let this = self . eval_context_mut ( ) ;
546
546
let protector = if protect { Some ( this. frame ( ) . extra ) } else { None } ;
547
547
let ptr = place. ptr . to_ptr ( ) ?;
548
- trace ! ( "reborrow: {} reference {} derived from {} (pointee {}): {:?}, size {}" ,
548
+ trace ! ( "reborrow: {} reference {:? } derived from {:? } (pointee {}): {:?}, size {}" ,
549
549
kind, new_tag, ptr. tag, place. layout. ty, ptr, size. bytes( ) ) ;
550
550
551
551
// Get the allocation. It might not be mutable, so we cannot use `get_mut`.
0 commit comments