Skip to content

Commit 6b0fb3c

Browse files
committed
Size -> Range in RangeMap's iterators
1 parent 2ec2db4 commit 6b0fb3c

File tree

5 files changed

+21
-18
lines changed

5 files changed

+21
-18
lines changed

src/borrow_tracker/stacked_borrows/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -459,7 +459,7 @@ impl<'tcx> Stack {
459459
impl Stacks {
460460
pub fn remove_unreachable_tags(&mut self, live_tags: &FxHashSet<BorTag>) {
461461
if self.modified_since_last_gc {
462-
for stack in self.stacks.iter_mut_all() {
462+
for (_, stack) in self.stacks.iter_mut_all() {
463463
if stack.len() > 64 {
464464
stack.retain(live_tags);
465465
}
@@ -512,7 +512,7 @@ impl<'tcx> Stacks {
512512
) -> InterpResult<'tcx> {
513513
self.modified_since_last_gc = true;
514514
for (offset, stack) in self.stacks.iter_mut(range.start, range.size) {
515-
let mut dcx = dcx_builder.build(&mut self.history, offset);
515+
let mut dcx = dcx_builder.build(&mut self.history, Size::from_bytes(offset.start));
516516
f(stack, &mut dcx, &mut self.exposed_tags)?;
517517
dcx_builder = dcx.unbuild();
518518
}

src/borrow_tracker/tree_borrows/diagnostics.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ use std::ops::Range;
33

44
use rustc_data_structures::fx::FxHashMap;
55
use rustc_span::{Span, SpanData};
6-
use rustc_target::abi::Size;
76

87
use crate::borrow_tracker::tree_borrows::{
98
perms::{PermTransition, Permission},
@@ -25,7 +24,7 @@ pub struct Event {
2524
pub access_kind: AccessKind,
2625
pub is_foreign: bool,
2726
pub access_range: AllocRange,
28-
pub offset: Size,
27+
pub offset: Range<u64>,
2928
pub span: Span,
3029
}
3130

@@ -243,7 +242,7 @@ pub(super) struct TbError<'node> {
243242
/// What failure occurred.
244243
pub error_kind: TransitionError,
245244
/// The byte at which the conflict occured.
246-
pub error_offset: Size,
245+
pub error_offset: u64,
247246
/// The tag on which the error was triggered.
248247
/// On protector violations, this is the tag that was protected.
249248
/// On accesses rejected due to insufficient permissions, this is the

src/borrow_tracker/tree_borrows/tree.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -368,7 +368,7 @@ impl<'tcx> Tree {
368368
TbError {
369369
conflicting_info,
370370
access_kind: AccessKind::Write,
371-
error_offset: offset,
371+
error_offset: offset.start,
372372
error_kind,
373373
accessed_info,
374374
}
@@ -458,7 +458,7 @@ impl<'tcx> Tree {
458458
access_kind,
459459
access_range: range,
460460
is_foreign: rel_pos.is_foreign(),
461-
offset,
461+
offset: offset.clone(),
462462
span,
463463
});
464464
old_state.permission =
@@ -472,7 +472,7 @@ impl<'tcx> Tree {
472472
TbError {
473473
conflicting_info,
474474
access_kind,
475-
error_offset: offset,
475+
error_offset: offset.start,
476476
error_kind,
477477
accessed_info,
478478
}
@@ -530,7 +530,7 @@ impl Tree {
530530
// the tag from the mapping.
531531
let tag = node.tag;
532532
self.nodes.remove(idx);
533-
for perms in self.rperms.iter_mut_all() {
533+
for (_, perms) in self.rperms.iter_mut_all() {
534534
perms.remove(idx);
535535
}
536536
self.tag_mapping.remove(&tag);

src/concurrency/data_race.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -869,7 +869,7 @@ impl VClockAlloc {
869869
range,
870870
"Read",
871871
false,
872-
Pointer::new(alloc_id, offset),
872+
Pointer::new(alloc_id, Size::from_bytes(offset.start)),
873873
);
874874
}
875875
}
@@ -903,7 +903,7 @@ impl VClockAlloc {
903903
range,
904904
write_type.get_descriptor(),
905905
false,
906-
Pointer::new(alloc_id, offset),
906+
Pointer::new(alloc_id, Size::from_bytes(offset.start)),
907907
);
908908
}
909909
}
@@ -1137,7 +1137,7 @@ trait EvalContextPrivExt<'mir, 'tcx: 'mir>: MiriInterpCxExt<'mir, 'tcx> {
11371137
range,
11381138
description,
11391139
true,
1140-
Pointer::new(alloc_id, offset),
1140+
Pointer::new(alloc_id, Size::from_bytes(offset.start)),
11411141
)
11421142
.map(|_| true);
11431143
}

src/range_map.rs

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ impl<T> RangeMap<T> {
6363
/// through interior mutability.
6464
///
6565
/// The iterator also provides the offset of the given element.
66-
pub fn iter(&self, offset: Size, len: Size) -> impl Iterator<Item = (Size, &T)> {
66+
pub fn iter(&self, offset: Size, len: Size) -> impl Iterator<Item = (ops::Range<u64>, &T)> {
6767
let offset = offset.bytes();
6868
let len = len.bytes();
6969
// Compute a slice starting with the elements we care about.
@@ -84,11 +84,11 @@ impl<T> RangeMap<T> {
8484
slice
8585
.iter()
8686
.take_while(move |elem| elem.range.start < end)
87-
.map(|elem| (Size::from_bytes(elem.range.start), &elem.data))
87+
.map(|elem| (elem.range.clone(), &elem.data))
8888
}
8989

90-
pub fn iter_mut_all(&mut self) -> impl Iterator<Item = &mut T> {
91-
self.v.iter_mut().map(|elem| &mut elem.data)
90+
pub fn iter_mut_all(&mut self) -> impl Iterator<Item = (ops::Range<u64>, &mut T)> {
91+
self.v.iter_mut().map(|elem| (elem.range.clone(), &mut elem.data))
9292
}
9393

9494
pub fn iter_all(&self) -> impl Iterator<Item = (ops::Range<u64>, &T)> {
@@ -127,7 +127,11 @@ impl<T> RangeMap<T> {
127127
/// Moreover, this will opportunistically merge neighbouring equal blocks.
128128
///
129129
/// The iterator also provides the offset of the given element.
130-
pub fn iter_mut(&mut self, offset: Size, len: Size) -> impl Iterator<Item = (Size, &mut T)>
130+
pub fn iter_mut(
131+
&mut self,
132+
offset: Size,
133+
len: Size,
134+
) -> impl Iterator<Item = (ops::Range<u64>, &mut T)>
131135
where
132136
T: Clone + PartialEq,
133137
{
@@ -208,7 +212,7 @@ impl<T> RangeMap<T> {
208212
// Now we yield the slice. `end` is inclusive.
209213
&mut self.v[first_idx..=end_idx]
210214
};
211-
slice.iter_mut().map(|elem| (Size::from_bytes(elem.range.start), &mut elem.data))
215+
slice.iter_mut().map(|elem| (elem.range.clone(), &mut elem.data))
212216
}
213217
}
214218

0 commit comments

Comments
 (0)