Skip to content

Commit a07398d

Browse files
committed
we don't need HexRange any more
1 parent 178e7f3 commit a07398d

File tree

3 files changed

+21
-25
lines changed

3 files changed

+21
-25
lines changed

src/diagnostics.rs

Lines changed: 19 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ use rustc_middle::ty;
88
use rustc_span::{source_map::DUMMY_SP, Span, SpanData, Symbol};
99
use rustc_target::abi::{Align, Size};
1010

11-
use crate::helpers::HexRange;
1211
use crate::stacked_borrows::{diagnostics::TagHistory, AccessKind};
1312
use crate::*;
1413

@@ -184,14 +183,14 @@ pub fn report_error<'tcx, 'mir>(
184183
];
185184
match history {
186185
Some(TagHistory::Tagged {tag, created: (created_range, created_span), invalidated, protected }) => {
187-
let msg = format!("{:?} was created by a retag at offsets {}", tag, HexRange(*created_range));
186+
let msg = format!("{tag:?} was created by a retag at offsets {created_range:?}");
188187
helps.push((Some(*created_span), msg));
189188
if let Some((invalidated_range, invalidated_span)) = invalidated {
190-
let msg = format!("{:?} was later invalidated at offsets {}", tag, HexRange(*invalidated_range));
189+
let msg = format!("{tag:?} was later invalidated at offsets {invalidated_range:?}");
191190
helps.push((Some(*invalidated_span), msg));
192191
}
193192
if let Some((protecting_tag, protecting_tag_span, protection_span)) = protected {
194-
helps.push((Some(*protecting_tag_span), format!("{:?} was protected due to {:?} which was created here", tag, protecting_tag)));
193+
helps.push((Some(*protecting_tag_span), format!("{tag:?} was protected due to {protecting_tag:?} which was created here")));
195194
helps.push((Some(*protection_span), format!("this protector is live for this call")));
196195
}
197196
}
@@ -448,32 +447,38 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriEvalContextExt<'mir, 'tcx
448447
for e in diagnostics.drain(..) {
449448
use NonHaltingDiagnostic::*;
450449
let msg = match e {
451-
CreatedPointerTag(tag, None) => format!("created tag {tag:?}"),
450+
CreatedPointerTag(tag, None) =>
451+
format!("created tag {tag:?}"),
452452
CreatedPointerTag(tag, Some((alloc_id, range))) =>
453-
format!("created tag {tag:?} at {alloc_id:?}{}", HexRange(range)),
453+
format!("created tag {tag:?} at {alloc_id:?}{range:?}"),
454454
PoppedPointerTag(item, tag) =>
455455
match tag {
456456
None =>
457457
format!(
458-
"popped tracked tag for item {:?} due to deallocation",
459-
item
458+
"popped tracked tag for item {item:?} due to deallocation",
460459
),
461460
Some((tag, access)) => {
462461
format!(
463-
"popped tracked tag for item {:?} due to {:?} access for {:?}",
464-
item, access, tag
462+
"popped tracked tag for item {item:?} due to {access:?} access for {tag:?}",
465463
)
466464
}
467465
},
468-
CreatedCallId(id) => format!("function call with id {id}"),
466+
CreatedCallId(id) =>
467+
format!("function call with id {id}"),
469468
CreatedAlloc(AllocId(id), size, align, kind) =>
470-
format!("created {kind} allocation of {} bytes (alignment {} bytes) with id {id}", size.bytes(), align.bytes()),
471-
FreedAlloc(AllocId(id)) => format!("freed allocation with id {id}"),
469+
format!(
470+
"created {kind} allocation of {size} bytes (alignment {align} bytes) with id {id}",
471+
size = size.bytes(),
472+
align = align.bytes(),
473+
),
474+
FreedAlloc(AllocId(id)) =>
475+
format!("freed allocation with id {id}"),
472476
RejectedIsolatedOp(ref op) =>
473477
format!("{op} was made to return an error due to isolation"),
474478
ProgressReport =>
475479
format!("progress report: current operation being executed is here"),
476-
Int2Ptr { .. } => format!("integer-to-pointer cast"),
480+
Int2Ptr { .. } =>
481+
format!("integer-to-pointer cast"),
477482
};
478483

479484
let (title, diag_level) = match e {

src/helpers.rs

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -905,15 +905,6 @@ pub fn get_local_crates(tcx: TyCtxt<'_>) -> Vec<CrateNum> {
905905
local_crates
906906
}
907907

908-
/// Formats an AllocRange like [0x1..0x3], for use in diagnostics.
909-
pub struct HexRange(pub AllocRange);
910-
911-
impl std::fmt::Display for HexRange {
912-
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
913-
write!(f, "[{:#x}..{:#x}]", self.0.start.bytes(), self.0.end().bytes())
914-
}
915-
}
916-
917908
/// Helper function used inside the shims of foreign functions to check that
918909
/// `target_os` is a supported UNIX OS.
919910
pub fn target_os_is_unix(target_os: &str) -> bool {

src/stacked_borrows/diagnostics.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ use rustc_middle::mir::interpret::{AllocId, AllocRange};
44
use rustc_span::{Span, SpanData};
55
use rustc_target::abi::Size;
66

7-
use crate::helpers::{CurrentSpan, HexRange};
7+
use crate::helpers::CurrentSpan;
88
use crate::stacked_borrows::{err_sb_ub, AccessKind, Permission};
99
use crate::Item;
1010
use crate::SbTag;
@@ -178,7 +178,7 @@ fn operation_summary(
178178
alloc_id: AllocId,
179179
alloc_range: AllocRange,
180180
) -> String {
181-
format!("this error occurs as part of {} at {:?}{}", operation, alloc_id, HexRange(alloc_range))
181+
format!("this error occurs as part of {operation} at {alloc_id:?}{alloc_range:?}")
182182
}
183183

184184
fn error_cause(stack: &Stack, tag: SbTagExtra) -> &'static str {

0 commit comments

Comments
 (0)