Skip to content

Commit

Permalink
fmt and clippy
Browse files Browse the repository at this point in the history
  • Loading branch information
RalfJung committed Dec 9, 2022
1 parent 2be695b commit bb7c9e7
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 9 deletions.
12 changes: 10 additions & 2 deletions src/borrow_tracker/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -264,15 +264,23 @@ impl GlobalStateInner {

impl<'mir, 'tcx: 'mir> EvalContextExt<'mir, 'tcx> for crate::MiriInterpCx<'mir, 'tcx> {}
pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriInterpCxExt<'mir, 'tcx> {
fn retag_ptr_value(&mut self, kind: RetagKind, val: &ImmTy<'tcx, Provenance>) -> InterpResult<'tcx, ImmTy<'tcx, Provenance>> {
fn retag_ptr_value(
&mut self,
kind: RetagKind,
val: &ImmTy<'tcx, Provenance>,
) -> InterpResult<'tcx, ImmTy<'tcx, Provenance>> {
let this = self.eval_context_mut();
let method = this.machine.borrow_tracker.as_ref().unwrap().borrow().borrow_tracker_method;
match method {
BorrowTrackerMethod::StackedBorrows => this.sb_retag_ptr_value(kind, val),
}
}

fn retag_place_contents(&mut self, kind: RetagKind, place: &PlaceTy<'tcx, Provenance>) -> InterpResult<'tcx> {
fn retag_place_contents(
&mut self,
kind: RetagKind,
place: &PlaceTy<'tcx, Provenance>,
) -> InterpResult<'tcx> {
let this = self.eval_context_mut();
let method = this.machine.borrow_tracker.as_ref().unwrap().borrow().borrow_tracker_method;
match method {
Expand Down
4 changes: 3 additions & 1 deletion src/borrow_tracker/stacked_borrows/diagnostics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -462,7 +462,9 @@ impl<'history, 'ecx, 'mir, 'tcx> DiagnosticCx<'history, 'ecx, 'mir, 'tcx> {
Operation::Retag(RetagOp { orig_tag, permission, new_tag, .. }) => {
let permission = permission
.expect("start_grant should set the current permission before popping a tag");
format!(" due to {permission:?} retag from {orig_tag:?} (that retag created {new_tag:?})")
format!(
" due to {permission:?} retag from {orig_tag:?} (that retag created {new_tag:?})"
)
}
};

Expand Down
5 changes: 3 additions & 2 deletions src/borrow_tracker/stacked_borrows/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ use rustc_middle::mir::{Mutability, RetagKind};
use rustc_middle::ty::{
self,
layout::{HasParamEnv, LayoutOf},
Ty,
};
use rustc_target::abi::{Abi, Size};

Expand Down Expand Up @@ -64,7 +65,7 @@ impl NewPermission {
/// A key function: determine the permissions to grant at a retag for the given kind of
/// reference/pointer.
fn from_ref_ty<'tcx>(
ty: ty::Ty<'tcx>,
ty: Ty<'tcx>,
kind: RetagKind,
cx: &crate::MiriInterpCx<'_, 'tcx>,
) -> Self {
Expand Down Expand Up @@ -864,7 +865,7 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriInterpCxExt<'mir, 'tcx> {
RetagKind::FnEntry => unreachable!(),
RetagKind::Raw | RetagKind::Default => RetagCause::Normal,
};
this.sb_retag_reference(&val, new_perm, retag_cause)
this.sb_retag_reference(val, new_perm, retag_cause)
}

fn sb_retag_place_contents(
Expand Down
3 changes: 2 additions & 1 deletion src/diagnostics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -393,7 +393,8 @@ impl<'mir, 'tcx> MiriMachine<'mir, 'tcx> {

let msg = match &e {
CreatedPointerTag(tag, None, _) => format!("created base tag {tag:?}"),
CreatedPointerTag(tag, Some(perm), None) => format!("created {tag:?} with {perm} derived from unknown tag"),
CreatedPointerTag(tag, Some(perm), None) =>
format!("created {tag:?} with {perm} derived from unknown tag"),
CreatedPointerTag(tag, Some(perm), Some((alloc_id, range, orig_tag))) =>
format!(
"created tag {tag:?} with {perm} at {alloc_id:?}{range:?} derived from {orig_tag:?}"
Expand Down
5 changes: 2 additions & 3 deletions src/machine.rs
Original file line number Diff line number Diff line change
Expand Up @@ -967,9 +967,8 @@ impl<'mir, 'tcx> Machine<'mir, 'tcx> for MiriMachine<'mir, 'tcx> {
ptr: Pointer<Self::Provenance>,
) -> InterpResult<'tcx> {
match ptr.provenance {
Provenance::Concrete { alloc_id, tag } => {
intptrcast::GlobalStateInner::expose_ptr(ecx, alloc_id, tag)
}
Provenance::Concrete { alloc_id, tag } =>
intptrcast::GlobalStateInner::expose_ptr(ecx, alloc_id, tag),
Provenance::Wildcard => {
// No need to do anything for wildcard pointers as
// their provenances have already been previously exposed.
Expand Down

0 comments on commit bb7c9e7

Please sign in to comment.