|
1 | 1 | //! Implements "Stacked Borrows". See <https://github.com/rust-lang/unsafe-code-guidelines/blob/master/wip/stacked-borrows.md> |
2 | 2 | //! for further information. |
3 | 3 |
|
| 4 | +use log::trace; |
4 | 5 | use std::cell::RefCell; |
5 | 6 | use std::fmt; |
6 | 7 | use std::num::NonZeroU64; |
7 | | -use log::trace; |
8 | 8 |
|
9 | 9 | use rustc_data_structures::fx::{FxHashMap, FxHashSet}; |
10 | 10 | use rustc_hir::Mutability; |
@@ -509,15 +509,29 @@ impl Stacks { |
509 | 509 | } |
510 | 510 |
|
511 | 511 | #[inline(always)] |
512 | | - pub fn memory_read<'tcx>(&self, ptr: Pointer<Tag>, size: Size, extra: &MemoryExtra) -> InterpResult<'tcx> { |
| 512 | + pub fn memory_read<'tcx>( |
| 513 | + &self, |
| 514 | + ptr: Pointer<Tag>, |
| 515 | + size: Size, |
| 516 | + extra: &MemoryExtra, |
| 517 | + ) -> InterpResult<'tcx> { |
513 | 518 | trace!("read access with tag {:?}: {:?}, size {}", ptr.tag, ptr.erase_tag(), size.bytes()); |
514 | | - self.for_each(ptr, size, &*extra.borrow(), |ptr, stack, global| stack.access(AccessKind::Read, ptr, global)) |
| 519 | + self.for_each(ptr, size, &*extra.borrow(), |ptr, stack, global| { |
| 520 | + stack.access(AccessKind::Read, ptr, global) |
| 521 | + }) |
515 | 522 | } |
516 | 523 |
|
517 | 524 | #[inline(always)] |
518 | | - pub fn memory_written<'tcx>(&mut self, ptr: Pointer<Tag>, size: Size, extra: &mut MemoryExtra) -> InterpResult<'tcx> { |
| 525 | + pub fn memory_written<'tcx>( |
| 526 | + &mut self, |
| 527 | + ptr: Pointer<Tag>, |
| 528 | + size: Size, |
| 529 | + extra: &mut MemoryExtra, |
| 530 | + ) -> InterpResult<'tcx> { |
519 | 531 | trace!("write access with tag {:?}: {:?}, size {}", ptr.tag, ptr.erase_tag(), size.bytes()); |
520 | | - self.for_each(ptr, size, extra.get_mut(), |ptr, stack, global| stack.access(AccessKind::Write, ptr, global)) |
| 532 | + self.for_each(ptr, size, extra.get_mut(), |ptr, stack, global| { |
| 533 | + stack.access(AccessKind::Write, ptr, global) |
| 534 | + }) |
521 | 535 | } |
522 | 536 |
|
523 | 537 | #[inline(always)] |
@@ -589,7 +603,8 @@ trait EvalContextPrivExt<'mir, 'tcx: 'mir>: crate::MiriEvalContextExt<'mir, 'tcx |
589 | 603 | } |
590 | 604 | }; |
591 | 605 | let item = Item { perm, tag: new_tag, protector }; |
592 | | - stacked_borrows.for_each(ptr, size, &*global, |ptr, stack, global| stack.grant(ptr, item, global)) |
| 606 | + stacked_borrows |
| 607 | + .for_each(ptr, size, &*global, |ptr, stack, global| stack.grant(ptr, item, global)) |
593 | 608 | } |
594 | 609 |
|
595 | 610 | /// Retags an indidual pointer, returning the retagged version. |
|
0 commit comments