Skip to content

Commit

Permalink
fmt (with a huge diff for some reason)
Browse files Browse the repository at this point in the history
  • Loading branch information
RalfJung committed Sep 21, 2024
1 parent e06b473 commit 6357a75
Show file tree
Hide file tree
Showing 75 changed files with 180 additions and 205 deletions.
2 changes: 1 addition & 1 deletion miri-script/src/args.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use std::env;
use std::iter;

use anyhow::{bail, Result};
use anyhow::{Result, bail};

pub struct Args {
args: iter::Peekable<env::Args>,
Expand Down
6 changes: 3 additions & 3 deletions miri-script/src/commands.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,13 @@ use std::path::PathBuf;
use std::process;
use std::time::Duration;

use anyhow::{anyhow, bail, Context, Result};
use anyhow::{Context, Result, anyhow, bail};
use path_macro::path;
use walkdir::WalkDir;
use xshell::{cmd, Shell};
use xshell::{Shell, cmd};

use crate::util::*;
use crate::Command;
use crate::util::*;

/// Used for rustc syncs.
const JOSH_FILTER: &str =
Expand Down
2 changes: 1 addition & 1 deletion miri-script/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ mod util;

use std::ops::Range;

use anyhow::{anyhow, bail, Context, Result};
use anyhow::{Context, Result, anyhow, bail};

#[derive(Clone, Debug)]
pub enum Command {
Expand Down
4 changes: 2 additions & 2 deletions miri-script/src/util.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@ use std::path::{Path, PathBuf};
use std::sync::atomic::{AtomicBool, AtomicU32, Ordering};
use std::{env, iter, thread};

use anyhow::{anyhow, bail, Context, Result};
use anyhow::{Context, Result, anyhow, bail};
use dunce::canonicalize;
use path_macro::path;
use xshell::{cmd, Cmd, Shell};
use xshell::{Cmd, Shell, cmd};

pub fn miri_dir() -> std::io::Result<PathBuf> {
const MIRI_SCRIPT_ROOT_DIR: &str = env!("CARGO_MANIFEST_DIR");
Expand Down
2 changes: 1 addition & 1 deletion src/alloc_addresses/reuse_pool.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use rand::Rng;

use rustc_target::abi::{Align, Size};

use crate::{concurrency::VClock, MemoryKind, MiriConfig, ThreadId};
use crate::{MemoryKind, MiriConfig, ThreadId, concurrency::VClock};

const MAX_POOL_SIZE: usize = 64;

Expand Down
22 changes: 10 additions & 12 deletions src/borrow_tracker/stacked_borrows/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,12 @@ use std::mem;

use rustc_data_structures::fx::FxHashSet;
use rustc_middle::mir::{Mutability, RetagKind};
use rustc_middle::ty::{self, layout::HasParamEnv, Ty};
use rustc_middle::ty::{self, Ty, layout::HasParamEnv};
use rustc_target::abi::{Abi, Size};

use crate::borrow_tracker::{
stacked_borrows::diagnostics::{AllocHistory, DiagnosticCx, DiagnosticCxBuilder},
GlobalStateInner, ProtectorKind,
stacked_borrows::diagnostics::{AllocHistory, DiagnosticCx, DiagnosticCxBuilder},
};
use crate::concurrency::data_race::{NaReadType, NaWriteType};
use crate::*;
Expand Down Expand Up @@ -913,11 +913,10 @@ pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> {
new_perm: NewPermission,
) -> InterpResult<'tcx> {
let val = self.ecx.read_immediate(&self.ecx.place_to_op(place)?)?;
let val = self.ecx.sb_retag_reference(
&val,
new_perm,
RetagInfo { cause: self.retag_cause, in_field: self.in_field },
)?;
let val = self.ecx.sb_retag_reference(&val, new_perm, RetagInfo {
cause: self.retag_cause,
in_field: self.in_field,
})?;
self.ecx.write_immediate(*val, place)?;
Ok(())
}
Expand Down Expand Up @@ -1003,11 +1002,10 @@ pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> {
access: Some(AccessKind::Write),
protector: Some(ProtectorKind::StrongProtector),
};
this.sb_retag_place(
place,
new_perm,
RetagInfo { cause: RetagCause::InPlaceFnPassing, in_field: false },
)
this.sb_retag_place(place, new_perm, RetagInfo {
cause: RetagCause::InPlaceFnPassing,
in_field: false,
})
}

/// Mark the given tag as exposed. It was found on a pointer with the given AllocId.
Expand Down
4 changes: 2 additions & 2 deletions src/borrow_tracker/stacked_borrows/stack.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@ use std::ops::Range;
use rustc_data_structures::fx::FxHashSet;
use tracing::trace;

use crate::ProvenanceExtra;
use crate::borrow_tracker::{
stacked_borrows::{Item, Permission},
AccessKind, BorTag,
stacked_borrows::{Item, Permission},
};
use crate::ProvenanceExtra;

/// Exactly what cache size we should use is a difficult trade-off. There will always be some
/// workload which has a `BorTag` working set which exceeds the size of the cache, and ends up
Expand Down
2 changes: 1 addition & 1 deletion src/borrow_tracker/tree_borrows/diagnostics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@ use std::ops::Range;
use rustc_data_structures::fx::FxHashMap;
use rustc_span::{Span, SpanData};

use crate::borrow_tracker::ProtectorKind;
use crate::borrow_tracker::tree_borrows::{
perms::{PermTransition, Permission},
tree::LocationState,
unimap::UniIndex,
};
use crate::borrow_tracker::ProtectorKind;
use crate::*;

/// Cause of an access: either a real access or one
Expand Down
2 changes: 1 addition & 1 deletion src/borrow_tracker/tree_borrows/mod.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use rustc_middle::{
mir::{Mutability, RetagKind},
ty::{self, layout::HasParamEnv, Ty},
ty::{self, Ty, layout::HasParamEnv},
};
use rustc_span::def_id::DefId;
use rustc_target::abi::{Abi, Size};
Expand Down
24 changes: 10 additions & 14 deletions src/borrow_tracker/tree_borrows/perms.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
use std::cmp::{Ordering, PartialOrd};
use std::fmt;

use crate::AccessKind;
use crate::borrow_tracker::tree_borrows::diagnostics::TransitionError;
use crate::borrow_tracker::tree_borrows::tree::AccessRelatedness;
use crate::AccessKind;

/// The activation states of a pointer.
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
Expand Down Expand Up @@ -345,18 +345,14 @@ pub mod diagnostics {
use super::*;
impl fmt::Display for PermissionPriv {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
write!(
f,
"{}",
match self {
ReservedFrz { conflicted: false } => "Reserved",
ReservedFrz { conflicted: true } => "Reserved (conflicted)",
ReservedIM => "Reserved (interior mutable)",
Active => "Active",
Frozen => "Frozen",
Disabled => "Disabled",
}
)
write!(f, "{}", match self {
ReservedFrz { conflicted: false } => "Reserved",
ReservedFrz { conflicted: true } => "Reserved (conflicted)",
ReservedIM => "Reserved (interior mutable)",
Active => "Active",
Frozen => "Frozen",
Disabled => "Disabled",
})
}
}

Expand Down Expand Up @@ -551,7 +547,7 @@ impl Permission {
#[cfg(test)]
mod propagation_optimization_checks {
pub use super::*;
use crate::borrow_tracker::tree_borrows::exhaustive::{precondition, Exhaustive};
use crate::borrow_tracker::tree_borrows::exhaustive::{Exhaustive, precondition};

impl Exhaustive for PermissionPriv {
fn exhaustive() -> Box<dyn Iterator<Item = Self>> {
Expand Down
36 changes: 15 additions & 21 deletions src/borrow_tracker/tree_borrows/tree.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,10 @@ use rustc_span::Span;
use rustc_target::abi::Size;

use crate::borrow_tracker::tree_borrows::{
Permission,
diagnostics::{self, NodeDebugInfo, TbError, TransitionError},
perms::PermTransition,
unimap::{UniEntry, UniIndex, UniKeyMap, UniValMap},
Permission,
};
use crate::borrow_tracker::{GlobalState, ProtectorKind};
use crate::*;
Expand Down Expand Up @@ -587,16 +587,13 @@ impl Tree {
let mut debug_info = NodeDebugInfo::new(root_tag, root_default_perm, span);
// name the root so that all allocations contain one named pointer
debug_info.add_name("root of the allocation");
nodes.insert(
root_idx,
Node {
tag: root_tag,
parent: None,
children: SmallVec::default(),
default_initial_perm: root_default_perm,
debug_info,
},
);
nodes.insert(root_idx, Node {
tag: root_tag,
parent: None,
children: SmallVec::default(),
default_initial_perm: root_default_perm,
debug_info,
});
nodes
};
let rperms = {
Expand Down Expand Up @@ -626,16 +623,13 @@ impl<'tcx> Tree {
let idx = self.tag_mapping.insert(new_tag);
let parent_idx = self.tag_mapping.get(&parent_tag).unwrap();
// Create the node
self.nodes.insert(
idx,
Node {
tag: new_tag,
parent: Some(parent_idx),
children: SmallVec::default(),
default_initial_perm,
debug_info: NodeDebugInfo::new(new_tag, default_initial_perm, span),
},
);
self.nodes.insert(idx, Node {
tag: new_tag,
parent: Some(parent_idx),
children: SmallVec::default(),
default_initial_perm,
debug_info: NodeDebugInfo::new(new_tag, default_initial_perm, span),
});
// Register new_tag as a child of parent_tag
self.nodes.get_mut(parent_idx).unwrap().children.push(idx);
// Initialize perms
Expand Down
2 changes: 1 addition & 1 deletion src/borrow_tracker/tree_borrows/tree/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
#![cfg(test)]

use super::*;
use crate::borrow_tracker::tree_borrows::exhaustive::{precondition, Exhaustive};
use crate::borrow_tracker::tree_borrows::exhaustive::{Exhaustive, precondition};
use std::fmt;

impl Exhaustive for LocationState {
Expand Down
22 changes: 9 additions & 13 deletions src/concurrency/sync.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use std::any::Any;
use std::collections::{hash_map::Entry, VecDeque};
use std::collections::{VecDeque, hash_map::Entry};
use std::ops::Not;
use std::time::Duration;

Expand Down Expand Up @@ -283,12 +283,10 @@ pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> {
data: Option<Box<dyn Any>>,
) -> InterpResult<'tcx, MutexId> {
let this = self.eval_context_mut();
this.create_id(
lock,
offset,
|ecx| &mut ecx.machine.sync.mutexes,
Mutex { data, ..Default::default() },
)
this.create_id(lock, offset, |ecx| &mut ecx.machine.sync.mutexes, Mutex {
data,
..Default::default()
})
}

/// Lazily create a new mutex.
Expand Down Expand Up @@ -355,12 +353,10 @@ pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> {
data: Option<Box<dyn Any>>,
) -> InterpResult<'tcx, CondvarId> {
let this = self.eval_context_mut();
this.create_id(
condvar,
offset,
|ecx| &mut ecx.machine.sync.condvars,
Condvar { data, ..Default::default() },
)
this.create_id(condvar, offset, |ecx| &mut ecx.machine.sync.condvars, Condvar {
data,
..Default::default()
})
}

fn condvar_get_or_create_id(
Expand Down
2 changes: 1 addition & 1 deletion src/concurrency/vector_clock.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use rustc_index::Idx;
use rustc_span::{Span, SpanData, DUMMY_SP};
use rustc_span::{DUMMY_SP, Span, SpanData};
use smallvec::SmallVec;
use std::{
cmp::Ordering,
Expand Down
2 changes: 1 addition & 1 deletion src/diagnostics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use std::fmt::{self, Write};
use std::num::NonZero;

use rustc_errors::{Diag, DiagMessage, Level};
use rustc_span::{SpanData, Symbol, DUMMY_SP};
use rustc_span::{DUMMY_SP, SpanData, Symbol};
use rustc_target::abi::{Align, Size};

use crate::borrow_tracker::stacked_borrows::diagnostics::TagHistory;
Expand Down
3 changes: 1 addition & 2 deletions src/eval.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,8 @@ use rustc_data_structures::fx::{FxHashMap, FxHashSet};
use rustc_hir::def::Namespace;
use rustc_hir::def_id::DefId;
use rustc_middle::ty::{
self,
self, Ty, TyCtxt,
layout::{LayoutCx, LayoutOf},
Ty, TyCtxt,
};
use rustc_target::spec::abi::Abi;

Expand Down
9 changes: 4 additions & 5 deletions src/helpers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,12 @@ use std::time::Duration;

use rand::RngCore;

use rustc_apfloat::ieee::{Double, Half, Quad, Single};
use rustc_apfloat::Float;
use rustc_apfloat::ieee::{Double, Half, Quad, Single};
use rustc_hir::{
def::{DefKind, Namespace},
def_id::{CrateNum, DefId, CRATE_DEF_INDEX, LOCAL_CRATE},
Safety,
def::{DefKind, Namespace},
def_id::{CRATE_DEF_INDEX, CrateNum, DefId, LOCAL_CRATE},
};
use rustc_index::IndexVec;
use rustc_middle::middle::codegen_fn_attrs::CodegenFnAttrFlags;
Expand All @@ -21,9 +21,8 @@ use rustc_middle::middle::exported_symbols::ExportedSymbol;
use rustc_middle::mir;
use rustc_middle::ty::layout::{FnAbiOf, MaybeResult};
use rustc_middle::ty::{
self,
self, FloatTy, IntTy, Ty, TyCtxt, UintTy,
layout::{LayoutOf, TyAndLayout},
FloatTy, IntTy, Ty, TyCtxt, UintTy,
};
use rustc_session::config::CrateType;
use rustc_span::{Span, Symbol};
Expand Down
4 changes: 2 additions & 2 deletions src/intrinsics/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,12 @@ use rustc_middle::{
mir,
ty::{self, FloatTy},
};
use rustc_span::{sym, Symbol};
use rustc_span::{Symbol, sym};
use rustc_target::abi::Size;

use crate::*;
use atomic::EvalContextExt as _;
use helpers::{check_arg_count, ToHost, ToSoft};
use helpers::{ToHost, ToSoft, check_arg_count};
use simd::EvalContextExt as _;

impl<'tcx> EvalContextExt<'tcx> for crate::MiriInterpCx<'tcx> {}
Expand Down
4 changes: 2 additions & 2 deletions src/intrinsics/simd.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@ use either::Either;
use rustc_apfloat::{Float, Round};
use rustc_middle::ty::layout::{HasParamEnv, LayoutOf};
use rustc_middle::{mir, ty, ty::FloatTy};
use rustc_span::{sym, Symbol};
use rustc_span::{Symbol, sym};
use rustc_target::abi::{Endian, HasDataLayout};

use crate::helpers::{bool_to_simd_element, check_arg_count, simd_element_to_bool, ToHost, ToSoft};
use crate::helpers::{ToHost, ToSoft, bool_to_simd_element, check_arg_count, simd_element_to_bool};
use crate::*;

#[derive(Copy, Clone)]
Expand Down
Loading

0 comments on commit 6357a75

Please sign in to comment.