1
Fork 0

let rustfmt format imports

This commit is contained in:
Ralf Jung 2024-09-29 18:51:03 +02:00
parent 6abc731f92
commit ad8a5ce4ca
93 changed files with 255 additions and 319 deletions

View file

@ -1,8 +1,9 @@
//! Extracted from the backtrace crate's test test_frame_conversion //! Extracted from the backtrace crate's test test_frame_conversion
use backtrace::{Backtrace, BacktraceFrame};
use std::fmt::Write; use std::fmt::Write;
use backtrace::{Backtrace, BacktraceFrame};
fn main() { fn main() {
let mut frames = vec![]; let mut frames = vec![];
backtrace::trace(|frame| { backtrace::trace(|frame| {

File diff suppressed because one or more lines are too long

View file

@ -8,7 +8,8 @@ use std::{env, thread};
use rustc_version::VersionMeta; use rustc_version::VersionMeta;
use crate::{setup::*, util::*}; use crate::setup::*;
use crate::util::*;
const CARGO_MIRI_HELP: &str = r"Runs binary crates and tests in Miri const CARGO_MIRI_HELP: &str = r"Runs binary crates and tests in Miri

View file

@ -1,5 +1,4 @@
use std::env; use std::{env, iter};
use std::iter;
use anyhow::{Result, bail}; use anyhow::{Result, bail};

View file

@ -1,12 +1,9 @@
use std::env;
use std::ffi::{OsStr, OsString}; use std::ffi::{OsStr, OsString};
use std::io::Write; use std::io::Write;
use std::net; use std::ops::{Not, Range};
use std::ops::Not;
use std::ops::Range;
use std::path::PathBuf; use std::path::PathBuf;
use std::process;
use std::time::Duration; use std::time::Duration;
use std::{env, net, process};
use anyhow::{Context, Result, anyhow, bail}; use anyhow::{Context, Result, anyhow, bail};
use path_macro::path; use path_macro::path;

View file

@ -1,5 +1,10 @@
# This matches rustc
style_edition = "2024" style_edition = "2024"
use_small_heuristics = "Max" use_small_heuristics = "Max"
group_imports = "StdExternalCrate"
imports_granularity = "Module"
# Miri-specific settings
force_multiline_blocks = true
match_arm_blocks = false match_arm_blocks = false
match_arm_leading_pipes = "Preserve" match_arm_leading_pipes = "Preserve"
force_multiline_blocks = true

View file

@ -7,14 +7,13 @@ use std::cell::RefCell;
use std::cmp::max; use std::cmp::max;
use rand::Rng; use rand::Rng;
use rustc_data_structures::fx::{FxHashMap, FxHashSet}; use rustc_data_structures::fx::{FxHashMap, FxHashSet};
use rustc_span::Span; use rustc_span::Span;
use rustc_target::abi::{Align, Size}; use rustc_target::abi::{Align, Size};
use crate::{concurrency::VClock, *};
use self::reuse_pool::ReusePool; use self::reuse_pool::ReusePool;
use crate::concurrency::VClock;
use crate::*;
#[derive(Copy, Clone, Debug, PartialEq, Eq)] #[derive(Copy, Clone, Debug, PartialEq, Eq)]
pub enum ProvenanceMode { pub enum ProvenanceMode {

View file

@ -1,10 +1,10 @@
//! Manages a pool of addresses that can be reused. //! Manages a pool of addresses that can be reused.
use rand::Rng; use rand::Rng;
use rustc_target::abi::{Align, Size}; use rustc_target::abi::{Align, Size};
use crate::{MemoryKind, MiriConfig, ThreadId, concurrency::VClock}; use crate::concurrency::VClock;
use crate::{MemoryKind, MiriConfig, ThreadId};
const MAX_POOL_SIZE: usize = 64; const MAX_POOL_SIZE: usize = 64;

View file

@ -1,7 +1,6 @@
use std::alloc;
use std::alloc::Layout; use std::alloc::Layout;
use std::borrow::Cow; use std::borrow::Cow;
use std::slice; use std::{alloc, slice};
use rustc_middle::mir::interpret::AllocBytes; use rustc_middle::mir::interpret::AllocBytes;
use rustc_target::abi::{Align, Size}; use rustc_target::abi::{Align, Size};

View file

@ -28,31 +28,27 @@ use std::num::NonZero;
use std::path::PathBuf; use std::path::PathBuf;
use std::str::FromStr; use std::str::FromStr;
use tracing::debug; use miri::{BacktraceStyle, BorrowTrackerMethod, ProvenanceMode, RetagFields, ValidationMode};
use rustc_data_structures::sync::Lrc; use rustc_data_structures::sync::Lrc;
use rustc_driver::Compilation; use rustc_driver::Compilation;
use rustc_hir::def_id::LOCAL_CRATE; use rustc_hir::def_id::LOCAL_CRATE;
use rustc_hir::{self as hir, Node}; use rustc_hir::{self as hir, Node};
use rustc_hir_analysis::check::check_function_signature; use rustc_hir_analysis::check::check_function_signature;
use rustc_interface::interface::Config; use rustc_interface::interface::Config;
use rustc_middle::{ use rustc_middle::middle::codegen_fn_attrs::CodegenFnAttrFlags;
middle::{ use rustc_middle::middle::exported_symbols::{
codegen_fn_attrs::CodegenFnAttrFlags, ExportedSymbol, SymbolExportInfo, SymbolExportKind, SymbolExportLevel,
exported_symbols::{ExportedSymbol, SymbolExportInfo, SymbolExportKind, SymbolExportLevel},
},
query::LocalCrate,
traits::{ObligationCause, ObligationCauseCode},
ty::{self, Ty, TyCtxt},
util::Providers,
}; };
use rustc_middle::query::LocalCrate;
use rustc_middle::traits::{ObligationCause, ObligationCauseCode};
use rustc_middle::ty::{self, Ty, TyCtxt};
use rustc_middle::util::Providers;
use rustc_session::config::{CrateType, EntryFnType, ErrorOutputType, OptLevel}; use rustc_session::config::{CrateType, EntryFnType, ErrorOutputType, OptLevel};
use rustc_session::search_paths::PathKind; use rustc_session::search_paths::PathKind;
use rustc_session::{CtfeBacktrace, EarlyDiagCtxt}; use rustc_session::{CtfeBacktrace, EarlyDiagCtxt};
use rustc_span::def_id::DefId; use rustc_span::def_id::DefId;
use rustc_target::spec::abi::Abi; use rustc_target::spec::abi::Abi;
use tracing::debug;
use miri::{BacktraceStyle, BorrowTrackerMethod, ProvenanceMode, RetagFields, ValidationMode};
struct MiriCompilerCalls { struct MiriCompilerCalls {
miri_config: miri::MiriConfig, miri_config: miri::MiriConfig,

View file

@ -2,11 +2,10 @@ use std::cell::RefCell;
use std::fmt; use std::fmt;
use std::num::NonZero; use std::num::NonZero;
use smallvec::SmallVec;
use rustc_data_structures::fx::{FxHashMap, FxHashSet}; use rustc_data_structures::fx::{FxHashMap, FxHashSet};
use rustc_middle::mir::RetagKind; use rustc_middle::mir::RetagKind;
use rustc_target::abi::Size; use rustc_target::abi::Size;
use smallvec::SmallVec;
use crate::*; use crate::*;
pub mod stacked_borrows; pub mod stacked_borrows;

View file

@ -1,9 +1,9 @@
use smallvec::SmallVec;
use std::fmt; use std::fmt;
use rustc_data_structures::fx::FxHashSet; use rustc_data_structures::fx::FxHashSet;
use rustc_span::{Span, SpanData}; use rustc_span::{Span, SpanData};
use rustc_target::abi::Size; use rustc_target::abi::Size;
use smallvec::SmallVec;
use crate::borrow_tracker::{GlobalStateInner, ProtectorKind}; use crate::borrow_tracker::{GlobalStateInner, ProtectorKind};
use crate::*; use crate::*;

View file

@ -6,25 +6,24 @@ mod item;
mod stack; mod stack;
use std::cell::RefCell; use std::cell::RefCell;
use std::cmp;
use std::fmt::Write; use std::fmt::Write;
use std::mem; use std::{cmp, mem};
use rustc_data_structures::fx::FxHashSet; use rustc_data_structures::fx::FxHashSet;
use rustc_middle::mir::{Mutability, RetagKind}; use rustc_middle::mir::{Mutability, RetagKind};
use rustc_middle::ty::{self, Ty, layout::HasParamEnv}; use rustc_middle::ty::layout::HasParamEnv;
use rustc_middle::ty::{self, Ty};
use rustc_target::abi::{Abi, Size}; use rustc_target::abi::{Abi, Size};
use crate::borrow_tracker::{
GlobalStateInner, ProtectorKind,
stacked_borrows::diagnostics::{AllocHistory, DiagnosticCx, DiagnosticCxBuilder},
};
use crate::concurrency::data_race::{NaReadType, NaWriteType};
use crate::*;
use self::diagnostics::{RetagCause, RetagInfo}; use self::diagnostics::{RetagCause, RetagInfo};
pub use self::item::{Item, Permission}; pub use self::item::{Item, Permission};
pub use self::stack::Stack; pub use self::stack::Stack;
use crate::borrow_tracker::stacked_borrows::diagnostics::{
AllocHistory, DiagnosticCx, DiagnosticCxBuilder,
};
use crate::borrow_tracker::{GlobalStateInner, ProtectorKind};
use crate::concurrency::data_race::{NaReadType, NaWriteType};
use crate::*;
pub type AllocState = Stacks; pub type AllocState = Stacks;

View file

@ -5,10 +5,8 @@ use rustc_data_structures::fx::FxHashSet;
use tracing::trace; use tracing::trace;
use crate::ProvenanceExtra; use crate::ProvenanceExtra;
use crate::borrow_tracker::{ use crate::borrow_tracker::stacked_borrows::{Item, Permission};
AccessKind, BorTag, use crate::borrow_tracker::{AccessKind, BorTag};
stacked_borrows::{Item, Permission},
};
/// Exactly what cache size we should use is a difficult trade-off. There will always be some /// 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 /// workload which has a `BorTag` working set which exceeds the size of the cache, and ends up

View file

@ -5,11 +5,9 @@ use rustc_data_structures::fx::FxHashMap;
use rustc_span::{Span, SpanData}; use rustc_span::{Span, SpanData};
use crate::borrow_tracker::ProtectorKind; use crate::borrow_tracker::ProtectorKind;
use crate::borrow_tracker::tree_borrows::{ use crate::borrow_tracker::tree_borrows::perms::{PermTransition, Permission};
perms::{PermTransition, Permission}, use crate::borrow_tracker::tree_borrows::tree::LocationState;
tree::LocationState, use crate::borrow_tracker::tree_borrows::unimap::UniIndex;
unimap::UniIndex,
};
use crate::*; use crate::*;
/// Cause of an access: either a real access or one /// Cause of an access: either a real access or one

View file

@ -1,15 +1,12 @@
use rustc_middle::{ use rustc_middle::mir::{Mutability, RetagKind};
mir::{Mutability, RetagKind}, use rustc_middle::ty::layout::HasParamEnv;
ty::{self, Ty, layout::HasParamEnv}, use rustc_middle::ty::{self, Ty};
};
use rustc_span::def_id::DefId; use rustc_span::def_id::DefId;
use rustc_target::abi::{Abi, Size}; use rustc_target::abi::{Abi, Size};
use crate::borrow_tracker::{GlobalState, GlobalStateInner, ProtectorKind};
use crate::concurrency::data_race::NaReadType;
use crate::*; use crate::*;
use crate::{
borrow_tracker::{GlobalState, GlobalStateInner, ProtectorKind},
concurrency::data_race::NaReadType,
};
pub mod diagnostics; pub mod diagnostics;
mod perms; mod perms;

View file

@ -12,18 +12,17 @@
use std::{fmt, mem}; use std::{fmt, mem};
use smallvec::SmallVec;
use rustc_data_structures::fx::FxHashSet; use rustc_data_structures::fx::FxHashSet;
use rustc_span::Span; use rustc_span::Span;
use rustc_target::abi::Size; use rustc_target::abi::Size;
use smallvec::SmallVec;
use crate::borrow_tracker::tree_borrows::{ use crate::borrow_tracker::tree_borrows::Permission;
Permission, use crate::borrow_tracker::tree_borrows::diagnostics::{
diagnostics::{self, NodeDebugInfo, TbError, TransitionError}, self, NodeDebugInfo, TbError, TransitionError,
perms::PermTransition,
unimap::{UniEntry, UniIndex, UniKeyMap, UniValMap},
}; };
use crate::borrow_tracker::tree_borrows::perms::PermTransition;
use crate::borrow_tracker::tree_borrows::unimap::{UniEntry, UniIndex, UniKeyMap, UniValMap};
use crate::borrow_tracker::{GlobalState, ProtectorKind}; use crate::borrow_tracker::{GlobalState, ProtectorKind};
use crate::*; use crate::*;

View file

@ -1,9 +1,10 @@
//! Tests for the tree //! Tests for the tree
#![cfg(test)] #![cfg(test)]
use std::fmt;
use super::*; use super::*;
use crate::borrow_tracker::tree_borrows::exhaustive::{Exhaustive, precondition}; use crate::borrow_tracker::tree_borrows::exhaustive::{Exhaustive, precondition};
use std::fmt;
impl Exhaustive for LocationState { impl Exhaustive for LocationState {
fn exhaustive() -> Box<dyn Iterator<Item = Self>> { fn exhaustive() -> Box<dyn Iterator<Item = Self>> {

View file

@ -12,7 +12,8 @@
#![allow(dead_code)] #![allow(dead_code)]
use std::{hash::Hash, mem}; use std::hash::Hash;
use std::mem;
use rustc_data_structures::fx::FxHashMap; use rustc_data_structures::fx::FxHashMap;

View file

@ -40,28 +40,23 @@
//! code some atomic operations may increment the timestamp when not necessary but this has no effect //! code some atomic operations may increment the timestamp when not necessary but this has no effect
//! on the data-race detection code. //! on the data-race detection code.
use std::{ use std::cell::{Cell, Ref, RefCell, RefMut};
cell::{Cell, Ref, RefCell, RefMut}, use std::fmt::Debug;
fmt::Debug, use std::mem;
mem,
};
use rustc_ast::Mutability; use rustc_ast::Mutability;
use rustc_data_structures::fx::FxHashMap; use rustc_data_structures::fx::{FxHashMap, FxHashSet};
use rustc_data_structures::fx::FxHashSet;
use rustc_index::{Idx, IndexVec}; use rustc_index::{Idx, IndexVec};
use rustc_middle::{mir, ty::Ty}; use rustc_middle::mir;
use rustc_middle::ty::Ty;
use rustc_span::Span; use rustc_span::Span;
use rustc_target::abi::{Align, HasDataLayout, Size}; use rustc_target::abi::{Align, HasDataLayout, Size};
use super::vector_clock::{VClock, VTimestamp, VectorIdx};
use super::weak_memory::EvalContextExt as _;
use crate::diagnostics::RacingOp; use crate::diagnostics::RacingOp;
use crate::*; use crate::*;
use super::{
vector_clock::{VClock, VTimestamp, VectorIdx},
weak_memory::EvalContextExt as _,
};
pub type AllocState = VClockAlloc; pub type AllocState = VClockAlloc;
/// Valid atomic read-write orderings, alias of atomic::Ordering (not non-exhaustive). /// Valid atomic read-write orderings, alias of atomic::Ordering (not non-exhaustive).

View file

@ -2,10 +2,10 @@
//! ranges and data are discrete and non-splittable -- they represent distinct "objects". An //! ranges and data are discrete and non-splittable -- they represent distinct "objects". An
//! allocation in the map will always have the same range until explicitly removed //! allocation in the map will always have the same range until explicitly removed
use rustc_target::abi::Size;
use std::ops::{Index, IndexMut, Range}; use std::ops::{Index, IndexMut, Range};
use rustc_const_eval::interpret::AllocRange; use rustc_const_eval::interpret::AllocRange;
use rustc_target::abi::Size;
#[derive(Clone, Debug)] #[derive(Clone, Debug)]
struct Elem<T> { struct Elem<T> {

View file

@ -1,5 +1,6 @@
use std::any::Any; use std::any::Any;
use std::collections::{VecDeque, hash_map::Entry}; use std::collections::VecDeque;
use std::collections::hash_map::Entry;
use std::ops::Not; use std::ops::Not;
use std::time::Duration; use std::time::Duration;

View file

@ -7,7 +7,6 @@ use std::task::Poll;
use std::time::{Duration, SystemTime}; use std::time::{Duration, SystemTime};
use either::Either; use either::Either;
use rustc_const_eval::CTRL_C_RECEIVED; use rustc_const_eval::CTRL_C_RECEIVED;
use rustc_data_structures::fx::FxHashMap; use rustc_data_structures::fx::FxHashMap;
use rustc_hir::def_id::DefId; use rustc_hir::def_id::DefId;

View file

@ -1,11 +1,10 @@
use std::cmp::Ordering;
use std::fmt::Debug;
use std::ops::{Index, Shr};
use rustc_index::Idx; use rustc_index::Idx;
use rustc_span::{DUMMY_SP, Span, SpanData}; use rustc_span::{DUMMY_SP, Span, SpanData};
use smallvec::SmallVec; use smallvec::SmallVec;
use std::{
cmp::Ordering,
fmt::Debug,
ops::{Index, Shr},
};
use super::data_race::NaReadType; use super::data_race::NaReadType;
@ -430,10 +429,12 @@ impl Index<VectorIdx> for VClock {
/// test suite /// test suite
#[cfg(test)] #[cfg(test)]
mod tests { mod tests {
use std::cmp::Ordering;
use rustc_span::DUMMY_SP;
use super::{VClock, VTimestamp, VectorIdx}; use super::{VClock, VTimestamp, VectorIdx};
use crate::concurrency::data_race::NaReadType; use crate::concurrency::data_race::NaReadType;
use rustc_span::DUMMY_SP;
use std::cmp::Ordering;
#[test] #[test]
fn test_equal() { fn test_equal() {

View file

@ -76,21 +76,16 @@
// (https://github.com/ChrisLidbury/tsan11/blob/ecbd6b81e9b9454e01cba78eb9d88684168132c7/lib/tsan/rtl/tsan_relaxed.cc#L295) // (https://github.com/ChrisLidbury/tsan11/blob/ecbd6b81e9b9454e01cba78eb9d88684168132c7/lib/tsan/rtl/tsan_relaxed.cc#L295)
// and here. // and here.
use std::{ use std::cell::{Ref, RefCell};
cell::{Ref, RefCell}, use std::collections::VecDeque;
collections::VecDeque,
};
use rustc_data_structures::fx::FxHashMap; use rustc_data_structures::fx::FxHashMap;
use super::data_race::{GlobalState as DataRaceState, ThreadClockSet};
use super::range_object_map::{AccessType, RangeObjectMap};
use super::vector_clock::{VClock, VTimestamp, VectorIdx};
use crate::*; use crate::*;
use super::{
data_race::{GlobalState as DataRaceState, ThreadClockSet},
range_object_map::{AccessType, RangeObjectMap},
vector_clock::{VClock, VTimestamp, VectorIdx},
};
pub type AllocState = StoreBufferAlloc; pub type AllocState = StoreBufferAlloc;
// Each store buffer must be bounded otherwise it will grow indefinitely. // Each store buffer must be bounded otherwise it will grow indefinitely.

View file

@ -1,25 +1,21 @@
//! Main evaluator loop and setting up the initial stack frame. //! Main evaluator loop and setting up the initial stack frame.
use std::ffi::{OsStr, OsString}; use std::ffi::{OsStr, OsString};
use std::iter;
use std::panic::{self, AssertUnwindSafe}; use std::panic::{self, AssertUnwindSafe};
use std::path::PathBuf; use std::path::PathBuf;
use std::task::Poll; use std::task::Poll;
use std::thread; use std::{iter, thread};
use crate::concurrency::thread::TlsAllocAction;
use crate::diagnostics::report_leaks;
use rustc_data_structures::fx::{FxHashMap, FxHashSet}; use rustc_data_structures::fx::{FxHashMap, FxHashSet};
use rustc_hir::def::Namespace; use rustc_hir::def::Namespace;
use rustc_hir::def_id::DefId; use rustc_hir::def_id::DefId;
use rustc_middle::ty::{ use rustc_middle::ty::layout::{LayoutCx, LayoutOf};
self, Ty, TyCtxt, use rustc_middle::ty::{self, Ty, TyCtxt};
layout::{LayoutCx, LayoutOf}, use rustc_session::config::EntryFnType;
};
use rustc_target::spec::abi::Abi; use rustc_target::spec::abi::Abi;
use rustc_session::config::EntryFnType; use crate::concurrency::thread::TlsAllocAction;
use crate::diagnostics::report_leaks;
use crate::shims::tls; use crate::shims::tls;
use crate::*; use crate::*;

View file

@ -1,29 +1,22 @@
use std::cmp;
use std::collections::BTreeSet; use std::collections::BTreeSet;
use std::iter;
use std::num::NonZero; use std::num::NonZero;
use std::sync::Mutex; use std::sync::Mutex;
use std::time::Duration; use std::time::Duration;
use std::{cmp, iter};
use rand::RngCore; use rand::RngCore;
use rustc_apfloat::Float; use rustc_apfloat::Float;
use rustc_apfloat::ieee::{Double, Half, Quad, Single}; use rustc_apfloat::ieee::{Double, Half, Quad, Single};
use rustc_hir::{ use rustc_hir::Safety;
Safety, use rustc_hir::def::{DefKind, Namespace};
def::{DefKind, Namespace}, use rustc_hir::def_id::{CRATE_DEF_INDEX, CrateNum, DefId, LOCAL_CRATE};
def_id::{CRATE_DEF_INDEX, CrateNum, DefId, LOCAL_CRATE},
};
use rustc_index::IndexVec; use rustc_index::IndexVec;
use rustc_middle::middle::codegen_fn_attrs::CodegenFnAttrFlags; use rustc_middle::middle::codegen_fn_attrs::CodegenFnAttrFlags;
use rustc_middle::middle::dependency_format::Linkage; use rustc_middle::middle::dependency_format::Linkage;
use rustc_middle::middle::exported_symbols::ExportedSymbol; use rustc_middle::middle::exported_symbols::ExportedSymbol;
use rustc_middle::mir; use rustc_middle::mir;
use rustc_middle::ty::layout::{FnAbiOf, MaybeResult}; use rustc_middle::ty::layout::{FnAbiOf, LayoutOf, MaybeResult, TyAndLayout};
use rustc_middle::ty::{ use rustc_middle::ty::{self, FloatTy, IntTy, Ty, TyCtxt, UintTy};
self, FloatTy, IntTy, Ty, TyCtxt, UintTy,
layout::{LayoutOf, TyAndLayout},
};
use rustc_session::config::CrateType; use rustc_session::config::CrateType;
use rustc_span::{Span, Symbol}; use rustc_span::{Span, Symbol};
use rustc_target::abi::{Align, FieldIdx, FieldsShape, Size, Variants}; use rustc_target::abi::{Align, FieldIdx, FieldsShape, Size, Variants};

View file

@ -1,4 +1,5 @@
use rustc_middle::{mir, mir::BinOp, ty}; use rustc_middle::mir::BinOp;
use rustc_middle::{mir, ty};
use self::helpers::check_arg_count; use self::helpers::check_arg_count;
use crate::*; use crate::*;

View file

@ -5,10 +5,8 @@ mod simd;
use rand::Rng; use rand::Rng;
use rustc_apfloat::{Float, Round}; use rustc_apfloat::{Float, Round};
use rustc_middle::{ use rustc_middle::mir;
mir, use rustc_middle::ty::{self, FloatTy};
ty::{self, FloatTy},
};
use rustc_span::{Symbol, sym}; use rustc_span::{Symbol, sym};
use rustc_target::abi::Size; use rustc_target::abi::Size;

View file

@ -1,8 +1,8 @@
use either::Either; use either::Either;
use rustc_apfloat::{Float, Round}; use rustc_apfloat::{Float, Round};
use rustc_middle::ty::FloatTy;
use rustc_middle::ty::layout::{HasParamEnv, LayoutOf}; use rustc_middle::ty::layout::{HasParamEnv, LayoutOf};
use rustc_middle::{mir, ty, ty::FloatTy}; use rustc_middle::{mir, ty};
use rustc_span::{Symbol, sym}; use rustc_span::{Symbol, sym};
use rustc_target::abi::{Endian, HasDataLayout}; use rustc_target::abi::{Endian, HasDataLayout};

View file

@ -92,15 +92,14 @@ mod range_map;
mod shims; mod shims;
// Establish a "crate-wide prelude": we often import `crate::*`. // Establish a "crate-wide prelude": we often import `crate::*`.
use rustc_middle::{bug, span_bug};
use tracing::{info, trace};
// Make all those symbols available in the same place as our own. // Make all those symbols available in the same place as our own.
#[doc(no_inline)] #[doc(no_inline)]
pub use rustc_const_eval::interpret::*; pub use rustc_const_eval::interpret::*;
// Resolve ambiguity. // Resolve ambiguity.
#[doc(no_inline)] #[doc(no_inline)]
pub use rustc_const_eval::interpret::{self, AllocMap, Provenance as _}; pub use rustc_const_eval::interpret::{self, AllocMap, Provenance as _};
use rustc_middle::{bug, span_bug};
use tracing::{info, trace};
// Type aliases that set the provenance parameter. // Type aliases that set the provenance parameter.
pub type Pointer = interpret::Pointer<Option<machine::Provenance>>; pub type Pointer = interpret::Pointer<Option<machine::Provenance>>;
@ -111,15 +110,6 @@ pub type OpTy<'tcx> = interpret::OpTy<'tcx, machine::Provenance>;
pub type PlaceTy<'tcx> = interpret::PlaceTy<'tcx, machine::Provenance>; pub type PlaceTy<'tcx> = interpret::PlaceTy<'tcx, machine::Provenance>;
pub type MPlaceTy<'tcx> = interpret::MPlaceTy<'tcx, machine::Provenance>; pub type MPlaceTy<'tcx> = interpret::MPlaceTy<'tcx, machine::Provenance>;
pub use crate::intrinsics::EvalContextExt as _;
pub use crate::shims::EmulateItemResult;
pub use crate::shims::env::{EnvVars, EvalContextExt as _};
pub use crate::shims::foreign_items::{DynSym, EvalContextExt as _};
pub use crate::shims::os_str::EvalContextExt as _;
pub use crate::shims::panic::{CatchUnwindData, EvalContextExt as _};
pub use crate::shims::time::EvalContextExt as _;
pub use crate::shims::tls::TlsData;
pub use crate::alloc_addresses::{EvalContextExt as _, ProvenanceMode}; pub use crate::alloc_addresses::{EvalContextExt as _, ProvenanceMode};
pub use crate::alloc_bytes::MiriAllocBytes; pub use crate::alloc_bytes::MiriAllocBytes;
pub use crate::borrow_tracker::stacked_borrows::{ pub use crate::borrow_tracker::stacked_borrows::{
@ -128,15 +118,17 @@ pub use crate::borrow_tracker::stacked_borrows::{
pub use crate::borrow_tracker::tree_borrows::{EvalContextExt as _, Tree}; pub use crate::borrow_tracker::tree_borrows::{EvalContextExt as _, Tree};
pub use crate::borrow_tracker::{BorTag, BorrowTrackerMethod, EvalContextExt as _, RetagFields}; pub use crate::borrow_tracker::{BorTag, BorrowTrackerMethod, EvalContextExt as _, RetagFields};
pub use crate::clock::{Clock, Instant}; pub use crate::clock::{Clock, Instant};
pub use crate::concurrency::{ pub use crate::concurrency::cpu_affinity::MAX_CPUS;
cpu_affinity::MAX_CPUS, pub use crate::concurrency::data_race::{
data_race::{AtomicFenceOrd, AtomicReadOrd, AtomicRwOrd, AtomicWriteOrd, EvalContextExt as _}, AtomicFenceOrd, AtomicReadOrd, AtomicRwOrd, AtomicWriteOrd, EvalContextExt as _,
init_once::{EvalContextExt as _, InitOnceId}, };
sync::{CondvarId, EvalContextExt as _, MutexId, RwLockId, SynchronizationObjects}, pub use crate::concurrency::init_once::{EvalContextExt as _, InitOnceId};
thread::{ pub use crate::concurrency::sync::{
BlockReason, EvalContextExt as _, StackEmptyCallback, ThreadId, ThreadManager, CondvarId, EvalContextExt as _, MutexId, RwLockId, SynchronizationObjects,
TimeoutAnchor, TimeoutClock, UnblockCallback, };
}, pub use crate::concurrency::thread::{
BlockReason, EvalContextExt as _, StackEmptyCallback, ThreadId, ThreadManager, TimeoutAnchor,
TimeoutClock, UnblockCallback,
}; };
pub use crate::diagnostics::{ pub use crate::diagnostics::{
EvalContextExt as _, NonHaltingDiagnostic, TerminationInfo, report_error, EvalContextExt as _, NonHaltingDiagnostic, TerminationInfo, report_error,
@ -146,6 +138,7 @@ pub use crate::eval::{
create_ecx, eval_entry, create_ecx, eval_entry,
}; };
pub use crate::helpers::{AccessKind, EvalContextExt as _}; pub use crate::helpers::{AccessKind, EvalContextExt as _};
pub use crate::intrinsics::EvalContextExt as _;
pub use crate::machine::{ pub use crate::machine::{
AllocExtra, FrameExtra, MemoryKind, MiriInterpCx, MiriInterpCxExt, MiriMachine, MiriMemoryKind, AllocExtra, FrameExtra, MemoryKind, MiriInterpCx, MiriInterpCxExt, MiriMachine, MiriMemoryKind,
PrimitiveLayouts, Provenance, ProvenanceExtra, PrimitiveLayouts, Provenance, ProvenanceExtra,
@ -154,6 +147,13 @@ pub use crate::mono_hash_map::MonoHashMap;
pub use crate::operator::EvalContextExt as _; pub use crate::operator::EvalContextExt as _;
pub use crate::provenance_gc::{EvalContextExt as _, LiveAllocs, VisitProvenance, VisitWith}; pub use crate::provenance_gc::{EvalContextExt as _, LiveAllocs, VisitProvenance, VisitWith};
pub use crate::range_map::RangeMap; pub use crate::range_map::RangeMap;
pub use crate::shims::EmulateItemResult;
pub use crate::shims::env::{EnvVars, EvalContextExt as _};
pub use crate::shims::foreign_items::{DynSym, EvalContextExt as _};
pub use crate::shims::os_str::EvalContextExt as _;
pub use crate::shims::panic::{CatchUnwindData, EvalContextExt as _};
pub use crate::shims::time::EvalContextExt as _;
pub use crate::shims::tls::TlsData;
/// Insert rustc arguments at the beginning of the argument list that Miri wants to be /// Insert rustc arguments at the beginning of the argument list that Miri wants to be
/// set per default, for maximal validation power. /// set per default, for maximal validation power.

View file

@ -4,40 +4,29 @@
use std::borrow::Cow; use std::borrow::Cow;
use std::cell::RefCell; use std::cell::RefCell;
use std::collections::hash_map::Entry; use std::collections::hash_map::Entry;
use std::fmt;
use std::path::Path; use std::path::Path;
use std::process; use std::{fmt, process};
use rand::Rng;
use rand::SeedableRng;
use rand::rngs::StdRng; use rand::rngs::StdRng;
use rand::{Rng, SeedableRng};
use rustc_attr::InlineAttr; use rustc_attr::InlineAttr;
use rustc_data_structures::fx::{FxHashMap, FxHashSet}; use rustc_data_structures::fx::{FxHashMap, FxHashSet};
#[allow(unused)] #[allow(unused)]
use rustc_data_structures::static_assert_size; use rustc_data_structures::static_assert_size;
use rustc_middle::{ use rustc_middle::mir;
mir, use rustc_middle::query::TyCtxtAt;
query::TyCtxtAt, use rustc_middle::ty::layout::{HasTyCtxt, LayoutCx, LayoutError, LayoutOf, TyAndLayout};
ty::{ use rustc_middle::ty::{self, Instance, Ty, TyCtxt};
self, Instance, Ty, TyCtxt,
layout::{HasTyCtxt, LayoutCx, LayoutError, LayoutOf, TyAndLayout},
},
};
use rustc_session::config::InliningThreshold; use rustc_session::config::InliningThreshold;
use rustc_span::def_id::{CrateNum, DefId}; use rustc_span::def_id::{CrateNum, DefId};
use rustc_span::{Span, SpanData, Symbol}; use rustc_span::{Span, SpanData, Symbol};
use rustc_target::abi::{Align, Size}; use rustc_target::abi::{Align, Size};
use rustc_target::spec::abi::Abi; use rustc_target::spec::abi::Abi;
use crate::{ use crate::concurrency::cpu_affinity::{self, CpuAffinityMask};
concurrency::{ use crate::concurrency::data_race::{self, NaReadType, NaWriteType};
cpu_affinity::{self, CpuAffinityMask}, use crate::concurrency::weak_memory;
data_race::{self, NaReadType, NaWriteType}, use crate::*;
weak_memory,
},
*,
};
/// First real-time signal. /// First real-time signal.
/// `signal(7)` says this must be between 32 and 64 and specifies 34 or 35 /// `signal(7)` says this must be between 32 and 64 and specifies 34 or 35

View file

@ -1,6 +1,7 @@
use std::iter; use std::iter;
use rand::{Rng, seq::IteratorRandom}; use rand::Rng;
use rand::seq::IteratorRandom;
use rustc_apfloat::{Float, FloatConvert}; use rustc_apfloat::{Float, FloatConvert};
use rustc_middle::mir; use rustc_middle::mir;
use rustc_target::abi::Size; use rustc_target::abi::Size;

View file

@ -1,5 +1,4 @@
use either::Either; use either::Either;
use rustc_data_structures::fx::FxHashSet; use rustc_data_structures::fx::FxHashSet;
use crate::*; use crate::*;

View file

@ -1,9 +1,11 @@
use crate::*;
use rustc_ast::ast::Mutability; use rustc_ast::ast::Mutability;
use rustc_middle::ty::layout::LayoutOf as _; use rustc_middle::ty::layout::LayoutOf as _;
use rustc_middle::ty::{self, Instance, Ty}; use rustc_middle::ty::{self, Instance, Ty};
use rustc_span::{BytePos, Loc, Symbol, hygiene}; use rustc_span::{BytePos, Loc, Symbol, hygiene};
use rustc_target::{abi::Size, spec::abi::Abi}; use rustc_target::abi::Size;
use rustc_target::spec::abi::Abi;
use crate::*;
impl<'tcx> EvalContextExt<'tcx> for crate::MiriInterpCx<'tcx> {} impl<'tcx> EvalContextExt<'tcx> for crate::MiriInterpCx<'tcx> {}
pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> { pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> {

View file

@ -2,7 +2,8 @@ use std::ffi::{OsStr, OsString};
use rustc_data_structures::fx::FxHashMap; use rustc_data_structures::fx::FxHashMap;
use self::shims::{unix::UnixEnvVars, windows::WindowsEnvVars}; use self::shims::unix::UnixEnvVars;
use self::shims::windows::WindowsEnvVars;
use crate::*; use crate::*;
#[derive(Default)] #[derive(Default)]

View file

@ -1,16 +1,17 @@
use std::{collections::hash_map::Entry, io::Write, iter, path::Path}; use std::collections::hash_map::Entry;
use std::io::Write;
use std::iter;
use std::path::Path;
use rustc_apfloat::Float; use rustc_apfloat::Float;
use rustc_ast::expand::allocator::alloc_error_handler_name; use rustc_ast::expand::allocator::alloc_error_handler_name;
use rustc_hir::{def::DefKind, def_id::CrateNum}; use rustc_hir::def::DefKind;
use rustc_hir::def_id::CrateNum;
use rustc_middle::middle::codegen_fn_attrs::CodegenFnAttrFlags; use rustc_middle::middle::codegen_fn_attrs::CodegenFnAttrFlags;
use rustc_middle::mir; use rustc_middle::{mir, ty};
use rustc_middle::ty;
use rustc_span::Symbol; use rustc_span::Symbol;
use rustc_target::{ use rustc_target::abi::{Align, AlignFromBytesError, Size};
abi::{Align, AlignFromBytesError, Size}, use rustc_target::spec::abi::Abi;
spec::abi::Abi,
};
use self::helpers::{ToHost, ToSoft}; use self::helpers::{ToHost, ToSoft};
use super::alloc::EvalContextExt as _; use super::alloc::EvalContextExt as _;

View file

@ -1,7 +1,8 @@
//! Implements calling functions from a native library. //! Implements calling functions from a native library.
use libffi::{high::call as ffi, low::CodePtr};
use std::ops::Deref; use std::ops::Deref;
use libffi::high::call as ffi;
use libffi::low::CodePtr;
use rustc_middle::ty::{self as ty, IntTy, UintTy}; use rustc_middle::ty::{self as ty, IntTy, UintTy};
use rustc_span::Symbol; use rustc_span::Symbol;
use rustc_target::abi::{Abi, HasDataLayout}; use rustc_target::abi::{Abi, HasDataLayout};

View file

@ -1,11 +1,10 @@
use std::borrow::Cow; use std::borrow::Cow;
use std::ffi::{OsStr, OsString}; use std::ffi::{OsStr, OsString};
use std::path::{Path, PathBuf};
#[cfg(unix)] #[cfg(unix)]
use std::os::unix::ffi::{OsStrExt, OsStringExt}; use std::os::unix::ffi::{OsStrExt, OsStringExt};
#[cfg(windows)] #[cfg(windows)]
use std::os::windows::ffi::{OsStrExt, OsStringExt}; use std::os::windows::ffi::{OsStrExt, OsStringExt};
use std::path::{Path, PathBuf};
use rustc_middle::ty::Ty; use rustc_middle::ty::Ty;
use rustc_middle::ty::layout::LayoutOf; use rustc_middle::ty::layout::LayoutOf;

View file

@ -1,7 +1,6 @@
use std::env;
use std::ffi::{OsStr, OsString}; use std::ffi::{OsStr, OsString};
use std::io::ErrorKind; use std::io::ErrorKind;
use std::mem; use std::{env, mem};
use rustc_data_structures::fx::FxHashMap; use rustc_data_structures::fx::FxHashMap;
use rustc_middle::ty::Ty; use rustc_middle::ty::Ty;

View file

@ -5,8 +5,7 @@ use std::any::Any;
use std::collections::BTreeMap; use std::collections::BTreeMap;
use std::io::{self, ErrorKind, IsTerminal, Read, SeekFrom, Write}; use std::io::{self, ErrorKind, IsTerminal, Read, SeekFrom, Write};
use std::ops::Deref; use std::ops::Deref;
use std::rc::Rc; use std::rc::{Rc, Weak};
use std::rc::Weak;
use rustc_target::abi::Size; use rustc_target::abi::Size;

View file

@ -6,16 +6,15 @@ use rustc_span::Symbol;
use rustc_target::abi::Size; use rustc_target::abi::Size;
use rustc_target::spec::abi::Abi; use rustc_target::spec::abi::Abi;
use crate::concurrency::cpu_affinity::CpuAffinityMask;
use crate::shims::alloc::EvalContextExt as _;
use crate::shims::unix::*;
use crate::*;
use self::shims::unix::android::foreign_items as android; use self::shims::unix::android::foreign_items as android;
use self::shims::unix::freebsd::foreign_items as freebsd; use self::shims::unix::freebsd::foreign_items as freebsd;
use self::shims::unix::linux::foreign_items as linux; use self::shims::unix::linux::foreign_items as linux;
use self::shims::unix::macos::foreign_items as macos; use self::shims::unix::macos::foreign_items as macos;
use self::shims::unix::solarish::foreign_items as solarish; use self::shims::unix::solarish::foreign_items as solarish;
use crate::concurrency::cpu_affinity::CpuAffinityMask;
use crate::shims::alloc::EvalContextExt as _;
use crate::shims::unix::*;
use crate::*;
pub fn is_dyn_sym(name: &str, target_os: &str) -> bool { pub fn is_dyn_sym(name: &str, target_os: &str) -> bool {
match name { match name {

View file

@ -11,14 +11,13 @@ use std::time::SystemTime;
use rustc_data_structures::fx::FxHashMap; use rustc_data_structures::fx::FxHashMap;
use rustc_target::abi::Size; use rustc_target::abi::Size;
use self::fd::FlockOp;
use self::shims::time::system_time_to_duration; use self::shims::time::system_time_to_duration;
use crate::shims::os_str::bytes_to_os_str; use crate::shims::os_str::bytes_to_os_str;
use crate::shims::unix::fd::FileDescriptionRef; use crate::shims::unix::fd::FileDescriptionRef;
use crate::shims::unix::*; use crate::shims::unix::*;
use crate::*; use crate::*;
use self::fd::FlockOp;
#[derive(Debug)] #[derive(Debug)]
struct FileHandle { struct FileHandle {
file: File, file: File,
@ -186,12 +185,14 @@ impl FileDescription for FileHandle {
#[cfg(target_family = "windows")] #[cfg(target_family = "windows")]
{ {
use std::os::windows::io::AsRawHandle; use std::os::windows::io::AsRawHandle;
use windows_sys::Win32::{
Foundation::{ERROR_IO_PENDING, ERROR_LOCK_VIOLATION, FALSE, HANDLE, TRUE}, use windows_sys::Win32::Foundation::{
Storage::FileSystem::{ ERROR_IO_PENDING, ERROR_LOCK_VIOLATION, FALSE, HANDLE, TRUE,
LOCKFILE_EXCLUSIVE_LOCK, LOCKFILE_FAIL_IMMEDIATELY, LockFileEx, UnlockFile,
},
}; };
use windows_sys::Win32::Storage::FileSystem::{
LOCKFILE_EXCLUSIVE_LOCK, LOCKFILE_FAIL_IMMEDIATELY, LockFileEx, UnlockFile,
};
let fh = self.file.as_raw_handle() as HANDLE; let fh = self.file.as_raw_handle() as HANDLE;
use FlockOp::*; use FlockOp::*;

View file

@ -3,10 +3,11 @@ use std::cell::{Cell, RefCell};
use std::io; use std::io;
use std::io::{Error, ErrorKind}; use std::io::{Error, ErrorKind};
use crate::concurrency::VClock;
use crate::shims::unix::fd::FileDescriptionRef; use crate::shims::unix::fd::FileDescriptionRef;
use crate::shims::unix::linux::epoll::{EpollReadyEvents, EvalContextExt as _}; use crate::shims::unix::linux::epoll::{EpollReadyEvents, EvalContextExt as _};
use crate::shims::unix::*; use crate::shims::unix::*;
use crate::{concurrency::VClock, *}; use crate::*;
/// Maximum value that the eventfd counter can hold. /// Maximum value that the eventfd counter can hold.
const MAX_COUNTER: u64 = u64::MAX - 1; const MAX_COUNTER: u64 = u64::MAX - 1;

View file

@ -5,8 +5,7 @@ use self::shims::unix::linux::epoll::EvalContextExt as _;
use self::shims::unix::linux::eventfd::EvalContextExt as _; use self::shims::unix::linux::eventfd::EvalContextExt as _;
use self::shims::unix::linux::mem::EvalContextExt as _; use self::shims::unix::linux::mem::EvalContextExt as _;
use self::shims::unix::linux::sync::futex; use self::shims::unix::linux::sync::futex;
use crate::machine::SIGRTMAX; use crate::machine::{SIGRTMAX, SIGRTMIN};
use crate::machine::SIGRTMIN;
use crate::shims::unix::*; use crate::shims::unix::*;
use crate::*; use crate::*;

View file

@ -1,9 +1,10 @@
//! This follows the pattern in src/shims/unix/mem.rs: We only support uses of mremap that would //! This follows the pattern in src/shims/unix/mem.rs: We only support uses of mremap that would
//! correspond to valid uses of realloc. //! correspond to valid uses of realloc.
use crate::*;
use rustc_target::abi::Size; use rustc_target::abi::Size;
use crate::*;
impl<'tcx> EvalContextExt<'tcx> for crate::MiriInterpCx<'tcx> {} impl<'tcx> EvalContextExt<'tcx> for crate::MiriInterpCx<'tcx> {}
pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> { pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> {
fn mremap( fn mremap(

View file

@ -14,9 +14,10 @@
//! munmap shim which would partially unmap a region of address space previously mapped by mmap will //! munmap shim which would partially unmap a region of address space previously mapped by mmap will
//! report UB. //! report UB.
use crate::*;
use rustc_target::abi::Size; use rustc_target::abi::Size;
use crate::*;
impl<'tcx> EvalContextExt<'tcx> for crate::MiriInterpCx<'tcx> {} impl<'tcx> EvalContextExt<'tcx> for crate::MiriInterpCx<'tcx> {}
pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> { pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> {
fn mmap( fn mmap(

View file

@ -14,14 +14,11 @@ mod linux;
mod macos; mod macos;
mod solarish; mod solarish;
pub use self::env::UnixEnvVars;
pub use self::fd::{FdTable, FileDescription};
pub use self::fs::DirTable;
pub use self::linux::epoll::EpollInterestTable;
// All the Unix-specific extension traits // All the Unix-specific extension traits
pub use self::env::EvalContextExt as _; pub use self::env::{EvalContextExt as _, UnixEnvVars};
pub use self::fd::EvalContextExt as _; pub use self::fd::{EvalContextExt as _, FdTable, FileDescription};
pub use self::fs::EvalContextExt as _; pub use self::fs::{DirTable, EvalContextExt as _};
pub use self::linux::epoll::EpollInterestTable;
pub use self::mem::EvalContextExt as _; pub use self::mem::EvalContextExt as _;
pub use self::sync::EvalContextExt as _; pub use self::sync::EvalContextExt as _;
pub use self::thread::EvalContextExt as _; pub use self::thread::EvalContextExt as _;

View file

@ -1,6 +1,7 @@
use crate::*;
use rustc_target::spec::abi::Abi; use rustc_target::spec::abi::Abi;
use crate::*;
impl<'tcx> EvalContextExt<'tcx> for crate::MiriInterpCx<'tcx> {} impl<'tcx> EvalContextExt<'tcx> for crate::MiriInterpCx<'tcx> {}
pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> { pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> {
fn pthread_create( fn pthread_create(

View file

@ -9,10 +9,11 @@ use std::io::{Error, ErrorKind, Read};
use rustc_target::abi::Size; use rustc_target::abi::Size;
use crate::concurrency::VClock;
use crate::shims::unix::fd::{FileDescriptionRef, WeakFileDescriptionRef}; use crate::shims::unix::fd::{FileDescriptionRef, WeakFileDescriptionRef};
use crate::shims::unix::linux::epoll::{EpollReadyEvents, EvalContextExt as _}; use crate::shims::unix::linux::epoll::{EpollReadyEvents, EvalContextExt as _};
use crate::shims::unix::*; use crate::shims::unix::*;
use crate::{concurrency::VClock, *}; use crate::*;
/// The maximum capacity of the socketpair buffer in bytes. /// The maximum capacity of the socketpair buffer in bytes.
/// This number is arbitrary as the value can always /// This number is arbitrary as the value can always

View file

@ -1,8 +1,6 @@
use std::ffi::OsStr; use std::ffi::OsStr;
use std::io;
use std::iter;
use std::path::{self, Path, PathBuf}; use std::path::{self, Path, PathBuf};
use std::str; use std::{io, iter, str};
use rustc_span::Symbol; use rustc_span::Symbol;
use rustc_target::abi::{Align, Size}; use rustc_target::abi::{Align, Size};

View file

@ -1,6 +1,7 @@
use rustc_target::abi::HasDataLayout;
use std::mem::variant_count; use std::mem::variant_count;
use rustc_target::abi::HasDataLayout;
use crate::*; use crate::*;
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)] #[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)]

View file

@ -5,9 +5,8 @@ mod handle;
mod sync; mod sync;
mod thread; mod thread;
pub use self::env::WindowsEnvVars;
// All the Windows-specific extension traits // All the Windows-specific extension traits
pub use self::env::EvalContextExt as _; pub use self::env::{EvalContextExt as _, WindowsEnvVars};
pub use self::handle::EvalContextExt as _; pub use self::handle::EvalContextExt as _;
pub use self::sync::EvalContextExt as _; pub use self::sync::EvalContextExt as _;
pub use self::thread::EvalContextExt as _; pub use self::thread::EvalContextExt as _;

View file

@ -1,4 +1,4 @@
use rustc_apfloat::{ieee::Double, ieee::Single}; use rustc_apfloat::ieee::{Double, Single};
use rustc_middle::mir; use rustc_middle::mir;
use rustc_middle::ty::Ty; use rustc_middle::ty::Ty;
use rustc_middle::ty::layout::LayoutOf as _; use rustc_middle::ty::layout::LayoutOf as _;

View file

@ -1,6 +1,6 @@
use rand::Rng as _; use rand::Rng as _;
use rustc_apfloat::Float;
use rustc_apfloat::{Float, ieee::Single}; use rustc_apfloat::ieee::Single;
use rustc_middle::ty::Ty; use rustc_middle::ty::Ty;
use rustc_middle::ty::layout::LayoutOf as _; use rustc_middle::ty::layout::LayoutOf as _;
use rustc_middle::{mir, ty}; use rustc_middle::{mir, ty};

View file

@ -1,9 +1,10 @@
use byteorder::{BigEndian, ByteOrder};
use std::env; use std::env;
#[cfg(unix)] #[cfg(unix)]
use std::io::{self, BufRead}; use std::io::{self, BufRead};
use std::path::PathBuf; use std::path::PathBuf;
use byteorder::{BigEndian, ByteOrder};
fn main() { fn main() {
// Check env var set by `build.rs`. // Check env var set by `build.rs`.
assert_eq!(env!("MIRITESTVAR"), "testval"); assert_eq!(env!("MIRITESTVAR"), "testval");

View file

@ -1,5 +1,4 @@
use std::env; use std::env;
use std::path::PathBuf; use std::path::PathBuf;
use byteorder::{ByteOrder, LittleEndian}; use byteorder::{ByteOrder, LittleEndian};

View file

@ -2,8 +2,7 @@
// Joining the same thread from multiple threads is undefined behavior. // Joining the same thread from multiple threads is undefined behavior.
use std::thread; use std::{mem, ptr, thread};
use std::{mem, ptr};
extern "C" fn thread_start(_null: *mut libc::c_void) -> *mut libc::c_void { extern "C" fn thread_start(_null: *mut libc::c_void) -> *mut libc::c_void {
// Yield the thread several times so that other threads can join it. // Yield the thread several times so that other threads can join it.

View file

@ -3,10 +3,10 @@
//@compile-flags: -Zmiri-disable-isolation -Zmiri-num-cpus=4 //@compile-flags: -Zmiri-disable-isolation -Zmiri-num-cpus=4
fn main() { fn main() {
use libc::{cpu_set_t, sched_setaffinity};
use std::mem::size_of; use std::mem::size_of;
use libc::{cpu_set_t, sched_setaffinity};
// If pid is zero, then the calling thread is used. // If pid is zero, then the calling thread is used.
const PID: i32 = 0; const PID: i32 = 0;

View file

@ -1,8 +1,7 @@
//@compile-flags: -Zmiri-disable-isolation -Zmiri-preemption-rate=0 //@compile-flags: -Zmiri-disable-isolation -Zmiri-preemption-rate=0
//@ignore-target: windows # No libc env support on Windows //@ignore-target: windows # No libc env support on Windows
use std::env; use std::{env, thread};
use std::thread;
fn main() { fn main() {
let t = thread::spawn(|| unsafe { let t = thread::spawn(|| unsafe {

View file

@ -1,10 +1,8 @@
//@compile-flags: -Zmiri-disable-validation -Zmiri-disable-stacked-borrows //@compile-flags: -Zmiri-disable-validation -Zmiri-disable-stacked-borrows
#![feature(coroutines, coroutine_trait, stmt_expr_attributes)] #![feature(coroutines, coroutine_trait, stmt_expr_attributes)]
use std::{ use std::ops::{Coroutine, CoroutineState};
ops::{Coroutine, CoroutineState}, use std::pin::Pin;
pin::Pin,
};
fn firstn() -> impl Coroutine<Yield = u64, Return = ()> { fn firstn() -> impl Coroutine<Yield = u64, Return = ()> {
#[coroutine] #[coroutine]

View file

@ -3,8 +3,7 @@
// Avoid accidental synchronization via address reuse inside `thread::spawn`. // Avoid accidental synchronization via address reuse inside `thread::spawn`.
//@compile-flags: -Zmiri-address-reuse-cross-thread-rate=0 //@compile-flags: -Zmiri-address-reuse-cross-thread-rate=0
use std::sync::atomic::AtomicUsize; use std::sync::atomic::{AtomicUsize, Ordering};
use std::sync::atomic::Ordering;
use std::thread::spawn; use std::thread::spawn;
#[derive(Copy, Clone)] #[derive(Copy, Clone)]

View file

@ -3,8 +3,7 @@
// Avoid accidental synchronization via address reuse inside `thread::spawn`. // Avoid accidental synchronization via address reuse inside `thread::spawn`.
//@compile-flags: -Zmiri-address-reuse-cross-thread-rate=0 //@compile-flags: -Zmiri-address-reuse-cross-thread-rate=0
use std::sync::atomic::AtomicUsize; use std::sync::atomic::{AtomicUsize, Ordering};
use std::sync::atomic::Ordering;
use std::thread::spawn; use std::thread::spawn;
#[derive(Copy, Clone)] #[derive(Copy, Clone)]

View file

@ -3,8 +3,7 @@
// Avoid accidental synchronization via address reuse inside `thread::spawn`. // Avoid accidental synchronization via address reuse inside `thread::spawn`.
//@compile-flags: -Zmiri-address-reuse-cross-thread-rate=0 //@compile-flags: -Zmiri-address-reuse-cross-thread-rate=0
use std::sync::atomic::AtomicUsize; use std::sync::atomic::{AtomicUsize, Ordering};
use std::sync::atomic::Ordering;
use std::thread::spawn; use std::thread::spawn;
#[derive(Copy, Clone)] #[derive(Copy, Clone)]

View file

@ -8,8 +8,7 @@
#![feature(ptr_internals)] #![feature(ptr_internals)]
use core::ptr::Unique; use core::ptr::{Unique, addr_of_mut};
use core::ptr::addr_of_mut;
fn main() { fn main() {
let mut data = 0u8; let mut data = 0u8;

View file

@ -6,8 +6,7 @@
use std::mem::MaybeUninit; use std::mem::MaybeUninit;
use std::ptr::{self, addr_of}; use std::ptr::{self, addr_of};
use std::sync::atomic::AtomicI32; use std::sync::atomic::{AtomicI32, Ordering};
use std::sync::atomic::Ordering;
use std::thread; use std::thread;
use std::time::{Duration, Instant}; use std::time::{Duration, Instant};

View file

@ -8,8 +8,7 @@
// FIXME(static_mut_refs): Do not allow `static_mut_refs` lint // FIXME(static_mut_refs): Do not allow `static_mut_refs` lint
#![allow(static_mut_refs)] #![allow(static_mut_refs)]
use std::mem; use std::{mem, ptr};
use std::ptr;
pub type Key = libc::pthread_key_t; pub type Key = libc::pthread_key_t;

View file

@ -2,9 +2,10 @@
//@revisions: with_isolation without_isolation //@revisions: with_isolation without_isolation
//@[without_isolation] compile-flags: -Zmiri-disable-isolation //@[without_isolation] compile-flags: -Zmiri-disable-isolation
use libc::{getpid, gettid};
use std::thread; use std::thread;
use libc::{getpid, gettid};
fn main() { fn main() {
thread::spawn(|| { thread::spawn(|| {
// Test that in isolation mode a deterministic value will be returned. // Test that in isolation mode a deterministic value will be returned.

View file

@ -5,9 +5,10 @@
#![feature(pointer_is_aligned_to)] #![feature(pointer_is_aligned_to)]
#![feature(strict_provenance)] #![feature(strict_provenance)]
use libc::{cpu_set_t, sched_getaffinity, sched_setaffinity};
use std::mem::{size_of, size_of_val}; use std::mem::{size_of, size_of_val};
use libc::{cpu_set_t, sched_getaffinity, sched_setaffinity};
// If pid is zero, then the calling thread is used. // If pid is zero, then the calling thread is used.
const PID: i32 = 0; const PID: i32 = 0;

View file

@ -1,7 +1,9 @@
//@ignore-target: windows # File handling is not implemented yet //@ignore-target: windows # File handling is not implemented yet
//@compile-flags: -Zmiri-disable-isolation //@compile-flags: -Zmiri-disable-isolation
use std::{fs::File, io::Error, os::fd::AsRawFd}; use std::fs::File;
use std::io::Error;
use std::os::fd::AsRawFd;
#[path = "../../utils/mod.rs"] #[path = "../../utils/mod.rs"]
mod utils; mod utils;

View file

@ -230,8 +230,7 @@ fn test_posix_mkstemp() {
/// Test allocating variant of `realpath`. /// Test allocating variant of `realpath`.
fn test_posix_realpath_alloc() { fn test_posix_realpath_alloc() {
use std::os::unix::ffi::OsStrExt; use std::os::unix::ffi::{OsStrExt, OsStringExt};
use std::os::unix::ffi::OsStringExt;
let buf; let buf;
let path = utils::tmp().join("miri_test_libc_posix_realpath_alloc"); let path = utils::tmp().join("miri_test_libc_posix_realpath_alloc");

View file

@ -2,6 +2,7 @@
//@only-target: linux # We only support tokio on Linux //@only-target: linux # We only support tokio on Linux
use std::fs::remove_file; use std::fs::remove_file;
use tokio::fs::{File, OpenOptions}; use tokio::fs::{File, OpenOptions};
use tokio::io::{self, AsyncReadExt, AsyncWriteExt}; use tokio::io::{self, AsyncReadExt, AsyncWriteExt};

View file

@ -1,13 +1,11 @@
//@revisions: stack tree //@revisions: stack tree
//@[tree]compile-flags: -Zmiri-tree-borrows //@[tree]compile-flags: -Zmiri-tree-borrows
use std::{ use std::future::Future;
future::Future, use std::mem::MaybeUninit;
mem::MaybeUninit, use std::pin::Pin;
pin::Pin, use std::sync::Arc;
sync::Arc, use std::task::{Context, Poll, Wake};
task::{Context, Poll, Wake},
};
struct ThingAdder<'a> { struct ThingAdder<'a> {
// Using `MaybeUninit` to ensure there are no niches here. // Using `MaybeUninit` to ensure there are no niches here.

View file

@ -1,5 +1,6 @@
//@compile-flags: -Zmiri-compare-exchange-weak-failure-rate=0.0 //@compile-flags: -Zmiri-compare-exchange-weak-failure-rate=0.0
use std::sync::atomic::{AtomicBool, Ordering::*}; use std::sync::atomic::AtomicBool;
use std::sync::atomic::Ordering::*;
// Ensure that compare_exchange_weak never fails. // Ensure that compare_exchange_weak never fails.
fn main() { fn main() {

View file

@ -6,9 +6,8 @@
// FIXME(static_mut_refs): Do not allow `static_mut_refs` lint // FIXME(static_mut_refs): Do not allow `static_mut_refs` lint
#![allow(static_mut_refs)] #![allow(static_mut_refs)]
use std::sync::atomic::{ use std::sync::atomic::Ordering::*;
AtomicBool, AtomicIsize, AtomicPtr, AtomicU64, Ordering::*, compiler_fence, fence, use std::sync::atomic::{AtomicBool, AtomicIsize, AtomicPtr, AtomicU64, compiler_fence, fence};
};
fn main() { fn main() {
atomic_bool(); atomic_bool();

View file

@ -7,13 +7,11 @@
#![feature(allocator_api)] #![feature(allocator_api)]
#![feature(strict_provenance)] #![feature(strict_provenance)]
use std::{ use std::alloc::{AllocError, Allocator, Layout};
alloc::{AllocError, Allocator, Layout}, use std::cell::{Cell, UnsafeCell};
cell::{Cell, UnsafeCell}, use std::mem;
mem, use std::ptr::{self, NonNull, addr_of};
ptr::{self, NonNull, addr_of}, use std::thread::{self, ThreadId};
thread::{self, ThreadId},
};
const BIN_SIZE: usize = 8; const BIN_SIZE: usize = 8;

View file

@ -3,8 +3,7 @@
#![allow(incomplete_features)] // for trait upcasting #![allow(incomplete_features)] // for trait upcasting
#![feature(allocator_api, trait_upcasting)] #![feature(allocator_api, trait_upcasting)]
use std::alloc::Layout; use std::alloc::{AllocError, Allocator, Layout};
use std::alloc::{AllocError, Allocator};
use std::cell::Cell; use std::cell::Cell;
use std::mem::MaybeUninit; use std::mem::MaybeUninit;
use std::ptr::{self, NonNull}; use std::ptr::{self, NonNull};

View file

@ -5,7 +5,8 @@
#![feature(sync_unsafe_cell)] #![feature(sync_unsafe_cell)]
use std::cell::SyncUnsafeCell; use std::cell::SyncUnsafeCell;
use std::sync::atomic::{AtomicUsize, Ordering::Relaxed}; use std::sync::atomic::AtomicUsize;
use std::sync::atomic::Ordering::Relaxed;
use std::thread; use std::thread;
static ADDR: AtomicUsize = AtomicUsize::new(0); static ADDR: AtomicUsize = AtomicUsize::new(0);

View file

@ -1,6 +1,5 @@
use std::hint; use std::hint;
use std::sync::atomic; use std::sync::{Mutex, TryLockError, atomic};
use std::sync::{Mutex, TryLockError};
fn main() { fn main() {
test_mutex_stdlib(); test_mutex_stdlib();

View file

@ -4,10 +4,8 @@
use std::fmt::Debug; use std::fmt::Debug;
use std::mem::ManuallyDrop; use std::mem::ManuallyDrop;
use std::ops::{ use std::ops::Coroutine;
Coroutine, use std::ops::CoroutineState::{self, *};
CoroutineState::{self, *},
};
use std::pin::Pin; use std::pin::Pin;
use std::ptr; use std::ptr;
use std::sync::atomic::{AtomicUsize, Ordering}; use std::sync::atomic::{AtomicUsize, Ordering};

View file

@ -21,7 +21,9 @@ fn pin_box_dyn() {
} }
fn stdlib_pointers() { fn stdlib_pointers() {
use std::{pin::Pin, rc::Rc, sync::Arc}; use std::pin::Pin;
use std::rc::Rc;
use std::sync::Arc;
trait Trait { trait Trait {
fn by_rc(self: Rc<Self>) -> i64; fn by_rc(self: Rc<Self>) -> i64;
@ -60,10 +62,8 @@ fn stdlib_pointers() {
} }
fn pointers_and_wrappers() { fn pointers_and_wrappers() {
use std::{ use std::marker::Unsize;
marker::Unsize, use std::ops::{CoerceUnsized, Deref, DispatchFromDyn};
ops::{CoerceUnsized, Deref, DispatchFromDyn},
};
struct Ptr<T: ?Sized>(Box<T>); struct Ptr<T: ?Sized>(Box<T>);

View file

@ -1,7 +1,5 @@
use std::mem;
use std::num;
use std::ptr;
use std::rc::Rc; use std::rc::Rc;
use std::{mem, num, ptr};
#[derive(Copy, Clone, Default)] #[derive(Copy, Clone, Default)]
struct Zst; struct Zst;

View file

@ -11,7 +11,8 @@
#![allow(incomplete_features, internal_features)] #![allow(incomplete_features, internal_features)]
use std::intrinsics::simd as intrinsics; use std::intrinsics::simd as intrinsics;
use std::ptr; use std::ptr;
use std::simd::{StdFloat, prelude::*}; use std::simd::StdFloat;
use std::simd::prelude::*;
extern "rust-intrinsic" { extern "rust-intrinsic" {
#[rustc_nounwind] #[rustc_nounwind]

View file

@ -2,7 +2,8 @@
// This test is the result of minimizing the `emplacable` crate to reproduce // This test is the result of minimizing the `emplacable` crate to reproduce
// <https://github.com/rust-lang/miri/issues/3541>. // <https://github.com/rust-lang/miri/issues/3541>.
use std::{ops::FnMut, ptr::Pointee}; use std::ops::FnMut;
use std::ptr::Pointee;
pub type EmplacerFn<'a, T> = dyn for<'b> FnMut(<T as Pointee>::Metadata) + 'a; pub type EmplacerFn<'a, T> = dyn for<'b> FnMut(<T as Pointee>::Metadata) + 'a;

View file

@ -1,7 +1,5 @@
use std::{ use std::ptr;
ptr, use std::sync::atomic::{AtomicPtr, Ordering};
sync::atomic::{AtomicPtr, Ordering},
};
static mut LEAKER: Option<Box<Vec<i32>>> = None; static mut LEAKER: Option<Box<Vec<i32>>> = None;

View file

@ -2,8 +2,7 @@
// Tree Borrows doesn't support int2ptr casts, but let's make sure we don't immediately crash either. // Tree Borrows doesn't support int2ptr casts, but let's make sure we don't immediately crash either.
//@[tree]compile-flags: -Zmiri-tree-borrows //@[tree]compile-flags: -Zmiri-tree-borrows
//@[stack]compile-flags: -Zmiri-permissive-provenance //@[stack]compile-flags: -Zmiri-permissive-provenance
use std::mem; use std::{mem, ptr};
use std::ptr;
fn eq_ref<T>(x: &T, y: &T) -> bool { fn eq_ref<T>(x: &T, y: &T) -> bool {
x as *const _ == y as *const _ x as *const _ == y as *const _

View file

@ -1,6 +1,5 @@
//@compile-flags: -Zmiri-preemption-rate=0 //@compile-flags: -Zmiri-preemption-rate=0
use std::env; use std::{env, thread};
use std::thread;
fn main() { fn main() {
// Test that miri environment is isolated when communication is disabled. // Test that miri environment is isolated when communication is disabled.

View file

@ -1,9 +1,8 @@
//@only-target: windows # this directly tests windows-only functions //@only-target: windows # this directly tests windows-only functions
use core::ffi::c_void;
use std::ffi::OsStr; use std::ffi::OsStr;
use std::os::windows::ffi::OsStrExt; use std::os::windows::ffi::OsStrExt;
use core::ffi::c_void;
type HANDLE = *mut c_void; type HANDLE = *mut c_void;
type PWSTR = *mut u16; type PWSTR = *mut u16;
type PCWSTR = *const u16; type PCWSTR = *const u16;

View file

@ -6,8 +6,7 @@
#![feature(layout_for_ptr)] #![feature(layout_for_ptr)]
#![feature(strict_provenance)] #![feature(strict_provenance)]
use std::ptr; use std::{ptr, slice};
use std::slice;
fn slice_of_zst() { fn slice_of_zst() {
fn foo<T>(v: &[T]) -> Option<&[T]> { fn foo<T>(v: &[T]) -> Option<&[T]> {

View file

@ -2,10 +2,8 @@
// this fails when Stacked Borrows is strictly applied even to `!Unpin` types. // this fails when Stacked Borrows is strictly applied even to `!Unpin` types.
#![feature(coroutines, coroutine_trait, stmt_expr_attributes)] #![feature(coroutines, coroutine_trait, stmt_expr_attributes)]
use std::{ use std::ops::{Coroutine, CoroutineState};
ops::{Coroutine, CoroutineState}, use std::pin::Pin;
pin::Pin,
};
fn firstn() -> impl Coroutine<Yield = u64, Return = ()> { fn firstn() -> impl Coroutine<Yield = u64, Return = ()> {
#[coroutine] #[coroutine]

View file

@ -3,10 +3,8 @@
//@compile-flags: -Zmiri-permissive-provenance -Zmiri-provenance-gc=0 //@compile-flags: -Zmiri-permissive-provenance -Zmiri-provenance-gc=0
#![feature(strict_provenance)] #![feature(strict_provenance)]
use std::{ use std::alloc::{self, Layout};
alloc::{self, Layout}, use std::mem::ManuallyDrop;
mem::ManuallyDrop,
};
extern "Rust" { extern "Rust" {
fn miri_get_alloc_id(ptr: *const u8) -> u64; fn miri_get_alloc_id(ptr: *const u8) -> u64;

View file

@ -3,8 +3,7 @@
//@[uniq]compile-flags: -Zmiri-unique-is-unique //@[uniq]compile-flags: -Zmiri-unique-is-unique
#![feature(allocator_api)] #![feature(allocator_api)]
use std::mem; use std::{mem, ptr};
use std::ptr;
fn main() { fn main() {
aliasing_read_only_mutable_refs(); aliasing_read_only_mutable_refs();

View file

@ -1,8 +1,9 @@
use std::env;
use std::ffi::OsString; use std::ffi::OsString;
use std::num::NonZero; use std::num::NonZero;
use std::path::{Path, PathBuf}; use std::path::{Path, PathBuf};
use std::process::Command;
use std::sync::OnceLock; use std::sync::OnceLock;
use std::{env, process::Command};
use colored::*; use colored::*;
use regex::bytes::Regex; use regex::bytes::Regex;