Skip to content

Commit 707afc3

Browse files
author
The Miri Conjob Bot
committed
fmt
1 parent 1505dd8 commit 707afc3

File tree

6 files changed

+53
-35
lines changed

6 files changed

+53
-35
lines changed

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

Lines changed: 19 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -221,7 +221,10 @@ impl AllocHistory {
221221
impl<'history, 'ecx, 'mir, 'tcx> DiagnosticCx<'history, 'ecx, 'mir, 'tcx> {
222222
pub fn start_grant(&mut self, perm: Permission) {
223223
let Operation::Retag(op) = &mut self.operation else {
224-
unreachable!("start_grant must only be called during a retag, this is: {:?}", self.operation)
224+
unreachable!(
225+
"start_grant must only be called during a retag, this is: {:?}",
226+
self.operation
227+
)
225228
};
226229
op.permission = Some(perm);
227230

@@ -286,7 +289,8 @@ impl<'history, 'ecx, 'mir, 'tcx> DiagnosticCx<'history, 'ecx, 'mir, 'tcx> {
286289
tag: BorTag,
287290
protector_tag: Option<BorTag>,
288291
) -> Option<TagHistory> {
289-
let Some(created) = self.history
292+
let Some(created) = self
293+
.history
290294
.creations
291295
.iter()
292296
.rev()
@@ -315,22 +319,27 @@ impl<'history, 'ecx, 'mir, 'tcx> DiagnosticCx<'history, 'ecx, 'mir, 'tcx> {
315319
None
316320
}
317321
})
318-
}).or_else(|| {
322+
})
323+
.or_else(|| {
319324
// If we didn't find a retag that created this tag, it might be the base tag of
320325
// this allocation.
321326
if self.history.base.0.tag() == tag {
322327
Some((
323-
format!("{tag:?} was created here, as the base tag for {:?}", self.history.id),
324-
self.history.base.1.data()
328+
format!(
329+
"{tag:?} was created here, as the base tag for {:?}",
330+
self.history.id
331+
),
332+
self.history.base.1.data(),
325333
))
326334
} else {
327335
None
328336
}
329-
}) else {
330-
// But if we don't have a creation event, this is related to a wildcard, and there
331-
// is really nothing we can do to help.
332-
return None;
333-
};
337+
})
338+
else {
339+
// But if we don't have a creation event, this is related to a wildcard, and there
340+
// is really nothing we can do to help.
341+
return None;
342+
};
334343

