Skip to content

Commit 2528f4e

Browse files
committed
move stacked_borrows to borrow_tracker/stacked_borrows
1 parent 2d42d26 commit 2528f4e

File tree

4 files changed

+116
-291
lines changed

4 files changed

+116
-291
lines changed

src/tools/miri/src/stacked_borrows/diagnostics.rs renamed to src/tools/miri/src/borrow_tracker/stacked_borrows/diagnostics.rs

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,16 @@
11
use smallvec::SmallVec;
22
use std::fmt;
33

4-
use rustc_middle::mir::interpret::{alloc_range, AllocId, AllocRange};
4+
use rustc_middle::mir::interpret::{alloc_range, AllocId, AllocRange, InterpError};
55
use rustc_span::{Span, SpanData};
66
use rustc_target::abi::Size;
77

8-
use crate::stacked_borrows::{
9-
err_sb_ub, AccessKind, GlobalStateInner, Permission, ProtectorKind, Stack,
8+
use crate::borrow_tracker::{
9+
stacked_borrows::{err_sb_ub, Permission},
10+
AccessKind, GlobalStateInner, ProtectorKind,
1011
};
1112
use crate::*;
1213

13-
use rustc_middle::mir::interpret::InterpError;
14-
1514
#[derive(Clone, Debug)]
1615
pub struct AllocHistory {
1716
id: AllocId,
@@ -53,7 +52,7 @@ impl Creation {
5352

5453
#[derive(Clone, Debug)]
5554
struct Invalidation {
56-
tag: SbTag,
55+
tag: BorTag,
5756
range: AllocRange,
5857
span: Span,
5958
cause: InvalidationCause,
@@ -100,7 +99,7 @@ impl fmt::Display for InvalidationCause {
10099

101100
#[derive(Clone, Debug)]
102101
struct Protection {
103-
tag: SbTag,
102+
tag: BorTag,
104103
span: Span,
105104
}
106105

@@ -135,7 +134,7 @@ impl<'ecx, 'mir, 'tcx> DiagnosticCxBuilder<'ecx, 'mir, 'tcx> {
135134
pub fn retag(
136135
machine: &'ecx MiriMachine<'mir, 'tcx>,
137136
cause: RetagCause,
138-
new_tag: SbTag,
137+
new_tag: BorTag,
139138
orig_tag: ProvenanceExtra,
140139
range: AllocRange,
141140
) -> Self {
@@ -185,7 +184,7 @@ enum Operation {
185184
#[derive(Debug, Clone)]
186185
struct RetagOp {
187186
cause: RetagCause,
188-
new_tag: SbTag,
187+
new_tag: BorTag,
189188
orig_tag: ProvenanceExtra,
190189
range: AllocRange,
191190
permission: Option<Permission>,
@@ -257,7 +256,7 @@ impl<'history, 'ecx, 'mir, 'tcx> DiagnosticCx<'history, 'ecx, 'mir, 'tcx> {
257256
.push(Creation { retag: op.clone(), span: self.machine.current_span() });
258257
}
259258

260-
pub fn log_invalidation(&mut self, tag: SbTag) {
259+
pub fn log_invalidation(&mut self, tag: BorTag) {
261260
let mut span = self.machine.current_span();
262261
let (range, cause) = match &self.operation {
263262
Operation::Retag(RetagOp { cause, range, permission, .. }) => {
@@ -288,8 +287,8 @@ impl<'history, 'ecx, 'mir, 'tcx> DiagnosticCx<'history, 'ecx, 'mir, 'tcx> {
288287

289288
pub fn get_logs_relevant_to(
290289
&self,
291-
tag: SbTag,
292-
protector_tag: Option<SbTag>,
290+
tag: BorTag,
291+
protector_tag: Option<BorTag>,
293292
) -> Option<TagHistory> {
294293
let Some(created) = self.history
295294
.creations
@@ -410,7 +409,7 @@ impl<'history, 'ecx, 'mir, 'tcx> DiagnosticCx<'history, 'ecx, 'mir, 'tcx> {
410409
.all_stacks()
411410
.flatten()
412411
.map(|frame| {
413-
frame.extra.stacked_borrows.as_ref().expect("we should have Stacked Borrows data")
412+
frame.extra.borrow_tracker.as_ref().expect("we should have borrow tracking data")
414413
})
415414
.find(|frame| frame.protected_tags.contains(&item.tag()))
416415
.map(|frame| frame.call_id)

src/tools/miri/src/stacked_borrows/item.rs renamed to src/tools/miri/src/borrow_tracker/stacked_borrows/item.rs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
1-
use crate::stacked_borrows::SbTag;
21
use std::fmt;
3-
use std::num::NonZeroU64;
2+
3+
use crate::borrow_tracker::BorTag;
44

55
/// An item in the per-location borrow stack.
66
#[derive(Copy, Clone, Hash, PartialEq, Eq)]
77
pub struct Item(u64);
88

99
// An Item contains 3 bitfields:
10-
// * Bits 0-61 store an SbTag
10+
// * Bits 0-61 store a BorTag
1111
// * Bits 61-63 store a Permission
1212
// * Bit 64 stores a flag which indicates if we have a protector
1313
const TAG_MASK: u64 = u64::MAX >> 3;
@@ -18,9 +18,9 @@ const PERM_SHIFT: u64 = 61;
1818
const PROTECTED_SHIFT: u64 = 63;
1919

2020
impl Item {
21-
pub fn new(tag: SbTag, perm: Permission, protected: bool) -> Self {
22-
assert!(tag.0.get() <= TAG_MASK);
23-
let packed_tag = tag.0.get();
21+
pub fn new(tag: BorTag, perm: Permission, protected: bool) -> Self {
22+
assert!(tag.get() <= TAG_MASK);
23+
let packed_tag = tag.get();
2424
let packed_perm = perm.to_bits() << PERM_SHIFT;
2525
let packed_protected = u64::from(protected) << PROTECTED_SHIFT;
2626

@@ -34,8 +34,8 @@ impl Item {
3434
}
3535

3636
/// The pointers the permission is granted to.
37-
pub fn tag(self) -> SbTag {
38-
SbTag(NonZeroU64::new(self.0 & TAG_MASK).unwrap())
37+
pub fn tag(self) -> BorTag {
38+
BorTag::new(self.0 & TAG_MASK).unwrap()
3939
}
4040

4141
/// The permission this item grants.

0 commit comments

Comments
 (0)