Skip to content

Commit 6235604

Browse files
committed
Tidy up the implementation
1 parent 63a51a6 commit 6235604

File tree

1 file changed

+9
-12
lines changed

1 file changed

+9
-12
lines changed

src/tools/miri/src/machine.rs

+9-12
Original file line numberDiff line numberDiff line change
@@ -141,9 +141,9 @@ impl MiriMemoryKind {
141141
use self::MiriMemoryKind::*;
142142
match self {
143143
// Heap allocations are fine since the `Allocation` is created immediately.
144-
Rust | Miri | C | Mmap => true,
144+
Rust | Miri | C | WinHeap | Mmap => true,
145145
// Everything else is unclear, let's not show potentially confusing spans.
146-
Machine | Global | ExternStatic | Tls | WinHeap | Runtime => false,
146+
Machine | Global | ExternStatic | Tls | Runtime => false,
147147
}
148148
}
149149
}
@@ -513,7 +513,7 @@ pub struct MiriMachine<'mir, 'tcx> {
513513

514514
/// The spans we will use to report where an allocation was created and deallocated in
515515
/// diagnostics.
516-
pub(crate) allocation_spans: RefCell<FxHashMap<AllocId, (Option<Span>, Option<Span>)>>,
516+
pub(crate) allocation_spans: RefCell<FxHashMap<AllocId, (Span, Option<Span>)>>,
517517
}
518518

519519
impl<'mir, 'tcx> MiriMachine<'mir, 'tcx> {
@@ -765,8 +765,7 @@ impl<'mir, 'tcx> MiriMachine<'mir, 'tcx> {
765765
self.allocation_spans
766766
.borrow()
767767
.get(&alloc_id)
768-
.and_then(|(allocated, _deallocated)| *allocated)
769-
.map(Span::data)
768+
.map(|(allocated, _deallocated)| allocated.data())
770769
}
771770

772771
pub(crate) fn deallocated_span(&self, alloc_id: AllocId) -> Option<SpanData> {
@@ -1087,13 +1086,11 @@ impl<'mir, 'tcx> Machine<'mir, 'tcx> for MiriMachine<'mir, 'tcx> {
10871086
|ptr| ecx.global_base_pointer(ptr),
10881087
)?;
10891088

1090-
if let MemoryKind::Machine(kind) = kind {
1091-
if kind.should_save_allocation_span() {
1092-
ecx.machine
1093-
.allocation_spans
1094-
.borrow_mut()
1095-
.insert(id, (Some(ecx.machine.current_span()), None));
1096-
}
1089+
if matches!(kind, MemoryKind::Machine(kind) if kind.should_save_allocation_span()) {
1090+
ecx.machine
1091+
.allocation_spans
1092+
.borrow_mut()
1093+
.insert(id, (ecx.machine.current_span(), None));
10971094
}
10981095

10991096
Ok(Cow::Owned(alloc))

0 commit comments

Comments
 (0)