diff --git a/src/tools/miri/bench-cargo-miri/backtraces/src/main.rs b/src/tools/miri/bench-cargo-miri/backtraces/src/main.rs index eba51c60dbc..b1a58712bec 100644 --- a/src/tools/miri/bench-cargo-miri/backtraces/src/main.rs +++ b/src/tools/miri/bench-cargo-miri/backtraces/src/main.rs @@ -1,8 +1,9 @@ //! Extracted from the backtrace crate's test test_frame_conversion -use backtrace::{Backtrace, BacktraceFrame}; use std::fmt::Write; +use backtrace::{Backtrace, BacktraceFrame}; + fn main() { let mut frames = vec![]; backtrace::trace(|frame| { diff --git a/src/tools/miri/bench-cargo-miri/serde2/src/main.rs b/src/tools/miri/bench-cargo-miri/serde2/src/main.rs index 83c04b9dd5f..8842d4ce310 100644 --- a/src/tools/miri/bench-cargo-miri/serde2/src/main.rs +++ b/src/tools/miri/bench-cargo-miri/serde2/src/main.rs @@ -1,9 +1,10 @@ // Like serde1, but in two threads concurrently. And we don't print. static JSON: &str = r#"{"buffer":[-29,-42,-40,-37,-28,-5,-21,1,-24,-8,-20,4,-18,26,-24,44,-26,66,-30,86,-37,88,-41,72,-46,50,-31,28,23,14,64,16,51,26,32,34,39,42,48,35,58,0,72,-36,69,-59,58,-98,54,-124,36,-103,12,-110,5,-173,-19,-146,-59,-4,-42,51,1,-23,-6,-30,-6,45,46,47,70,6,55,19,60,38,62,42,47,61,46,40,42,-19,22,-34,6,-35,-50,-61,-141,-37,-171,17,-163,26,-180,46,-154,80,-63,48,-4,18,20,50,47,58,53,44,61,57,85,37,80,0,86,-8,106,-95,49,-213,-8,-131,47,49,63,40,-39,-69,-74,-37,-20,63,-12,58,-14,-12,25,-31,41,11,45,76,47,167,5,261,-37,277,-83,183,-172,35,-122,-79,138,-70,266,69,124,228,0,391,-29,594,-84,702,-78,627,-8,551,-13,509,13,372,120,352,125,622,127,691,223,362,126,386,-33,915,198,958,457,456,298,500,233,1027,469,1096,426,918,160,1067,141,1220,189,1245,164,1375,297,1378,503,1299,702,1550,929,1799,855,1752,547,1830,602,1928,832,1736,796,1735,933,1961,1385,1935,1562,2105,1485,2716,1449,2948,1305,2768,1205,2716,1346,2531,1450,2470,1653,3117,2111,3370,2176,2696,1947,2925,2305,3846,2658,2425,2184,-877,1981,-2261,2623,-1645,2908,-1876,2732,-2704,2953,-2484,3116,-2120,2954,-2442,3216,-2466,3499,-2192,3234,-2392,3361,-2497,3869,-2078,3772,-1858,3915,-2066,4438,-2285,2934,-2294,-280,-2066,-1762,-1992,-1412,-2298,-1535,-2399,-1789,-2223,-1419,-2244,-1334,-2092,-1476,-1777,-1396,-2014,-1571,-2199,-1574,-1843,-1167,-1910,-1446,-2007,-1818,-1506,-1331,-2526,-2048,-5535,-4573,-7148,-5828,-6422,-5327,-5840,-5488,-5992,-6144,-6014,-6164,-6109,-6234,-6271,-6388,-6288,-6156,-6517,-6249,-6794,-6602,-6822,-6418,-6788,-6245,-6490,-6560,-6394,-6794,-7920,-6937,-10397,-7140,-11428,-6972,-11019,-6610,-11141,-6665,-11913,-7046,-11979,-7235,-11599,-7015,-11854,-6912,-12161,-7441,-12136,-7761,-12861,-7292,-13390,-7254,-12345,-7809,-12490,-7463,-13983,-6969,-10489,-8465,-2382,-11054,1272,-12247,-270,-12060,-323,-12113,502,-12486,-697,-12251,-1086,-12141,-181,-13116,-670,-13509,-1173,-12592,-443,-12811,-449,-13698,-934,-12850,-747,-13083,-873,-15036,-1161,-11478,-1047,-2669,-1407,1006,-1658,-1146,-1195,-1297,-1421,-73,-1946,-977,-1590,-1499,-1577,-1010,-1862,-1256,-1389,-962,-1692,-509,-2613,-1317,-2087,-1359,-1997,-1034,-2891,-2024,-119,-84,5651,5723,8074,8306,7156,6870,6985,7106,7312,8403,7114,8096,7173,7848,7082,7827,6761,7189,6985,7368,7076,7835,6992,7297,7453,7260,7016,7755,6025,7429,8533,7352,14150,7628,17142,7077,16399,6947,15939,7475,16564,7069,16463,6882,16400,7602,17031,7233,16543,6517,15395,7018,15985,7104,16689,6869,15655,7622,16155,7198,17884,6022,14056,8856,5665,14484,1815,16782,3034,15786,3107,15664,2312,16517,2965,16443,3036,16120,2287,16584,2479,16720,2693,16073,2535,16159,2958,16609,3067,16086,2716,16579,3035,17752,3092,13704,2499,5265,2620,1452,2808,3024,2444,3275,2839,2267,3340,2857,2968,3232,3066,2867,3152,3072,2248,2961,2413,2807,3238,3237,2368,2699,2262,2392,3537,3339,827,823,-5020,-5359,-7095,-7857,-5973,-6274,-6208,-6279,-6934,-7181,-6893,-6647,-7146,-6687,-7026,-7328,-6451,-6924,-6763,-6535,-7109,-6639,-6926,-6559,-7188,-6799,-6727,-6955,-5786,-6554,-8543,-6796,-14465,-7190,-17356,-6641,-16372,-6529,-15941,-6898,-16526,-6434,-16219,-6520,-16222,-7449,-17077,-7097,-16665,-6476,-15675,-7026,-16498,-6848,-17147,-6271,-15894,-7069,-16266,-7032,-17817,-5991,-13796,-8594,-5421,-14349,-1649,-17288,-2847,-16525,-2974,-15945,-2324,-16482,-3022,-16593,-3097,-16451,-2420,-16780,-2649,-16641,-2836,-15900,-2660,-16214,-3050,-16827,-3111,-15993,-2741,-16151,-2994,-17537,-2933,-13812,-2314,-5216,-2475,-1125,-2648,-2801,-2290,-3285,-2796,-2243,-3415,-2642,-3109,-3000,-3271,-2839,-3408,-3161,-2497,-2876,-2603,-2570,-3351,-3173,-2416,-2832,-2235,-2408,-3405,-3186,-613,-768,5271,5201,7376,7644,6241,6176,6366,6275,6964,7124,6831,6508,6998,6566,6836,7230,6277,6777,6589,6376,6934,6536,6819,6494,7160,6749,6736,6900,5822,6476,8593,6747,14520,7204,17448,6637,16490,6483,16033,6906,16600,6511,16304,6568,16279,7438,17079,7072,16624,6463,15577,7028,16343,6877,16990,6331,15760,7121,16140,7023,17719,5944,13748,8575,5401,14336,1645,17210,2880,16419,3036,15896,2382,16483,3074,16584,3143,16425,2443,16782,2650,16695,2825,15978,2632,16272,3015,16880,3084,16096,2709,16289,2965,17641,2932,13887,2323,5330,2474,1286,2656,2954,2309,3410,2803,2373,3414,2795,3106,3151,3263,2952,3403,3241,2483,2969,2568,2681,3316,3245,2383,2837,2199,2390,3396,3165,641,706,-5230,-5323,-7307,-7790,-6136,-6317,-6268,-6419,-6884,-7278,-6766,-6666,-6976,-6731,-6853,-7406,-6308,-6958,-6636,-6553,-6978,-6703,-6829,-6647,-7156,-6883,-6737,-7017,-5814,-6581,-8575,-6833,-14490,-7270,-17411,-6699,-16466,-6539,-16016,-6931,-16571,-6504,-16257,-6551,-16202,-7408,-16983,-7021,-16545,-6410,-15512,-6976,-16305,-6803,-17017,-6243,-15820,-7037,-16197,-6923,-17802,-5820,-13840,-8455,-5475,-14227,-1724,-17099,-2923,-16314,-3008,-15801,-2362,-16392,-3088,-16506,-3163,-16356,-2503,-16700,-2717,-16605,-2855,-15904,-2710,-16226,-3108,-16870,-3089,-16101,-2747,-16257,-3087,-17584,-2975,-13868,-2324,-5343,-2548,-1275,-2673,-2917,-2213,-3363,-2694,-2311,-3251,-2744,-2867,-3129,-3034,-2939,-3190,-3234,-2346,-2964,-2639,-2658,-3558,-3241,-2670,-2892,-2453,-2437,-3564,-3175,-771,-779,5105,5171,7308,7655,6265,6204,6397,6288,7024,7172,6903,6586,7002,6627,6777,7308,6190,6889,6537,6465,7011,6613,6985,6631,7393,6934,7073,7072,6112,6615,8751,6859,14672,7282,17448,6652,16146,6448,15565,6899,16151,6547,15860,6591,16048,7446,17065,7064,16661,6368,15774,6857,16524,6677,16825,6071,15577,6900,16119,7040,17490,6118,13495,8696,5432,14446,1678,17366,3036,16488,3624,15834,3012,16382,3575,16465,3685,16301,2815,16708,2982,16679,3356,15952,2934,16049,3290,16352,3964,15605,3612,16222,3647,17764,4272,13865,3977,5384,3592,1580,3794,3243,3627,3670,3622,2758,4007,3130,3835,3294,3964,3065,4468,3408,3933,3234,3789,3118,4634,3643,4211,3174,4155,3176,5512,4400,2792,1730,-3702,-4499,-5940,-6691,-4265,-5094,-4381,-5215,-4918,-5746,-4217,-4871,-4402,-4981,-4479,-5525,-3732,-4968,-4118,-4924,-4300,-5349,-3422,-5021,-3876,-4886,-4087,-4860,-2790,-4254,-5025,-4196,-10898,-4415,-13419,-4007,-12198,-4121,-11995,-4413,-12471,-3808,-11937,-3920,-11792,-4583,-12284,-3776,-12085,-3107,-11421,-3583,-11226,-3081,-11157,-2768,-10580,-3914,-10424,-3197,-11040,-1715,-9822,-5144,-6189,-11154,-4236,-13029,-5134,-11598,-5507,-10949,-4921,-11142,-4999,-11180,-4883,-11184,-4366,-11090,-4548,-10887,-4818,-10708,-4866,-10534,-5253,-10272,-5179,-9894,-4633,-10029,-4773,-10382,-4977,-8674,-4668,-5292,-4651,-3928,-4629,-4465,-4312,-3994,-4459,-3528,-4570,-4400,-4272,-4601,-4482,-4035,-4627,-4334,-4080,-4498,-4045,-3835,-4204,-3526,-3695,-3646,-4045,-4101,-4856,-4628,-3338,-3235,-673,-508,28,147,-453,-639,11,0,8,-2,7,0,7,-3,11,-8,15,-9,17,-6,17,-5,13,-3,7,0,3,0,-2,0,-4,0,-4,-2,-6,0,-14,-2,-17,-4,-8,0,-7,5,-17,7,-18,10,-7,18,-2,25,-3,27,0,31,4,34,4,34,8,36,8,37,2,36,4,34,8,28,3,15,0,11,0,12,-5,8,-4,10,0,23,-4,31,-8,30,-2,30,0,26,-6,22,-6,20,-12,15,-19,10,-10,13,-14,6,-43,-13,-43,-16,-9,-12,-10,-29,-42,-40,-37,-28,-5,-21,1,-24,-8,-20,4,-18,26,-24,44,-26,66,-30,86,-37,88,-41,72,-46,50,-31,28,23,14,64,16,51,26,32,34,39,42,48,35,58,0,72,-36,69,-59,58,-98,54,-124,36,-103,12,-110,5,-173,-19,-146,-59,-4,-42,51,1,-23,-6,-30,-6,45,46,47,70,6,55,19,60,38,62,42,47,61,46,40,42,-19,22,-34,6,-35,-50,-61,-141,-37,-171,17,-163,26,-180,46,-154,80,-63,48,-4,18,20,50,47,58,53,44,61,57,85,37,80,0,86,-8,106,-95,49,-213,-8,-131,47,49,63,40,-39,-69,-74,-37,-20,63,-12,58,-14,-12,25,-31,41,11,45,76,47,167,5,261,-37,277,-83,183,-172,35,-122,-79,138,-70,266,69,124,228,0,391,-29,594,-84,702,-78,627,-8,551,-13,509,13,372,120,352,125,622,127,691,223,362,126,386,-33,915,198,958,457,456,298,500,233,1027,469,1096,426,918,160,1067,141,1220,189,1245,164,1375,297,1378,503,1299,702,1550,929,1799,855,1752,547,1830,602,1928,832,1736,796,1735,933,1961,1385,1935,1562,2105,1485,2716,1449,2948,1305,2768,1205,2716,1346,2531,1450,2470,1653,3117,2111,3370,2176,2696,1947,2925,2305,3846,2658,2425,2184,-877,1981,-2261,2623,-1645,2908,-1876,2732,-2704,2953,-2484,3116,-2120,2954,-2442,3216,-2466,3499,-2192,3234,-2392,3361,-2497,3869,-2078,3772,-1858,3915,-2066,4438,-2285,2934,-2294,-280,-2066,-1762,-1992,-1412,-2298,-1535,-2399,-1789,-2223,-1419,-2244,-1334,-2092,-1476,-1777,-1396,-2014,-1571,-2199,-1574,-1843,-1167,-1910,-1446,-2007,-1818,-1506,-1331,-2526,-2048,-5535,-4573,-7148,-5828,-6422,-5327,-5840,-5488,-5992,-6144,-6014,-6164,-6109,-6234,-6271,-6388,-6288,-6156,-6517,-6249,-6794,-6602,-6822,-6418,-6788,-6245,-6490,-6560,-6394,-6794,-7920,-6937,-10397,-7140,-11428,-6972,-11019,-6610,-11141,-6665,-11913,-7046,-11979,-7235,-11599,-7015,-11854,-6912,-12161,-7441,-12136,-7761,-12861,-7292,-13390,-7254,-12345,-7809,-12490,-7463,-13983,-6969,-10489,-8465,-2382,-11054,1272,-12247,-270,-12060,-323,-12113,502,-12486,-697,-12251,-1086,-12141,-181,-13116,-670,-13509,-1173,-12592,-443,-12811,-449,-13698,-934,-12850,-747,-13083,-873,-15036,-1161,-11478,-1047,-2669,-1407,1006,-1658,-1146,-1195,-1297,-1421,-73,-1946,-977,-1590,-1499,-1577,-1010,-1862,-1256,-1389,-962,-1692,-509,-2613,-1317,-2087,-1359,-1997,-1034,-2891,-2024,-119,-84,5651,5723,8074,8306,7156,6870,6985,7106,7312,8403,7114,8096,7173,7848,7082,7827,6761,7189,6985,7368]}"#; -use serde::Deserialize; use std::thread; +use serde::Deserialize; + #[derive(Deserialize)] #[allow(unused)] struct DeriveStruct { diff --git a/src/tools/miri/cargo-miri/src/phases.rs b/src/tools/miri/cargo-miri/src/phases.rs index e13ecbbe54b..52bc8e1a3b6 100644 --- a/src/tools/miri/cargo-miri/src/phases.rs +++ b/src/tools/miri/cargo-miri/src/phases.rs @@ -8,7 +8,8 @@ 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 diff --git a/src/tools/miri/miri-script/src/args.rs b/src/tools/miri/miri-script/src/args.rs index c1688ca0fb6..55d9de4233d 100644 --- a/src/tools/miri/miri-script/src/args.rs +++ b/src/tools/miri/miri-script/src/args.rs @@ -1,5 +1,4 @@ -use std::env; -use std::iter; +use std::{env, iter}; use anyhow::{Result, bail}; diff --git a/src/tools/miri/miri-script/src/commands.rs b/src/tools/miri/miri-script/src/commands.rs index b0e62d5cda6..36175c8dd2b 100644 --- a/src/tools/miri/miri-script/src/commands.rs +++ b/src/tools/miri/miri-script/src/commands.rs @@ -1,12 +1,9 @@ -use std::env; use std::ffi::{OsStr, OsString}; use std::io::Write; -use std::net; -use std::ops::Not; -use std::ops::Range; +use std::ops::{Not, Range}; use std::path::PathBuf; -use std::process; use std::time::Duration; +use std::{env, net, process}; use anyhow::{Context, Result, anyhow, bail}; use path_macro::path; diff --git a/src/tools/miri/rustfmt.toml b/src/tools/miri/rustfmt.toml index 3f9311d9d1a..49650d8486c 100644 --- a/src/tools/miri/rustfmt.toml +++ b/src/tools/miri/rustfmt.toml @@ -1,5 +1,10 @@ +# This matches rustc style_edition = "2024" use_small_heuristics = "Max" +group_imports = "StdExternalCrate" +imports_granularity = "Module" + +# Miri-specific settings +force_multiline_blocks = true match_arm_blocks = false match_arm_leading_pipes = "Preserve" -force_multiline_blocks = true diff --git a/src/tools/miri/src/alloc_addresses/mod.rs b/src/tools/miri/src/alloc_addresses/mod.rs index c19a962e652..f71edafb4b2 100644 --- a/src/tools/miri/src/alloc_addresses/mod.rs +++ b/src/tools/miri/src/alloc_addresses/mod.rs @@ -7,14 +7,13 @@ use std::cmp::max; use rand::Rng; - use rustc_data_structures::fx::{FxHashMap, FxHashSet}; use rustc_span::Span; use rustc_target::abi::{Align, Size}; -use crate::{concurrency::VClock, *}; - use self::reuse_pool::ReusePool; +use crate::concurrency::VClock; +use crate::*; #[derive(Copy, Clone, Debug, PartialEq, Eq)] pub enum ProvenanceMode { diff --git a/src/tools/miri/src/alloc_addresses/reuse_pool.rs b/src/tools/miri/src/alloc_addresses/reuse_pool.rs index f6c16756344..b5366d5ce92 100644 --- a/src/tools/miri/src/alloc_addresses/reuse_pool.rs +++ b/src/tools/miri/src/alloc_addresses/reuse_pool.rs @@ -1,10 +1,10 @@ //! Manages a pool of addresses that can be reused. use rand::Rng; - 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; diff --git a/src/tools/miri/src/alloc_bytes.rs b/src/tools/miri/src/alloc_bytes.rs index 84225d83b6a..6ada8c66fde 100644 --- a/src/tools/miri/src/alloc_bytes.rs +++ b/src/tools/miri/src/alloc_bytes.rs @@ -1,7 +1,6 @@ -use std::alloc; use std::alloc::Layout; use std::borrow::Cow; -use std::slice; +use std::{alloc, slice}; use rustc_middle::mir::interpret::AllocBytes; use rustc_target::abi::{Align, Size}; diff --git a/src/tools/miri/src/bin/miri.rs b/src/tools/miri/src/bin/miri.rs index 14f43f576d3..8d3ae97e0e9 100644 --- a/src/tools/miri/src/bin/miri.rs +++ b/src/tools/miri/src/bin/miri.rs @@ -28,31 +28,27 @@ use std::path::PathBuf; use std::str::FromStr; -use tracing::debug; - +use miri::{BacktraceStyle, BorrowTrackerMethod, ProvenanceMode, RetagFields, ValidationMode}; use rustc_data_structures::sync::Lrc; use rustc_driver::Compilation; use rustc_hir::def_id::LOCAL_CRATE; use rustc_hir::{self as hir, Node}; use rustc_hir_analysis::check::check_function_signature; use rustc_interface::interface::Config; -use rustc_middle::{ - middle::{ - codegen_fn_attrs::CodegenFnAttrFlags, - exported_symbols::{ExportedSymbol, SymbolExportInfo, SymbolExportKind, SymbolExportLevel}, - }, - query::LocalCrate, - traits::{ObligationCause, ObligationCauseCode}, - ty::{self, Ty, TyCtxt}, - util::Providers, +use rustc_middle::middle::codegen_fn_attrs::CodegenFnAttrFlags; +use rustc_middle::middle::exported_symbols::{ + ExportedSymbol, SymbolExportInfo, SymbolExportKind, SymbolExportLevel, }; +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::search_paths::PathKind; use rustc_session::{CtfeBacktrace, EarlyDiagCtxt}; use rustc_span::def_id::DefId; use rustc_target::spec::abi::Abi; - -use miri::{BacktraceStyle, BorrowTrackerMethod, ProvenanceMode, RetagFields, ValidationMode}; +use tracing::debug; struct MiriCompilerCalls { miri_config: miri::MiriConfig, diff --git a/src/tools/miri/src/borrow_tracker/mod.rs b/src/tools/miri/src/borrow_tracker/mod.rs index 9e205cd0064..89fd8c28af2 100644 --- a/src/tools/miri/src/borrow_tracker/mod.rs +++ b/src/tools/miri/src/borrow_tracker/mod.rs @@ -2,11 +2,10 @@ use std::fmt; use std::num::NonZero; -use smallvec::SmallVec; - use rustc_data_structures::fx::{FxHashMap, FxHashSet}; use rustc_middle::mir::RetagKind; use rustc_target::abi::Size; +use smallvec::SmallVec; use crate::*; pub mod stacked_borrows; diff --git a/src/tools/miri/src/borrow_tracker/stacked_borrows/diagnostics.rs b/src/tools/miri/src/borrow_tracker/stacked_borrows/diagnostics.rs index 12eeaae0eff..146f9902f6f 100644 --- a/src/tools/miri/src/borrow_tracker/stacked_borrows/diagnostics.rs +++ b/src/tools/miri/src/borrow_tracker/stacked_borrows/diagnostics.rs @@ -1,9 +1,9 @@ -use smallvec::SmallVec; use std::fmt; use rustc_data_structures::fx::FxHashSet; use rustc_span::{Span, SpanData}; use rustc_target::abi::Size; +use smallvec::SmallVec; use crate::borrow_tracker::{GlobalStateInner, ProtectorKind}; use crate::*; diff --git a/src/tools/miri/src/borrow_tracker/stacked_borrows/mod.rs b/src/tools/miri/src/borrow_tracker/stacked_borrows/mod.rs index 7eb67730383..b270e484bdb 100644 --- a/src/tools/miri/src/borrow_tracker/stacked_borrows/mod.rs +++ b/src/tools/miri/src/borrow_tracker/stacked_borrows/mod.rs @@ -6,25 +6,24 @@ mod stack; use std::cell::RefCell; -use std::cmp; use std::fmt::Write; -use std::mem; +use std::{cmp, mem}; use rustc_data_structures::fx::FxHashSet; 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 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}; pub use self::item::{Item, Permission}; 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; diff --git a/src/tools/miri/src/borrow_tracker/stacked_borrows/stack.rs b/src/tools/miri/src/borrow_tracker/stacked_borrows/stack.rs index 5c040983142..6b5ef7d59c5 100644 --- a/src/tools/miri/src/borrow_tracker/stacked_borrows/stack.rs +++ b/src/tools/miri/src/borrow_tracker/stacked_borrows/stack.rs @@ -5,10 +5,8 @@ use tracing::trace; use crate::ProvenanceExtra; -use crate::borrow_tracker::{ - AccessKind, BorTag, - stacked_borrows::{Item, Permission}, -}; +use crate::borrow_tracker::stacked_borrows::{Item, Permission}; +use crate::borrow_tracker::{AccessKind, BorTag}; /// 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 diff --git a/src/tools/miri/src/borrow_tracker/tree_borrows/diagnostics.rs b/src/tools/miri/src/borrow_tracker/tree_borrows/diagnostics.rs index 44ea7533b00..af9ec129c69 100644 --- a/src/tools/miri/src/borrow_tracker/tree_borrows/diagnostics.rs +++ b/src/tools/miri/src/borrow_tracker/tree_borrows/diagnostics.rs @@ -5,11 +5,9 @@ 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::tree_borrows::perms::{PermTransition, Permission}; +use crate::borrow_tracker::tree_borrows::tree::LocationState; +use crate::borrow_tracker::tree_borrows::unimap::UniIndex; use crate::*; /// Cause of an access: either a real access or one diff --git a/src/tools/miri/src/borrow_tracker/tree_borrows/mod.rs b/src/tools/miri/src/borrow_tracker/tree_borrows/mod.rs index 2afe02dc2c7..30e940b4439 100644 --- a/src/tools/miri/src/borrow_tracker/tree_borrows/mod.rs +++ b/src/tools/miri/src/borrow_tracker/tree_borrows/mod.rs @@ -1,15 +1,12 @@ -use rustc_middle::{ - mir::{Mutability, RetagKind}, - ty::{self, Ty, layout::HasParamEnv}, -}; +use rustc_middle::mir::{Mutability, RetagKind}; +use rustc_middle::ty::layout::HasParamEnv; +use rustc_middle::ty::{self, Ty}; use rustc_span::def_id::DefId; use rustc_target::abi::{Abi, Size}; +use crate::borrow_tracker::{GlobalState, GlobalStateInner, ProtectorKind}; +use crate::concurrency::data_race::NaReadType; use crate::*; -use crate::{ - borrow_tracker::{GlobalState, GlobalStateInner, ProtectorKind}, - concurrency::data_race::NaReadType, -}; pub mod diagnostics; mod perms; diff --git a/src/tools/miri/src/borrow_tracker/tree_borrows/tree.rs b/src/tools/miri/src/borrow_tracker/tree_borrows/tree.rs index a99c71d96b4..9fe134ed34b 100644 --- a/src/tools/miri/src/borrow_tracker/tree_borrows/tree.rs +++ b/src/tools/miri/src/borrow_tracker/tree_borrows/tree.rs @@ -12,18 +12,17 @@ use std::{fmt, mem}; -use smallvec::SmallVec; - use rustc_data_structures::fx::FxHashSet; use rustc_span::Span; use rustc_target::abi::Size; +use smallvec::SmallVec; -use crate::borrow_tracker::tree_borrows::{ - Permission, - diagnostics::{self, NodeDebugInfo, TbError, TransitionError}, - perms::PermTransition, - unimap::{UniEntry, UniIndex, UniKeyMap, UniValMap}, +use crate::borrow_tracker::tree_borrows::Permission; +use crate::borrow_tracker::tree_borrows::diagnostics::{ + self, NodeDebugInfo, TbError, TransitionError, }; +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::*; diff --git a/src/tools/miri/src/borrow_tracker/tree_borrows/tree/tests.rs b/src/tools/miri/src/borrow_tracker/tree_borrows/tree/tests.rs index 5cd5040f807..5d51a72852c 100644 --- a/src/tools/miri/src/borrow_tracker/tree_borrows/tree/tests.rs +++ b/src/tools/miri/src/borrow_tracker/tree_borrows/tree/tests.rs @@ -1,9 +1,10 @@ //! Tests for the tree #![cfg(test)] +use std::fmt; + use super::*; use crate::borrow_tracker::tree_borrows::exhaustive::{Exhaustive, precondition}; -use std::fmt; impl Exhaustive for LocationState { fn exhaustive() -> Box> { diff --git a/src/tools/miri/src/borrow_tracker/tree_borrows/unimap.rs b/src/tools/miri/src/borrow_tracker/tree_borrows/unimap.rs index cbc25724cb6..7874721c0ac 100644 --- a/src/tools/miri/src/borrow_tracker/tree_borrows/unimap.rs +++ b/src/tools/miri/src/borrow_tracker/tree_borrows/unimap.rs @@ -12,7 +12,8 @@ #![allow(dead_code)] -use std::{hash::Hash, mem}; +use std::hash::Hash; +use std::mem; use rustc_data_structures::fx::FxHashMap; diff --git a/src/tools/miri/src/concurrency/data_race.rs b/src/tools/miri/src/concurrency/data_race.rs index b5b43f589f6..8ee039b6ddc 100644 --- a/src/tools/miri/src/concurrency/data_race.rs +++ b/src/tools/miri/src/concurrency/data_race.rs @@ -40,28 +40,23 @@ //! code some atomic operations may increment the timestamp when not necessary but this has no effect //! on the data-race detection code. -use std::{ - cell::{Cell, Ref, RefCell, RefMut}, - fmt::Debug, - mem, -}; +use std::cell::{Cell, Ref, RefCell, RefMut}; +use std::fmt::Debug; +use std::mem; use rustc_ast::Mutability; -use rustc_data_structures::fx::FxHashMap; -use rustc_data_structures::fx::FxHashSet; +use rustc_data_structures::fx::{FxHashMap, FxHashSet}; 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_target::abi::{Align, HasDataLayout, Size}; +use super::vector_clock::{VClock, VTimestamp, VectorIdx}; +use super::weak_memory::EvalContextExt as _; use crate::diagnostics::RacingOp; use crate::*; -use super::{ - vector_clock::{VClock, VTimestamp, VectorIdx}, - weak_memory::EvalContextExt as _, -}; - pub type AllocState = VClockAlloc; /// Valid atomic read-write orderings, alias of atomic::Ordering (not non-exhaustive). diff --git a/src/tools/miri/src/concurrency/range_object_map.rs b/src/tools/miri/src/concurrency/range_object_map.rs index 859eb4bbb60..d36ed36ac1a 100644 --- a/src/tools/miri/src/concurrency/range_object_map.rs +++ b/src/tools/miri/src/concurrency/range_object_map.rs @@ -2,10 +2,10 @@ //! 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 -use rustc_target::abi::Size; use std::ops::{Index, IndexMut, Range}; use rustc_const_eval::interpret::AllocRange; +use rustc_target::abi::Size; #[derive(Clone, Debug)] struct Elem { diff --git a/src/tools/miri/src/concurrency/sync.rs b/src/tools/miri/src/concurrency/sync.rs index 2b34db047f3..7fe67e5c672 100644 --- a/src/tools/miri/src/concurrency/sync.rs +++ b/src/tools/miri/src/concurrency/sync.rs @@ -1,5 +1,6 @@ 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::time::Duration; diff --git a/src/tools/miri/src/concurrency/thread.rs b/src/tools/miri/src/concurrency/thread.rs index 681e9211246..f6b453efcbe 100644 --- a/src/tools/miri/src/concurrency/thread.rs +++ b/src/tools/miri/src/concurrency/thread.rs @@ -7,7 +7,6 @@ use std::time::{Duration, SystemTime}; use either::Either; - use rustc_const_eval::CTRL_C_RECEIVED; use rustc_data_structures::fx::FxHashMap; use rustc_hir::def_id::DefId; diff --git a/src/tools/miri/src/concurrency/vector_clock.rs b/src/tools/miri/src/concurrency/vector_clock.rs index 901b097c1bd..f9025e06c68 100644 --- a/src/tools/miri/src/concurrency/vector_clock.rs +++ b/src/tools/miri/src/concurrency/vector_clock.rs @@ -1,11 +1,10 @@ +use std::cmp::Ordering; +use std::fmt::Debug; +use std::ops::{Index, Shr}; + use rustc_index::Idx; use rustc_span::{DUMMY_SP, Span, SpanData}; use smallvec::SmallVec; -use std::{ - cmp::Ordering, - fmt::Debug, - ops::{Index, Shr}, -}; use super::data_race::NaReadType; @@ -430,10 +429,12 @@ fn index(&self, index: VectorIdx) -> &VTimestamp { /// test suite #[cfg(test)] mod tests { + use std::cmp::Ordering; + + use rustc_span::DUMMY_SP; + use super::{VClock, VTimestamp, VectorIdx}; use crate::concurrency::data_race::NaReadType; - use rustc_span::DUMMY_SP; - use std::cmp::Ordering; #[test] fn test_equal() { diff --git a/src/tools/miri/src/concurrency/weak_memory.rs b/src/tools/miri/src/concurrency/weak_memory.rs index 0605b744e6a..307695436c6 100644 --- a/src/tools/miri/src/concurrency/weak_memory.rs +++ b/src/tools/miri/src/concurrency/weak_memory.rs @@ -76,21 +76,16 @@ // (https://github.com/ChrisLidbury/tsan11/blob/ecbd6b81e9b9454e01cba78eb9d88684168132c7/lib/tsan/rtl/tsan_relaxed.cc#L295) // and here. -use std::{ - cell::{Ref, RefCell}, - collections::VecDeque, -}; +use std::cell::{Ref, RefCell}; +use std::collections::VecDeque; 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 super::{ - data_race::{GlobalState as DataRaceState, ThreadClockSet}, - range_object_map::{AccessType, RangeObjectMap}, - vector_clock::{VClock, VTimestamp, VectorIdx}, -}; - pub type AllocState = StoreBufferAlloc; // Each store buffer must be bounded otherwise it will grow indefinitely. diff --git a/src/tools/miri/src/eval.rs b/src/tools/miri/src/eval.rs index 8c8ed9c4ddc..3739d46bd60 100644 --- a/src/tools/miri/src/eval.rs +++ b/src/tools/miri/src/eval.rs @@ -1,25 +1,21 @@ //! Main evaluator loop and setting up the initial stack frame. use std::ffi::{OsStr, OsString}; -use std::iter; use std::panic::{self, AssertUnwindSafe}; use std::path::PathBuf; 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_hir::def::Namespace; use rustc_hir::def_id::DefId; -use rustc_middle::ty::{ - self, Ty, TyCtxt, - layout::{LayoutCx, LayoutOf}, -}; +use rustc_middle::ty::layout::{LayoutCx, LayoutOf}; +use rustc_middle::ty::{self, Ty, TyCtxt}; +use rustc_session::config::EntryFnType; 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::*; diff --git a/src/tools/miri/src/helpers.rs b/src/tools/miri/src/helpers.rs index 10e5882b5ba..0cd6ba69aac 100644 --- a/src/tools/miri/src/helpers.rs +++ b/src/tools/miri/src/helpers.rs @@ -1,29 +1,22 @@ -use std::cmp; use std::collections::BTreeSet; -use std::iter; use std::num::NonZero; use std::sync::Mutex; use std::time::Duration; +use std::{cmp, iter}; use rand::RngCore; - use rustc_apfloat::Float; use rustc_apfloat::ieee::{Double, Half, Quad, Single}; -use rustc_hir::{ - Safety, - def::{DefKind, Namespace}, - def_id::{CRATE_DEF_INDEX, CrateNum, DefId, LOCAL_CRATE}, -}; +use rustc_hir::Safety; +use rustc_hir::def::{DefKind, Namespace}; +use rustc_hir::def_id::{CRATE_DEF_INDEX, CrateNum, DefId, LOCAL_CRATE}; use rustc_index::IndexVec; use rustc_middle::middle::codegen_fn_attrs::CodegenFnAttrFlags; use rustc_middle::middle::dependency_format::Linkage; use rustc_middle::middle::exported_symbols::ExportedSymbol; use rustc_middle::mir; -use rustc_middle::ty::layout::{FnAbiOf, MaybeResult}; -use rustc_middle::ty::{ - self, FloatTy, IntTy, Ty, TyCtxt, UintTy, - layout::{LayoutOf, TyAndLayout}, -}; +use rustc_middle::ty::layout::{FnAbiOf, LayoutOf, MaybeResult, TyAndLayout}; +use rustc_middle::ty::{self, FloatTy, IntTy, Ty, TyCtxt, UintTy}; use rustc_session::config::CrateType; use rustc_span::{Span, Symbol}; use rustc_target::abi::{Align, FieldIdx, FieldsShape, Size, Variants}; diff --git a/src/tools/miri/src/intrinsics/atomic.rs b/src/tools/miri/src/intrinsics/atomic.rs index f38c3b82174..b6fd9ba1e82 100644 --- a/src/tools/miri/src/intrinsics/atomic.rs +++ b/src/tools/miri/src/intrinsics/atomic.rs @@ -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 crate::*; diff --git a/src/tools/miri/src/intrinsics/mod.rs b/src/tools/miri/src/intrinsics/mod.rs index d8d267f5ba6..23ce2f8ed1f 100644 --- a/src/tools/miri/src/intrinsics/mod.rs +++ b/src/tools/miri/src/intrinsics/mod.rs @@ -5,10 +5,8 @@ use rand::Rng; use rustc_apfloat::{Float, Round}; -use rustc_middle::{ - mir, - ty::{self, FloatTy}, -}; +use rustc_middle::mir; +use rustc_middle::ty::{self, FloatTy}; use rustc_span::{Symbol, sym}; use rustc_target::abi::Size; diff --git a/src/tools/miri/src/intrinsics/simd.rs b/src/tools/miri/src/intrinsics/simd.rs index 2bc11d63a39..802a70e5a54 100644 --- a/src/tools/miri/src/intrinsics/simd.rs +++ b/src/tools/miri/src/intrinsics/simd.rs @@ -1,8 +1,8 @@ use either::Either; - use rustc_apfloat::{Float, Round}; +use rustc_middle::ty::FloatTy; 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_target::abi::{Endian, HasDataLayout}; diff --git a/src/tools/miri/src/lib.rs b/src/tools/miri/src/lib.rs index 4d0606113f9..78e7bf70455 100644 --- a/src/tools/miri/src/lib.rs +++ b/src/tools/miri/src/lib.rs @@ -92,15 +92,14 @@ mod shims; // 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. #[doc(no_inline)] pub use rustc_const_eval::interpret::*; // Resolve ambiguity. #[doc(no_inline)] 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. pub type Pointer = interpret::Pointer>; @@ -111,15 +110,6 @@ pub type PlaceTy<'tcx> = interpret::PlaceTy<'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_bytes::MiriAllocBytes; pub use crate::borrow_tracker::stacked_borrows::{ @@ -128,15 +118,17 @@ pub use crate::borrow_tracker::tree_borrows::{EvalContextExt as _, Tree}; pub use crate::borrow_tracker::{BorTag, BorrowTrackerMethod, EvalContextExt as _, RetagFields}; pub use crate::clock::{Clock, Instant}; -pub use crate::concurrency::{ - cpu_affinity::MAX_CPUS, - data_race::{AtomicFenceOrd, AtomicReadOrd, AtomicRwOrd, AtomicWriteOrd, EvalContextExt as _}, - init_once::{EvalContextExt as _, InitOnceId}, - sync::{CondvarId, EvalContextExt as _, MutexId, RwLockId, SynchronizationObjects}, - thread::{ - BlockReason, EvalContextExt as _, StackEmptyCallback, ThreadId, ThreadManager, - TimeoutAnchor, TimeoutClock, UnblockCallback, - }, +pub use crate::concurrency::cpu_affinity::MAX_CPUS; +pub use crate::concurrency::data_race::{ + AtomicFenceOrd, AtomicReadOrd, AtomicRwOrd, AtomicWriteOrd, EvalContextExt as _, +}; +pub use crate::concurrency::init_once::{EvalContextExt as _, InitOnceId}; +pub use crate::concurrency::sync::{ + CondvarId, EvalContextExt as _, MutexId, RwLockId, SynchronizationObjects, +}; +pub use crate::concurrency::thread::{ + BlockReason, EvalContextExt as _, StackEmptyCallback, ThreadId, ThreadManager, TimeoutAnchor, + TimeoutClock, UnblockCallback, }; pub use crate::diagnostics::{ EvalContextExt as _, NonHaltingDiagnostic, TerminationInfo, report_error, @@ -146,6 +138,7 @@ create_ecx, eval_entry, }; pub use crate::helpers::{AccessKind, EvalContextExt as _}; +pub use crate::intrinsics::EvalContextExt as _; pub use crate::machine::{ AllocExtra, FrameExtra, MemoryKind, MiriInterpCx, MiriInterpCxExt, MiriMachine, MiriMemoryKind, PrimitiveLayouts, Provenance, ProvenanceExtra, @@ -154,6 +147,13 @@ pub use crate::operator::EvalContextExt as _; pub use crate::provenance_gc::{EvalContextExt as _, LiveAllocs, VisitProvenance, VisitWith}; 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 /// set per default, for maximal validation power. diff --git a/src/tools/miri/src/machine.rs b/src/tools/miri/src/machine.rs index b93feeeee33..fb5ccbcd4fe 100644 --- a/src/tools/miri/src/machine.rs +++ b/src/tools/miri/src/machine.rs @@ -4,40 +4,29 @@ use std::borrow::Cow; use std::cell::RefCell; use std::collections::hash_map::Entry; -use std::fmt; use std::path::Path; -use std::process; +use std::{fmt, process}; -use rand::Rng; -use rand::SeedableRng; use rand::rngs::StdRng; - +use rand::{Rng, SeedableRng}; use rustc_attr::InlineAttr; use rustc_data_structures::fx::{FxHashMap, FxHashSet}; #[allow(unused)] use rustc_data_structures::static_assert_size; -use rustc_middle::{ - mir, - query::TyCtxtAt, - ty::{ - self, Instance, Ty, TyCtxt, - layout::{HasTyCtxt, LayoutCx, LayoutError, LayoutOf, TyAndLayout}, - }, -}; +use rustc_middle::mir; +use rustc_middle::query::TyCtxtAt; +use rustc_middle::ty::layout::{HasTyCtxt, LayoutCx, LayoutError, LayoutOf, TyAndLayout}; +use rustc_middle::ty::{self, Instance, Ty, TyCtxt}; use rustc_session::config::InliningThreshold; use rustc_span::def_id::{CrateNum, DefId}; use rustc_span::{Span, SpanData, Symbol}; use rustc_target::abi::{Align, Size}; use rustc_target::spec::abi::Abi; -use crate::{ - concurrency::{ - cpu_affinity::{self, CpuAffinityMask}, - data_race::{self, NaReadType, NaWriteType}, - weak_memory, - }, - *, -}; +use crate::concurrency::cpu_affinity::{self, CpuAffinityMask}; +use crate::concurrency::data_race::{self, NaReadType, NaWriteType}; +use crate::concurrency::weak_memory; +use crate::*; /// First real-time signal. /// `signal(7)` says this must be between 32 and 64 and specifies 34 or 35 diff --git a/src/tools/miri/src/operator.rs b/src/tools/miri/src/operator.rs index 1b6a7255eef..6b8c0fe87ad 100644 --- a/src/tools/miri/src/operator.rs +++ b/src/tools/miri/src/operator.rs @@ -1,6 +1,7 @@ use std::iter; -use rand::{Rng, seq::IteratorRandom}; +use rand::Rng; +use rand::seq::IteratorRandom; use rustc_apfloat::{Float, FloatConvert}; use rustc_middle::mir; use rustc_target::abi::Size; diff --git a/src/tools/miri/src/provenance_gc.rs b/src/tools/miri/src/provenance_gc.rs index d4bed69c670..c5a35bc14f5 100644 --- a/src/tools/miri/src/provenance_gc.rs +++ b/src/tools/miri/src/provenance_gc.rs @@ -1,5 +1,4 @@ use either::Either; - use rustc_data_structures::fx::FxHashSet; use crate::*; diff --git a/src/tools/miri/src/shims/backtrace.rs b/src/tools/miri/src/shims/backtrace.rs index edff17c0514..1d20189b6fd 100644 --- a/src/tools/miri/src/shims/backtrace.rs +++ b/src/tools/miri/src/shims/backtrace.rs @@ -1,9 +1,11 @@ -use crate::*; use rustc_ast::ast::Mutability; use rustc_middle::ty::layout::LayoutOf as _; use rustc_middle::ty::{self, Instance, Ty}; 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> {} pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> { diff --git a/src/tools/miri/src/shims/env.rs b/src/tools/miri/src/shims/env.rs index c465ef3d28b..557d648682c 100644 --- a/src/tools/miri/src/shims/env.rs +++ b/src/tools/miri/src/shims/env.rs @@ -2,7 +2,8 @@ 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::*; #[derive(Default)] diff --git a/src/tools/miri/src/shims/foreign_items.rs b/src/tools/miri/src/shims/foreign_items.rs index c0484dde59b..6a835098e60 100644 --- a/src/tools/miri/src/shims/foreign_items.rs +++ b/src/tools/miri/src/shims/foreign_items.rs @@ -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_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::mir; -use rustc_middle::ty; +use rustc_middle::{mir, ty}; use rustc_span::Symbol; -use rustc_target::{ - abi::{Align, AlignFromBytesError, Size}, - spec::abi::Abi, -}; +use rustc_target::abi::{Align, AlignFromBytesError, Size}; +use rustc_target::spec::abi::Abi; use self::helpers::{ToHost, ToSoft}; use super::alloc::EvalContextExt as _; diff --git a/src/tools/miri/src/shims/native_lib.rs b/src/tools/miri/src/shims/native_lib.rs index e4998c37f3f..2b5acee244c 100644 --- a/src/tools/miri/src/shims/native_lib.rs +++ b/src/tools/miri/src/shims/native_lib.rs @@ -1,7 +1,8 @@ //! Implements calling functions from a native library. -use libffi::{high::call as ffi, low::CodePtr}; 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_span::Symbol; use rustc_target::abi::{Abi, HasDataLayout}; diff --git a/src/tools/miri/src/shims/os_str.rs b/src/tools/miri/src/shims/os_str.rs index a1be2ae8b58..17c45105920 100644 --- a/src/tools/miri/src/shims/os_str.rs +++ b/src/tools/miri/src/shims/os_str.rs @@ -1,11 +1,10 @@ use std::borrow::Cow; use std::ffi::{OsStr, OsString}; -use std::path::{Path, PathBuf}; - #[cfg(unix)] use std::os::unix::ffi::{OsStrExt, OsStringExt}; #[cfg(windows)] use std::os::windows::ffi::{OsStrExt, OsStringExt}; +use std::path::{Path, PathBuf}; use rustc_middle::ty::Ty; use rustc_middle::ty::layout::LayoutOf; diff --git a/src/tools/miri/src/shims/unix/env.rs b/src/tools/miri/src/shims/unix/env.rs index 324607cc1ed..184a6c238b3 100644 --- a/src/tools/miri/src/shims/unix/env.rs +++ b/src/tools/miri/src/shims/unix/env.rs @@ -1,7 +1,6 @@ -use std::env; use std::ffi::{OsStr, OsString}; use std::io::ErrorKind; -use std::mem; +use std::{env, mem}; use rustc_data_structures::fx::FxHashMap; use rustc_middle::ty::Ty; diff --git a/src/tools/miri/src/shims/unix/fd.rs b/src/tools/miri/src/shims/unix/fd.rs index 5fae746af2b..6bd753d0d6b 100644 --- a/src/tools/miri/src/shims/unix/fd.rs +++ b/src/tools/miri/src/shims/unix/fd.rs @@ -5,8 +5,7 @@ use std::collections::BTreeMap; use std::io::{self, ErrorKind, IsTerminal, Read, SeekFrom, Write}; use std::ops::Deref; -use std::rc::Rc; -use std::rc::Weak; +use std::rc::{Rc, Weak}; use rustc_target::abi::Size; diff --git a/src/tools/miri/src/shims/unix/foreign_items.rs b/src/tools/miri/src/shims/unix/foreign_items.rs index 470f13442f9..528d068ea92 100644 --- a/src/tools/miri/src/shims/unix/foreign_items.rs +++ b/src/tools/miri/src/shims/unix/foreign_items.rs @@ -6,16 +6,15 @@ use rustc_target::abi::Size; 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::freebsd::foreign_items as freebsd; use self::shims::unix::linux::foreign_items as linux; use self::shims::unix::macos::foreign_items as macos; 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 { match name { diff --git a/src/tools/miri/src/shims/unix/fs.rs b/src/tools/miri/src/shims/unix/fs.rs index 1b657db5ccc..92514b67bea 100644 --- a/src/tools/miri/src/shims/unix/fs.rs +++ b/src/tools/miri/src/shims/unix/fs.rs @@ -11,14 +11,13 @@ use rustc_data_structures::fx::FxHashMap; use rustc_target::abi::Size; +use self::fd::FlockOp; use self::shims::time::system_time_to_duration; use crate::shims::os_str::bytes_to_os_str; use crate::shims::unix::fd::FileDescriptionRef; use crate::shims::unix::*; use crate::*; -use self::fd::FlockOp; - #[derive(Debug)] struct FileHandle { file: File, @@ -186,12 +185,14 @@ fn flock<'tcx>( #[cfg(target_family = "windows")] { use std::os::windows::io::AsRawHandle; - use windows_sys::Win32::{ - Foundation::{ERROR_IO_PENDING, ERROR_LOCK_VIOLATION, FALSE, HANDLE, TRUE}, - Storage::FileSystem::{ - LOCKFILE_EXCLUSIVE_LOCK, LOCKFILE_FAIL_IMMEDIATELY, LockFileEx, UnlockFile, - }, + + use windows_sys::Win32::Foundation::{ + ERROR_IO_PENDING, ERROR_LOCK_VIOLATION, FALSE, HANDLE, TRUE, }; + use windows_sys::Win32::Storage::FileSystem::{ + LOCKFILE_EXCLUSIVE_LOCK, LOCKFILE_FAIL_IMMEDIATELY, LockFileEx, UnlockFile, + }; + let fh = self.file.as_raw_handle() as HANDLE; use FlockOp::*; diff --git a/src/tools/miri/src/shims/unix/linux/eventfd.rs b/src/tools/miri/src/shims/unix/linux/eventfd.rs index 9fbabbd9641..ab7652ca721 100644 --- a/src/tools/miri/src/shims/unix/linux/eventfd.rs +++ b/src/tools/miri/src/shims/unix/linux/eventfd.rs @@ -3,10 +3,11 @@ use std::io; use std::io::{Error, ErrorKind}; +use crate::concurrency::VClock; use crate::shims::unix::fd::FileDescriptionRef; use crate::shims::unix::linux::epoll::{EpollReadyEvents, EvalContextExt as _}; use crate::shims::unix::*; -use crate::{concurrency::VClock, *}; +use crate::*; /// Maximum value that the eventfd counter can hold. const MAX_COUNTER: u64 = u64::MAX - 1; diff --git a/src/tools/miri/src/shims/unix/linux/foreign_items.rs b/src/tools/miri/src/shims/unix/linux/foreign_items.rs index 07527a9d6e3..e2e76aad7cd 100644 --- a/src/tools/miri/src/shims/unix/linux/foreign_items.rs +++ b/src/tools/miri/src/shims/unix/linux/foreign_items.rs @@ -5,8 +5,7 @@ use self::shims::unix::linux::eventfd::EvalContextExt as _; use self::shims::unix::linux::mem::EvalContextExt as _; use self::shims::unix::linux::sync::futex; -use crate::machine::SIGRTMAX; -use crate::machine::SIGRTMIN; +use crate::machine::{SIGRTMAX, SIGRTMIN}; use crate::shims::unix::*; use crate::*; diff --git a/src/tools/miri/src/shims/unix/linux/mem.rs b/src/tools/miri/src/shims/unix/linux/mem.rs index 3b32612e8ba..b11f60048a0 100644 --- a/src/tools/miri/src/shims/unix/linux/mem.rs +++ b/src/tools/miri/src/shims/unix/linux/mem.rs @@ -1,9 +1,10 @@ //! This follows the pattern in src/shims/unix/mem.rs: We only support uses of mremap that would //! correspond to valid uses of realloc. -use crate::*; use rustc_target::abi::Size; +use crate::*; + impl<'tcx> EvalContextExt<'tcx> for crate::MiriInterpCx<'tcx> {} pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> { fn mremap( diff --git a/src/tools/miri/src/shims/unix/mem.rs b/src/tools/miri/src/shims/unix/mem.rs index 33ed0e26982..0397ba3b91a 100644 --- a/src/tools/miri/src/shims/unix/mem.rs +++ b/src/tools/miri/src/shims/unix/mem.rs @@ -14,9 +14,10 @@ //! munmap shim which would partially unmap a region of address space previously mapped by mmap will //! report UB. -use crate::*; use rustc_target::abi::Size; +use crate::*; + impl<'tcx> EvalContextExt<'tcx> for crate::MiriInterpCx<'tcx> {} pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> { fn mmap( diff --git a/src/tools/miri/src/shims/unix/mod.rs b/src/tools/miri/src/shims/unix/mod.rs index a95b4d3d307..9bc310e8d0a 100644 --- a/src/tools/miri/src/shims/unix/mod.rs +++ b/src/tools/miri/src/shims/unix/mod.rs @@ -14,14 +14,11 @@ mod macos; 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 -pub use self::env::EvalContextExt as _; -pub use self::fd::EvalContextExt as _; -pub use self::fs::EvalContextExt as _; +pub use self::env::{EvalContextExt as _, UnixEnvVars}; +pub use self::fd::{EvalContextExt as _, FdTable, FileDescription}; +pub use self::fs::{DirTable, EvalContextExt as _}; +pub use self::linux::epoll::EpollInterestTable; pub use self::mem::EvalContextExt as _; pub use self::sync::EvalContextExt as _; pub use self::thread::EvalContextExt as _; diff --git a/src/tools/miri/src/shims/unix/thread.rs b/src/tools/miri/src/shims/unix/thread.rs index 56e8270aa62..96af4ae51ef 100644 --- a/src/tools/miri/src/shims/unix/thread.rs +++ b/src/tools/miri/src/shims/unix/thread.rs @@ -1,6 +1,7 @@ -use crate::*; use rustc_target::spec::abi::Abi; +use crate::*; + impl<'tcx> EvalContextExt<'tcx> for crate::MiriInterpCx<'tcx> {} pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> { fn pthread_create( diff --git a/src/tools/miri/src/shims/unix/unnamed_socket.rs b/src/tools/miri/src/shims/unix/unnamed_socket.rs index db6872319ea..d1bfa563387 100644 --- a/src/tools/miri/src/shims/unix/unnamed_socket.rs +++ b/src/tools/miri/src/shims/unix/unnamed_socket.rs @@ -9,10 +9,11 @@ use rustc_target::abi::Size; +use crate::concurrency::VClock; use crate::shims::unix::fd::{FileDescriptionRef, WeakFileDescriptionRef}; use crate::shims::unix::linux::epoll::{EpollReadyEvents, EvalContextExt as _}; use crate::shims::unix::*; -use crate::{concurrency::VClock, *}; +use crate::*; /// The maximum capacity of the socketpair buffer in bytes. /// This number is arbitrary as the value can always diff --git a/src/tools/miri/src/shims/windows/foreign_items.rs b/src/tools/miri/src/shims/windows/foreign_items.rs index cd8f3e59015..22634c509be 100644 --- a/src/tools/miri/src/shims/windows/foreign_items.rs +++ b/src/tools/miri/src/shims/windows/foreign_items.rs @@ -1,8 +1,6 @@ use std::ffi::OsStr; -use std::io; -use std::iter; use std::path::{self, Path, PathBuf}; -use std::str; +use std::{io, iter, str}; use rustc_span::Symbol; use rustc_target::abi::{Align, Size}; diff --git a/src/tools/miri/src/shims/windows/handle.rs b/src/tools/miri/src/shims/windows/handle.rs index ec461a4cd36..0a8e0e8fdfb 100644 --- a/src/tools/miri/src/shims/windows/handle.rs +++ b/src/tools/miri/src/shims/windows/handle.rs @@ -1,6 +1,7 @@ -use rustc_target::abi::HasDataLayout; use std::mem::variant_count; +use rustc_target::abi::HasDataLayout; + use crate::*; #[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)] diff --git a/src/tools/miri/src/shims/windows/mod.rs b/src/tools/miri/src/shims/windows/mod.rs index 537c724e526..892bd6924fc 100644 --- a/src/tools/miri/src/shims/windows/mod.rs +++ b/src/tools/miri/src/shims/windows/mod.rs @@ -5,9 +5,8 @@ mod sync; mod thread; -pub use self::env::WindowsEnvVars; // 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::sync::EvalContextExt as _; pub use self::thread::EvalContextExt as _; diff --git a/src/tools/miri/src/shims/x86/avx.rs b/src/tools/miri/src/shims/x86/avx.rs index bdc4fc94469..169f8f8111a 100644 --- a/src/tools/miri/src/shims/x86/avx.rs +++ b/src/tools/miri/src/shims/x86/avx.rs @@ -1,4 +1,4 @@ -use rustc_apfloat::{ieee::Double, ieee::Single}; +use rustc_apfloat::ieee::{Double, Single}; use rustc_middle::mir; use rustc_middle::ty::Ty; use rustc_middle::ty::layout::LayoutOf as _; diff --git a/src/tools/miri/src/shims/x86/mod.rs b/src/tools/miri/src/shims/x86/mod.rs index 211bd168af2..8132de7d646 100644 --- a/src/tools/miri/src/shims/x86/mod.rs +++ b/src/tools/miri/src/shims/x86/mod.rs @@ -1,6 +1,6 @@ use rand::Rng as _; - -use rustc_apfloat::{Float, ieee::Single}; +use rustc_apfloat::Float; +use rustc_apfloat::ieee::Single; use rustc_middle::ty::Ty; use rustc_middle::ty::layout::LayoutOf as _; use rustc_middle::{mir, ty}; diff --git a/src/tools/miri/test-cargo-miri/src/main.rs b/src/tools/miri/test-cargo-miri/src/main.rs index d171ec1c0d1..efe95bf3aba 100644 --- a/src/tools/miri/test-cargo-miri/src/main.rs +++ b/src/tools/miri/test-cargo-miri/src/main.rs @@ -1,9 +1,10 @@ -use byteorder::{BigEndian, ByteOrder}; use std::env; #[cfg(unix)] use std::io::{self, BufRead}; use std::path::PathBuf; +use byteorder::{BigEndian, ByteOrder}; + fn main() { // Check env var set by `build.rs`. assert_eq!(env!("MIRITESTVAR"), "testval"); diff --git a/src/tools/miri/test-cargo-miri/subcrate/test.rs b/src/tools/miri/test-cargo-miri/subcrate/test.rs index b60cf20339b..e663643f20b 100644 --- a/src/tools/miri/test-cargo-miri/subcrate/test.rs +++ b/src/tools/miri/test-cargo-miri/subcrate/test.rs @@ -1,5 +1,4 @@ use std::env; - use std::path::PathBuf; use byteorder::{ByteOrder, LittleEndian}; diff --git a/src/tools/miri/tests/fail-dep/concurrency/libc_pthread_join_multiple.rs b/src/tools/miri/tests/fail-dep/concurrency/libc_pthread_join_multiple.rs index 6a49625d75d..b2a398e0a19 100644 --- a/src/tools/miri/tests/fail-dep/concurrency/libc_pthread_join_multiple.rs +++ b/src/tools/miri/tests/fail-dep/concurrency/libc_pthread_join_multiple.rs @@ -2,8 +2,7 @@ // Joining the same thread from multiple threads is undefined behavior. -use std::thread; -use std::{mem, ptr}; +use std::{mem, ptr, thread}; 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. diff --git a/src/tools/miri/tests/fail-dep/libc/affinity.rs b/src/tools/miri/tests/fail-dep/libc/affinity.rs index d7d5c59e1bc..09f096e46f1 100644 --- a/src/tools/miri/tests/fail-dep/libc/affinity.rs +++ b/src/tools/miri/tests/fail-dep/libc/affinity.rs @@ -3,10 +3,10 @@ //@compile-flags: -Zmiri-disable-isolation -Zmiri-num-cpus=4 fn main() { - use libc::{cpu_set_t, sched_setaffinity}; - use std::mem::size_of; + use libc::{cpu_set_t, sched_setaffinity}; + // If pid is zero, then the calling thread is used. const PID: i32 = 0; diff --git a/src/tools/miri/tests/fail-dep/libc/env-set_var-data-race.rs b/src/tools/miri/tests/fail-dep/libc/env-set_var-data-race.rs index c7d8bacd379..3a832bb0ce0 100644 --- a/src/tools/miri/tests/fail-dep/libc/env-set_var-data-race.rs +++ b/src/tools/miri/tests/fail-dep/libc/env-set_var-data-race.rs @@ -1,8 +1,7 @@ //@compile-flags: -Zmiri-disable-isolation -Zmiri-preemption-rate=0 //@ignore-target: windows # No libc env support on Windows -use std::env; -use std::thread; +use std::{env, thread}; fn main() { let t = thread::spawn(|| unsafe { diff --git a/src/tools/miri/tests/fail/coroutine-pinned-moved.rs b/src/tools/miri/tests/fail/coroutine-pinned-moved.rs index 46ec58810a6..abed638e443 100644 --- a/src/tools/miri/tests/fail/coroutine-pinned-moved.rs +++ b/src/tools/miri/tests/fail/coroutine-pinned-moved.rs @@ -1,10 +1,8 @@ //@compile-flags: -Zmiri-disable-validation -Zmiri-disable-stacked-borrows #![feature(coroutines, coroutine_trait, stmt_expr_attributes)] -use std::{ - ops::{Coroutine, CoroutineState}, - pin::Pin, -}; +use std::ops::{Coroutine, CoroutineState}; +use std::pin::Pin; fn firstn() -> impl Coroutine { #[coroutine] diff --git a/src/tools/miri/tests/fail/data_race/atomic_read_na_write_race2.rs b/src/tools/miri/tests/fail/data_race/atomic_read_na_write_race2.rs index 8bceba9380a..c67ce65eb34 100644 --- a/src/tools/miri/tests/fail/data_race/atomic_read_na_write_race2.rs +++ b/src/tools/miri/tests/fail/data_race/atomic_read_na_write_race2.rs @@ -3,8 +3,7 @@ // Avoid accidental synchronization via address reuse inside `thread::spawn`. //@compile-flags: -Zmiri-address-reuse-cross-thread-rate=0 -use std::sync::atomic::AtomicUsize; -use std::sync::atomic::Ordering; +use std::sync::atomic::{AtomicUsize, Ordering}; use std::thread::spawn; #[derive(Copy, Clone)] diff --git a/src/tools/miri/tests/fail/data_race/atomic_write_na_read_race1.rs b/src/tools/miri/tests/fail/data_race/atomic_write_na_read_race1.rs index 1a2746a26f4..5e328740e85 100644 --- a/src/tools/miri/tests/fail/data_race/atomic_write_na_read_race1.rs +++ b/src/tools/miri/tests/fail/data_race/atomic_write_na_read_race1.rs @@ -3,8 +3,7 @@ // Avoid accidental synchronization via address reuse inside `thread::spawn`. //@compile-flags: -Zmiri-address-reuse-cross-thread-rate=0 -use std::sync::atomic::AtomicUsize; -use std::sync::atomic::Ordering; +use std::sync::atomic::{AtomicUsize, Ordering}; use std::thread::spawn; #[derive(Copy, Clone)] diff --git a/src/tools/miri/tests/fail/data_race/atomic_write_na_write_race2.rs b/src/tools/miri/tests/fail/data_race/atomic_write_na_write_race2.rs index b494bd3a003..fdc0f9e20f0 100644 --- a/src/tools/miri/tests/fail/data_race/atomic_write_na_write_race2.rs +++ b/src/tools/miri/tests/fail/data_race/atomic_write_na_write_race2.rs @@ -3,8 +3,7 @@ // Avoid accidental synchronization via address reuse inside `thread::spawn`. //@compile-flags: -Zmiri-address-reuse-cross-thread-rate=0 -use std::sync::atomic::AtomicUsize; -use std::sync::atomic::Ordering; +use std::sync::atomic::{AtomicUsize, Ordering}; use std::thread::spawn; #[derive(Copy, Clone)] diff --git a/src/tools/miri/tests/fail/tree_borrows/children-can-alias.rs b/src/tools/miri/tests/fail/tree_borrows/children-can-alias.rs index 036267dc11e..d3f272dfbf8 100644 --- a/src/tools/miri/tests/fail/tree_borrows/children-can-alias.rs +++ b/src/tools/miri/tests/fail/tree_borrows/children-can-alias.rs @@ -8,8 +8,7 @@ #![feature(ptr_internals)] -use core::ptr::Unique; -use core::ptr::addr_of_mut; +use core::ptr::{Unique, addr_of_mut}; fn main() { let mut data = 0u8; diff --git a/src/tools/miri/tests/pass-dep/concurrency/linux-futex.rs b/src/tools/miri/tests/pass-dep/concurrency/linux-futex.rs index 255a93226a9..20e642a0a29 100644 --- a/src/tools/miri/tests/pass-dep/concurrency/linux-futex.rs +++ b/src/tools/miri/tests/pass-dep/concurrency/linux-futex.rs @@ -6,8 +6,7 @@ use std::mem::MaybeUninit; use std::ptr::{self, addr_of}; -use std::sync::atomic::AtomicI32; -use std::sync::atomic::Ordering; +use std::sync::atomic::{AtomicI32, Ordering}; use std::thread; use std::time::{Duration, Instant}; diff --git a/src/tools/miri/tests/pass-dep/concurrency/tls_pthread_drop_order.rs b/src/tools/miri/tests/pass-dep/concurrency/tls_pthread_drop_order.rs index 2dc09709b8e..b5738600040 100644 --- a/src/tools/miri/tests/pass-dep/concurrency/tls_pthread_drop_order.rs +++ b/src/tools/miri/tests/pass-dep/concurrency/tls_pthread_drop_order.rs @@ -8,8 +8,7 @@ // FIXME(static_mut_refs): Do not allow `static_mut_refs` lint #![allow(static_mut_refs)] -use std::mem; -use std::ptr; +use std::{mem, ptr}; pub type Key = libc::pthread_key_t; diff --git a/src/tools/miri/tests/pass-dep/libc/gettid.rs b/src/tools/miri/tests/pass-dep/libc/gettid.rs index ca352e0109a..51f1a5ed708 100644 --- a/src/tools/miri/tests/pass-dep/libc/gettid.rs +++ b/src/tools/miri/tests/pass-dep/libc/gettid.rs @@ -2,9 +2,10 @@ //@revisions: with_isolation without_isolation //@[without_isolation] compile-flags: -Zmiri-disable-isolation -use libc::{getpid, gettid}; use std::thread; +use libc::{getpid, gettid}; + fn main() { thread::spawn(|| { // Test that in isolation mode a deterministic value will be returned. diff --git a/src/tools/miri/tests/pass-dep/libc/libc-affinity.rs b/src/tools/miri/tests/pass-dep/libc/libc-affinity.rs index ff152eaea5c..8aa8c7dcb8e 100644 --- a/src/tools/miri/tests/pass-dep/libc/libc-affinity.rs +++ b/src/tools/miri/tests/pass-dep/libc/libc-affinity.rs @@ -5,9 +5,10 @@ #![feature(pointer_is_aligned_to)] #![feature(strict_provenance)] -use libc::{cpu_set_t, sched_getaffinity, sched_setaffinity}; 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. const PID: i32 = 0; diff --git a/src/tools/miri/tests/pass-dep/libc/libc-fs-flock.rs b/src/tools/miri/tests/pass-dep/libc/libc-fs-flock.rs index be11f65a1e0..99d6d2b38f8 100644 --- a/src/tools/miri/tests/pass-dep/libc/libc-fs-flock.rs +++ b/src/tools/miri/tests/pass-dep/libc/libc-fs-flock.rs @@ -1,7 +1,9 @@ //@ignore-target: windows # File handling is not implemented yet //@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"] mod utils; diff --git a/src/tools/miri/tests/pass-dep/libc/libc-fs.rs b/src/tools/miri/tests/pass-dep/libc/libc-fs.rs index 17e6e507c27..f85abe2cc43 100644 --- a/src/tools/miri/tests/pass-dep/libc/libc-fs.rs +++ b/src/tools/miri/tests/pass-dep/libc/libc-fs.rs @@ -230,8 +230,7 @@ fn test_posix_mkstemp() { /// Test allocating variant of `realpath`. fn test_posix_realpath_alloc() { - use std::os::unix::ffi::OsStrExt; - use std::os::unix::ffi::OsStringExt; + use std::os::unix::ffi::{OsStrExt, OsStringExt}; let buf; let path = utils::tmp().join("miri_test_libc_posix_realpath_alloc"); diff --git a/src/tools/miri/tests/pass-dep/tokio/file-io.rs b/src/tools/miri/tests/pass-dep/tokio/file-io.rs index 14c27285a6a..6e88b907f5d 100644 --- a/src/tools/miri/tests/pass-dep/tokio/file-io.rs +++ b/src/tools/miri/tests/pass-dep/tokio/file-io.rs @@ -2,6 +2,7 @@ //@only-target: linux # We only support tokio on Linux use std::fs::remove_file; + use tokio::fs::{File, OpenOptions}; use tokio::io::{self, AsyncReadExt, AsyncWriteExt}; diff --git a/src/tools/miri/tests/pass/async-niche-aliasing.rs b/src/tools/miri/tests/pass/async-niche-aliasing.rs index ab82c929a94..fe4ddd9d800 100644 --- a/src/tools/miri/tests/pass/async-niche-aliasing.rs +++ b/src/tools/miri/tests/pass/async-niche-aliasing.rs @@ -1,13 +1,11 @@ //@revisions: stack tree //@[tree]compile-flags: -Zmiri-tree-borrows -use std::{ - future::Future, - mem::MaybeUninit, - pin::Pin, - sync::Arc, - task::{Context, Poll, Wake}, -}; +use std::future::Future; +use std::mem::MaybeUninit; +use std::pin::Pin; +use std::sync::Arc; +use std::task::{Context, Poll, Wake}; struct ThingAdder<'a> { // Using `MaybeUninit` to ensure there are no niches here. diff --git a/src/tools/miri/tests/pass/atomic-compare-exchange-weak-never-fail.rs b/src/tools/miri/tests/pass/atomic-compare-exchange-weak-never-fail.rs index 8d3d71869f4..0a236377a9c 100644 --- a/src/tools/miri/tests/pass/atomic-compare-exchange-weak-never-fail.rs +++ b/src/tools/miri/tests/pass/atomic-compare-exchange-weak-never-fail.rs @@ -1,5 +1,6 @@ //@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. fn main() { diff --git a/src/tools/miri/tests/pass/atomic.rs b/src/tools/miri/tests/pass/atomic.rs index 781cc9bd309..f84fe825d01 100644 --- a/src/tools/miri/tests/pass/atomic.rs +++ b/src/tools/miri/tests/pass/atomic.rs @@ -6,9 +6,8 @@ // FIXME(static_mut_refs): Do not allow `static_mut_refs` lint #![allow(static_mut_refs)] -use std::sync::atomic::{ - AtomicBool, AtomicIsize, AtomicPtr, AtomicU64, Ordering::*, compiler_fence, fence, -}; +use std::sync::atomic::Ordering::*; +use std::sync::atomic::{AtomicBool, AtomicIsize, AtomicPtr, AtomicU64, compiler_fence, fence}; fn main() { atomic_bool(); diff --git a/src/tools/miri/tests/pass/box-custom-alloc-aliasing.rs b/src/tools/miri/tests/pass/box-custom-alloc-aliasing.rs index a1371242f60..0a61db960c1 100644 --- a/src/tools/miri/tests/pass/box-custom-alloc-aliasing.rs +++ b/src/tools/miri/tests/pass/box-custom-alloc-aliasing.rs @@ -7,13 +7,11 @@ #![feature(allocator_api)] #![feature(strict_provenance)] -use std::{ - alloc::{AllocError, Allocator, Layout}, - cell::{Cell, UnsafeCell}, - mem, - ptr::{self, NonNull, addr_of}, - thread::{self, ThreadId}, -}; +use std::alloc::{AllocError, Allocator, Layout}; +use std::cell::{Cell, UnsafeCell}; +use std::mem; +use std::ptr::{self, NonNull, addr_of}; +use std::thread::{self, ThreadId}; const BIN_SIZE: usize = 8; diff --git a/src/tools/miri/tests/pass/box-custom-alloc.rs b/src/tools/miri/tests/pass/box-custom-alloc.rs index 8d6da0733fe..71ce019187c 100644 --- a/src/tools/miri/tests/pass/box-custom-alloc.rs +++ b/src/tools/miri/tests/pass/box-custom-alloc.rs @@ -3,8 +3,7 @@ #![allow(incomplete_features)] // for trait upcasting #![feature(allocator_api, trait_upcasting)] -use std::alloc::Layout; -use std::alloc::{AllocError, Allocator}; +use std::alloc::{AllocError, Allocator, Layout}; use std::cell::Cell; use std::mem::MaybeUninit; use std::ptr::{self, NonNull}; diff --git a/src/tools/miri/tests/pass/concurrency/address_reuse_happens_before.rs b/src/tools/miri/tests/pass/concurrency/address_reuse_happens_before.rs index cfc1ef7ae45..255f4061abc 100644 --- a/src/tools/miri/tests/pass/concurrency/address_reuse_happens_before.rs +++ b/src/tools/miri/tests/pass/concurrency/address_reuse_happens_before.rs @@ -5,7 +5,8 @@ #![feature(sync_unsafe_cell)] 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; static ADDR: AtomicUsize = AtomicUsize::new(0); diff --git a/src/tools/miri/tests/pass/concurrency/sync_singlethread.rs b/src/tools/miri/tests/pass/concurrency/sync_singlethread.rs index 5663e1c1426..e52dbd3186e 100644 --- a/src/tools/miri/tests/pass/concurrency/sync_singlethread.rs +++ b/src/tools/miri/tests/pass/concurrency/sync_singlethread.rs @@ -1,6 +1,5 @@ use std::hint; -use std::sync::atomic; -use std::sync::{Mutex, TryLockError}; +use std::sync::{Mutex, TryLockError, atomic}; fn main() { test_mutex_stdlib(); diff --git a/src/tools/miri/tests/pass/coroutine.rs b/src/tools/miri/tests/pass/coroutine.rs index 7822c136d91..9ec9b1fc5bc 100644 --- a/src/tools/miri/tests/pass/coroutine.rs +++ b/src/tools/miri/tests/pass/coroutine.rs @@ -4,10 +4,8 @@ use std::fmt::Debug; use std::mem::ManuallyDrop; -use std::ops::{ - Coroutine, - CoroutineState::{self, *}, -}; +use std::ops::Coroutine; +use std::ops::CoroutineState::{self, *}; use std::pin::Pin; use std::ptr; use std::sync::atomic::{AtomicUsize, Ordering}; diff --git a/src/tools/miri/tests/pass/dyn-arbitrary-self.rs b/src/tools/miri/tests/pass/dyn-arbitrary-self.rs index dc2b9e4491b..d993e5ad68c 100644 --- a/src/tools/miri/tests/pass/dyn-arbitrary-self.rs +++ b/src/tools/miri/tests/pass/dyn-arbitrary-self.rs @@ -21,7 +21,9 @@ fn bar(self: Pin<&mut Self>) -> bool { } 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 { fn by_rc(self: Rc) -> i64; @@ -60,10 +62,8 @@ fn by_pin_box(self: Pin>) -> i64 { } fn pointers_and_wrappers() { - use std::{ - marker::Unsize, - ops::{CoerceUnsized, Deref, DispatchFromDyn}, - }; + use std::marker::Unsize; + use std::ops::{CoerceUnsized, Deref, DispatchFromDyn}; struct Ptr(Box); diff --git a/src/tools/miri/tests/pass/function_calls/abi_compat.rs b/src/tools/miri/tests/pass/function_calls/abi_compat.rs index 0cfcd532ff4..b5feac8c677 100644 --- a/src/tools/miri/tests/pass/function_calls/abi_compat.rs +++ b/src/tools/miri/tests/pass/function_calls/abi_compat.rs @@ -1,7 +1,5 @@ -use std::mem; -use std::num; -use std::ptr; use std::rc::Rc; +use std::{mem, num, ptr}; #[derive(Copy, Clone, Default)] struct Zst; diff --git a/src/tools/miri/tests/pass/intrinsics/portable-simd.rs b/src/tools/miri/tests/pass/intrinsics/portable-simd.rs index cd606a5282a..f560669dd63 100644 --- a/src/tools/miri/tests/pass/intrinsics/portable-simd.rs +++ b/src/tools/miri/tests/pass/intrinsics/portable-simd.rs @@ -11,7 +11,8 @@ #![allow(incomplete_features, internal_features)] use std::intrinsics::simd as intrinsics; use std::ptr; -use std::simd::{StdFloat, prelude::*}; +use std::simd::StdFloat; +use std::simd::prelude::*; extern "rust-intrinsic" { #[rustc_nounwind] diff --git a/src/tools/miri/tests/pass/issues/issue-miri-3541-dyn-vtable-trait-normalization.rs b/src/tools/miri/tests/pass/issues/issue-miri-3541-dyn-vtable-trait-normalization.rs index c46031de2d8..123fe6ed642 100644 --- a/src/tools/miri/tests/pass/issues/issue-miri-3541-dyn-vtable-trait-normalization.rs +++ b/src/tools/miri/tests/pass/issues/issue-miri-3541-dyn-vtable-trait-normalization.rs @@ -2,7 +2,8 @@ // This test is the result of minimizing the `emplacable` crate to reproduce // . -use std::{ops::FnMut, ptr::Pointee}; +use std::ops::FnMut; +use std::ptr::Pointee; pub type EmplacerFn<'a, T> = dyn for<'b> FnMut(::Metadata) + 'a; diff --git a/src/tools/miri/tests/pass/leak-in-static.rs b/src/tools/miri/tests/pass/leak-in-static.rs index 95233944088..6f08b64ada4 100644 --- a/src/tools/miri/tests/pass/leak-in-static.rs +++ b/src/tools/miri/tests/pass/leak-in-static.rs @@ -1,7 +1,5 @@ -use std::{ - ptr, - sync::atomic::{AtomicPtr, Ordering}, -}; +use std::ptr; +use std::sync::atomic::{AtomicPtr, Ordering}; static mut LEAKER: Option>> = None; diff --git a/src/tools/miri/tests/pass/ptr_int_casts.rs b/src/tools/miri/tests/pass/ptr_int_casts.rs index 684e8f6ec7b..4e274f62981 100644 --- a/src/tools/miri/tests/pass/ptr_int_casts.rs +++ b/src/tools/miri/tests/pass/ptr_int_casts.rs @@ -2,8 +2,7 @@ // Tree Borrows doesn't support int2ptr casts, but let's make sure we don't immediately crash either. //@[tree]compile-flags: -Zmiri-tree-borrows //@[stack]compile-flags: -Zmiri-permissive-provenance -use std::mem; -use std::ptr; +use std::{mem, ptr}; fn eq_ref(x: &T, y: &T) -> bool { x as *const _ == y as *const _ diff --git a/src/tools/miri/tests/pass/shims/env/var.rs b/src/tools/miri/tests/pass/shims/env/var.rs index a576c1fc8bb..655b29674e3 100644 --- a/src/tools/miri/tests/pass/shims/env/var.rs +++ b/src/tools/miri/tests/pass/shims/env/var.rs @@ -1,6 +1,5 @@ //@compile-flags: -Zmiri-preemption-rate=0 -use std::env; -use std::thread; +use std::{env, thread}; fn main() { // Test that miri environment is isolated when communication is disabled. diff --git a/src/tools/miri/tests/pass/shims/windows-threadname.rs b/src/tools/miri/tests/pass/shims/windows-threadname.rs index 29c3fa5d5f3..f1c05fa3790 100644 --- a/src/tools/miri/tests/pass/shims/windows-threadname.rs +++ b/src/tools/miri/tests/pass/shims/windows-threadname.rs @@ -1,9 +1,8 @@ //@only-target: windows # this directly tests windows-only functions +use core::ffi::c_void; use std::ffi::OsStr; use std::os::windows::ffi::OsStrExt; - -use core::ffi::c_void; type HANDLE = *mut c_void; type PWSTR = *mut u16; type PCWSTR = *const u16; diff --git a/src/tools/miri/tests/pass/slices.rs b/src/tools/miri/tests/pass/slices.rs index 459d04d6761..39e1d1cb97f 100644 --- a/src/tools/miri/tests/pass/slices.rs +++ b/src/tools/miri/tests/pass/slices.rs @@ -6,8 +6,7 @@ #![feature(layout_for_ptr)] #![feature(strict_provenance)] -use std::ptr; -use std::slice; +use std::{ptr, slice}; fn slice_of_zst() { fn foo(v: &[T]) -> Option<&[T]> { diff --git a/src/tools/miri/tests/pass/stacked-borrows/coroutine-self-referential.rs b/src/tools/miri/tests/pass/stacked-borrows/coroutine-self-referential.rs index 259fc72d392..72e360fe19a 100644 --- a/src/tools/miri/tests/pass/stacked-borrows/coroutine-self-referential.rs +++ b/src/tools/miri/tests/pass/stacked-borrows/coroutine-self-referential.rs @@ -2,10 +2,8 @@ // this fails when Stacked Borrows is strictly applied even to `!Unpin` types. #![feature(coroutines, coroutine_trait, stmt_expr_attributes)] -use std::{ - ops::{Coroutine, CoroutineState}, - pin::Pin, -}; +use std::ops::{Coroutine, CoroutineState}; +use std::pin::Pin; fn firstn() -> impl Coroutine { #[coroutine] diff --git a/src/tools/miri/tests/pass/stacked-borrows/stack-printing.rs b/src/tools/miri/tests/pass/stacked-borrows/stack-printing.rs index 9c9db4d1b3b..1478b21d6c1 100644 --- a/src/tools/miri/tests/pass/stacked-borrows/stack-printing.rs +++ b/src/tools/miri/tests/pass/stacked-borrows/stack-printing.rs @@ -3,10 +3,8 @@ //@compile-flags: -Zmiri-permissive-provenance -Zmiri-provenance-gc=0 #![feature(strict_provenance)] -use std::{ - alloc::{self, Layout}, - mem::ManuallyDrop, -}; +use std::alloc::{self, Layout}; +use std::mem::ManuallyDrop; extern "Rust" { fn miri_get_alloc_id(ptr: *const u8) -> u64; diff --git a/src/tools/miri/tests/pass/tree_borrows/tree-borrows.rs b/src/tools/miri/tests/pass/tree_borrows/tree-borrows.rs index c741e4de6d5..b9d5ca06ed0 100644 --- a/src/tools/miri/tests/pass/tree_borrows/tree-borrows.rs +++ b/src/tools/miri/tests/pass/tree_borrows/tree-borrows.rs @@ -3,8 +3,7 @@ //@[uniq]compile-flags: -Zmiri-unique-is-unique #![feature(allocator_api)] -use std::mem; -use std::ptr; +use std::{mem, ptr}; fn main() { aliasing_read_only_mutable_refs(); diff --git a/src/tools/miri/tests/ui.rs b/src/tools/miri/tests/ui.rs index 2430140eea1..9553a37c9a8 100644 --- a/src/tools/miri/tests/ui.rs +++ b/src/tools/miri/tests/ui.rs @@ -1,8 +1,9 @@ +use std::env; use std::ffi::OsString; use std::num::NonZero; use std::path::{Path, PathBuf}; +use std::process::Command; use std::sync::OnceLock; -use std::{env, process::Command}; use colored::*; use regex::bytes::Regex;