335344
let invalidated = self.history.invalidations.iter().rev().find_map(|event| {
336345
if event.tag == tag { Some(event.generate_diagnostic()) } else { None }

src/tools/miri/src/borrow_tracker/stacked_borrows/mod.rs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -430,12 +430,15 @@ impl<'tcx> Stack {
430430
.find_granting(AccessKind::Write, derived_from, exposed_tags)
431431
.map_err(|()| dcx.grant_error(self))?;
432432

433-
let (Some(granting_idx), ProvenanceExtra::Concrete(_)) = (granting_idx, derived_from) else {
433+
let (Some(granting_idx), ProvenanceExtra::Concrete(_)) = (granting_idx, derived_from)
434+
else {
434435
// The parent is a wildcard pointer or matched the unknown bottom.
435436
// This is approximate. Nobody knows what happened, so forget everything.
436437
// The new thing is SRW anyway, so we cannot push it "on top of the unknown part"
437438
// (for all we know, it might join an SRW group inside the unknown).
438-
trace!("reborrow: forgetting stack entirely due to SharedReadWrite reborrow from wildcard or unknown");
439+
trace!(
440+
"reborrow: forgetting stack entirely due to SharedReadWrite reborrow from wildcard or unknown"
441+
);
439442
self.set_unknown_bottom(global.next_ptr_tag);
440443
return Ok(());
441444
};

src/tools/miri/src/borrow_tracker/stacked_borrows/stack.rs

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -196,19 +196,19 @@ impl<'tcx> Stack {
196196
let ProvenanceExtra::Concrete(tag) = tag else {
197197
// Handle the wildcard case.
198198
// Go search the stack for an exposed tag.
199-
if let Some(idx) =
200-
self.borrows
201-
.iter()
202-
.enumerate() // we also need to know *where* in the stack
203-
.rev() // search top-to-bottom
204-
.find_map(|(idx, item)| {
205-
// If the item fits and *might* be this wildcard, use it.
206-
if item.perm().grants(access) && exposed_tags.contains(&item.tag()) {
207-
Some(idx)
208-
} else {
209-
None
210-
}
211-
})
199+
if let Some(idx) = self
200+
.borrows
201+
.iter()
202+
.enumerate() // we also need to know *where* in the stack
203+
.rev() // search top-to-bottom
204+
.find_map(|(idx, item)| {
205+
// If the item fits and *might* be this wildcard, use it.
206+
if item.perm().grants(access) && exposed_tags.contains(&item.tag()) {
207+
Some(idx)
208+
} else {
209+
None
210+
}
211+
})
212212
{
213213
return Ok(Some(idx));
214214
}

src/tools/miri/src/borrow_tracker/tree_borrows/diagnostics.rs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -570,9 +570,13 @@ impl DisplayRepr {
570570
extraction_aux(tree, tree.root, show_unnamed, &mut v);
571571
let Some(root) = v.pop() else {
572572
if show_unnamed {
573-
unreachable!("This allocation contains no tags, not even a root. This should not happen.");
573+
unreachable!(
574+
"This allocation contains no tags, not even a root. This should not happen."
575+
);
574576
}
575-
eprintln!("This allocation does not contain named tags. Use `miri_print_borrow_state(_, true)` to also print unnamed tags.");
577+
eprintln!(
578+
"This allocation does not contain named tags. Use `miri_print_borrow_state(_, true)` to also print unnamed tags."
579+
);
576580
return None;
577581
};
578582
assert!(v.is_empty());

src/tools/miri/src/borrow_tracker/tree_borrows/mod.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -256,7 +256,9 @@ trait EvalContextPrivExt<'mir: 'ecx, 'tcx: 'mir, 'ecx>: crate::MiriInterpCxExt<'
256256
ptr_size.bytes()
257257
);
258258

259-
let Some(new_perm) = new_perm else { return Ok(Some((alloc_id, orig_tag))); };
259+
let Some(new_perm) = new_perm else {
260+
return Ok(Some((alloc_id, orig_tag)));
261+
};
260262

261263
if let Some(protect) = new_perm.protector {
262264
// We register the protection in two different places.

src/tools/miri/src/shims/intrinsics/simd.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -483,7 +483,11 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriInterpCxExt<'mir, 'tcx> {
483483

484484
// `index` is an array, not a SIMD type
485485
let ty::Array(_, index_len) = index.layout.ty.kind() else {
486-
span_bug!(this.cur_span(), "simd_shuffle index argument has non-array type {}", index.layout.ty)
486+
span_bug!(
487+
this.cur_span(),
488+
"simd_shuffle index argument has non-array type {}",
489+
index.layout.ty
490+
)
487491
};
488492
let index_len = index_len.eval_target_usize(*this.tcx, this.param_env());
489493

@@ -622,9 +626,7 @@ fn fmax_op<'tcx>(
622626
right: &ImmTy<'tcx, Provenance>,
623627
) -> InterpResult<'tcx, Scalar<Provenance>> {
624628
assert_eq!(left.layout.ty, right.layout.ty);
625-
let ty::Float(float_ty) = left.layout.ty.kind() else {
626-
bug!("fmax operand is not a float")
627-
};
629+
let ty::Float(float_ty) = left.layout.ty.kind() else { bug!("fmax operand is not a float") };
628630
let left = left.to_scalar();
629631
let right = right.to_scalar();
630632
Ok(match float_ty {
@@ -638,9 +640,7 @@ fn fmin_op<'tcx>(
638640
right: &ImmTy<'tcx, Provenance>,
639641
) -> InterpResult<'tcx, Scalar<Provenance>> {
640642
assert_eq!(left.layout.ty, right.layout.ty);
641-
let ty::Float(float_ty) = left.layout.ty.kind() else {
642-
bug!("fmin operand is not a float")
643-
};
643+
let ty::Float(float_ty) = left.layout.ty.kind() else { bug!("fmin operand is not a float") };
644644
let left = left.to_scalar();
645645
let right = right.to_scalar();
646646
Ok(match float_ty {

0 commit comments

Comments
 (0)