From 0332581327dc23fdc08a37fecaaa4a062b65ad4d Mon Sep 17 00:00:00 2001 From: Ralf Jung Date: Mon, 23 Sep 2024 11:47:09 +0200 Subject: [PATCH 01/26] add test for new abort_unwind function --- .../miri/tests/fail/panic/abort_unwind.rs | 11 +++++++ .../miri/tests/fail/panic/abort_unwind.stderr | 33 +++++++++++++++++++ 2 files changed, 44 insertions(+) create mode 100644 src/tools/miri/tests/fail/panic/abort_unwind.rs create mode 100644 src/tools/miri/tests/fail/panic/abort_unwind.stderr diff --git a/src/tools/miri/tests/fail/panic/abort_unwind.rs b/src/tools/miri/tests/fail/panic/abort_unwind.rs new file mode 100644 index 0000000000000..e313d9c11dec3 --- /dev/null +++ b/src/tools/miri/tests/fail/panic/abort_unwind.rs @@ -0,0 +1,11 @@ +//@error-in-other-file: the program aborted execution +//@normalize-stderr-test: "unsafe \{ libc::abort\(\) \}|crate::intrinsics::abort\(\);" -> "ABORT();" +//@normalize-stderr-test: "\| +\^+" -> "| ^" +//@normalize-stderr-test: "\n +[0-9]+:[^\n]+" -> "" +//@normalize-stderr-test: "\n +at [^\n]+" -> "" + +#![feature(abort_unwind)] + +fn main() { + std::panic::abort_unwind(|| panic!("PANIC!!!")); +} diff --git a/src/tools/miri/tests/fail/panic/abort_unwind.stderr b/src/tools/miri/tests/fail/panic/abort_unwind.stderr new file mode 100644 index 0000000000000..e9c5413693e44 --- /dev/null +++ b/src/tools/miri/tests/fail/panic/abort_unwind.stderr @@ -0,0 +1,33 @@ +thread 'main' panicked at tests/fail/panic/abort_unwind.rs:LL:CC: +PANIC!!! +note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace +note: in Miri, you may have to set `MIRIFLAGS=-Zmiri-env-forward=RUST_BACKTRACE` for the environment variable to have an effect +thread 'main' panicked at RUSTLIB/core/src/panicking.rs:LL:CC: +panic in a function that cannot unwind +stack backtrace: +thread caused non-unwinding panic. aborting. +error: abnormal termination: the program aborted execution + --> RUSTLIB/std/src/sys/pal/PLATFORM/mod.rs:LL:CC + | +LL | ABORT(); + | ^ the program aborted execution + | + = note: BACKTRACE: + = note: inside `std::sys::pal::PLATFORM::abort_internal` at RUSTLIB/std/src/sys/pal/PLATFORM/mod.rs:LL:CC + = note: inside `std::panicking::rust_panic_with_hook` at RUSTLIB/std/src/panicking.rs:LL:CC + = note: inside closure at RUSTLIB/std/src/panicking.rs:LL:CC + = note: inside `std::sys::backtrace::__rust_end_short_backtrace::<{closure@std::panicking::begin_panic_handler::{closure#0}}, !>` at RUSTLIB/std/src/sys/backtrace.rs:LL:CC + = note: inside `std::panicking::begin_panic_handler` at RUSTLIB/std/src/panicking.rs:LL:CC + = note: inside `core::panicking::panic_nounwind` at RUSTLIB/core/src/panicking.rs:LL:CC + = note: inside `core::panicking::panic_cannot_unwind` at RUSTLIB/core/src/panicking.rs:LL:CC + = note: inside `std::panic::abort_unwind::<{closure@tests/fail/panic/abort_unwind.rs:LL:CC}, ()>` at RUSTLIB/core/src/panic.rs:LL:CC +note: inside `main` + --> tests/fail/panic/abort_unwind.rs:LL:CC + | +LL | std::panic::abort_unwind(|| panic!("PANIC!!!")); + | ^ + +note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace + +error: aborting due to 1 previous error + From 51d90bbc8d6c2e4bbaaf4f9b1ef1c7b928826e51 Mon Sep 17 00:00:00 2001 From: Ralf Jung Date: Mon, 23 Sep 2024 12:56:17 +0200 Subject: [PATCH 02/26] fix workflow permissions --- src/tools/miri/.github/workflows/ci.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/tools/miri/.github/workflows/ci.yml b/src/tools/miri/.github/workflows/ci.yml index b9441236bcd3e..6e4815c0b9140 100644 --- a/src/tools/miri/.github/workflows/ci.yml +++ b/src/tools/miri/.github/workflows/ci.yml @@ -13,7 +13,8 @@ on: - cron: '44 4 * * *' # At 4:44 UTC every day. permissions: - contents: write + contents: read + pull-requests: write defaults: run: From 3a108a75f70211c8d6c677de79fa293a4e790aa7 Mon Sep 17 00:00:00 2001 From: Ralf Jung Date: Tue, 24 Sep 2024 08:53:10 +0200 Subject: [PATCH 03/26] looks like we need more permissions --- src/tools/miri/.github/workflows/ci.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/tools/miri/.github/workflows/ci.yml b/src/tools/miri/.github/workflows/ci.yml index 6e4815c0b9140..7d8c7203b320b 100644 --- a/src/tools/miri/.github/workflows/ci.yml +++ b/src/tools/miri/.github/workflows/ci.yml @@ -13,7 +13,9 @@ on: - cron: '44 4 * * *' # At 4:44 UTC every day. permissions: - contents: read + # The cronjob needs to be able to push to the repo... + contents: write + # ... and create a PR. pull-requests: write defaults: From 8885ae9b253bc44e0a35359855381a2248361e06 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jakub=20Ber=C3=A1nek?= Date: Tue, 24 Sep 2024 09:21:41 +0200 Subject: [PATCH 04/26] Scope CI permissions to the job that needs it --- src/tools/miri/.github/workflows/ci.yml | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/src/tools/miri/.github/workflows/ci.yml b/src/tools/miri/.github/workflows/ci.yml index 7d8c7203b320b..8b0916f511117 100644 --- a/src/tools/miri/.github/workflows/ci.yml +++ b/src/tools/miri/.github/workflows/ci.yml @@ -12,12 +12,6 @@ on: schedule: - cron: '44 4 * * *' # At 4:44 UTC every day. -permissions: - # The cronjob needs to be able to push to the repo... - contents: write - # ... and create a PR. - pull-requests: write - defaults: run: shell: bash @@ -93,6 +87,11 @@ jobs: cron-fail-notify: name: cronjob failure notification runs-on: ubuntu-latest + permissions: + # The cronjob needs to be able to push to the repo... + contents: write + # ... and create a PR. + pull-requests: write needs: [build, style] if: github.event_name == 'schedule' && failure() steps: From f319ce73d7e657c11e39e74ac6db5035ca371a88 Mon Sep 17 00:00:00 2001 From: The Miri Cronjob Bot Date: Wed, 25 Sep 2024 05:06:18 +0000 Subject: [PATCH 05/26] Preparing for merge from rustc --- src/tools/miri/rust-version | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/tools/miri/rust-version b/src/tools/miri/rust-version index 76fe17316ac65..79ed6cc7d74b8 100644 --- a/src/tools/miri/rust-version +++ b/src/tools/miri/rust-version @@ -1 +1 @@ -6ce376774c0bc46ac8be247bca93ff5a1287a8fc +1b5aa96d6016bafe50e071b45d4d2e3c90fd766f From e057c1777685e6e80924b7dea3bed3098a8d1cf9 Mon Sep 17 00:00:00 2001 From: The Miri Cronjob Bot Date: Wed, 25 Sep 2024 05:15:00 +0000 Subject: [PATCH 06/26] fmt --- src/tools/miri/src/intrinsics/atomic.rs | 2 +- src/tools/miri/src/intrinsics/mod.rs | 2 +- src/tools/miri/src/shims/env.rs | 2 +- src/tools/miri/src/shims/foreign_items.rs | 2 +- src/tools/miri/src/shims/panic.rs | 2 +- src/tools/miri/src/shims/unix/fs.rs | 2 +- src/tools/miri/src/shims/unix/linux/foreign_items.rs | 8 ++++---- src/tools/miri/src/shims/unix/macos/foreign_items.rs | 3 ++- src/tools/miri/src/shims/windows/env.rs | 2 +- src/tools/miri/src/shims/windows/foreign_items.rs | 2 +- src/tools/miri/src/shims/windows/thread.rs | 2 +- src/tools/miri/src/shims/x86/mod.rs | 2 +- .../tests/fail/validity/wrong-dyn-trait-assoc-type.rs | 4 +++- 13 files changed, 19 insertions(+), 16 deletions(-) diff --git a/src/tools/miri/src/intrinsics/atomic.rs b/src/tools/miri/src/intrinsics/atomic.rs index 6365e0efd5129..f38c3b821742a 100644 --- a/src/tools/miri/src/intrinsics/atomic.rs +++ b/src/tools/miri/src/intrinsics/atomic.rs @@ -1,7 +1,7 @@ use rustc_middle::{mir, mir::BinOp, ty}; -use crate::*; use self::helpers::check_arg_count; +use crate::*; pub enum AtomicOp { /// The `bool` indicates whether the result of the operation should be negated (`UnOp::Not`, diff --git a/src/tools/miri/src/intrinsics/mod.rs b/src/tools/miri/src/intrinsics/mod.rs index b8352b575a4ac..d8d267f5ba693 100644 --- a/src/tools/miri/src/intrinsics/mod.rs +++ b/src/tools/miri/src/intrinsics/mod.rs @@ -12,10 +12,10 @@ use rustc_middle::{ use rustc_span::{Symbol, sym}; use rustc_target::abi::Size; -use crate::*; use self::atomic::EvalContextExt as _; use self::helpers::{ToHost, ToSoft, check_arg_count}; use self::simd::EvalContextExt as _; +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 279df042dea97..d12a0581b4137 100644 --- a/src/tools/miri/src/shims/env.rs +++ b/src/tools/miri/src/shims/env.rs @@ -2,8 +2,8 @@ use std::ffi::{OsStr, OsString}; use rustc_data_structures::fx::FxHashMap; -use crate::*; use self::shims::{unix::UnixEnvVars, windows::WindowsEnvVars}; +use crate::*; #[derive(Default)] pub enum EnvVars<'tcx> { diff --git a/src/tools/miri/src/shims/foreign_items.rs b/src/tools/miri/src/shims/foreign_items.rs index 11cb9740e3e6d..c0484dde59b5b 100644 --- a/src/tools/miri/src/shims/foreign_items.rs +++ b/src/tools/miri/src/shims/foreign_items.rs @@ -12,10 +12,10 @@ use rustc_target::{ spec::abi::Abi, }; +use self::helpers::{ToHost, ToSoft}; use super::alloc::EvalContextExt as _; use super::backtrace::EvalContextExt as _; use crate::*; -use self::helpers::{ToHost, ToSoft}; /// Type of dynamic symbols (for `dlsym` et al) #[derive(Debug, Copy, Clone)] diff --git a/src/tools/miri/src/shims/panic.rs b/src/tools/miri/src/shims/panic.rs index 52c4394591c2d..55b814a09fa01 100644 --- a/src/tools/miri/src/shims/panic.rs +++ b/src/tools/miri/src/shims/panic.rs @@ -16,8 +16,8 @@ use rustc_middle::{mir, ty}; use rustc_target::spec::PanicStrategy; use rustc_target::spec::abi::Abi; -use crate::*; use self::helpers::check_arg_count; +use crate::*; /// Holds all of the relevant data for when unwinding hits a `try` frame. #[derive(Debug)] diff --git a/src/tools/miri/src/shims/unix/fs.rs b/src/tools/miri/src/shims/unix/fs.rs index c90839138ce6f..1b657db5cccc0 100644 --- a/src/tools/miri/src/shims/unix/fs.rs +++ b/src/tools/miri/src/shims/unix/fs.rs @@ -11,11 +11,11 @@ use std::time::SystemTime; use rustc_data_structures::fx::FxHashMap; use rustc_target::abi::Size; +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::shims::time::system_time_to_duration; use self::fd::FlockOp; 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 6418280d03504..07527a9d6e332 100644 --- a/src/tools/miri/src/shims/unix/linux/foreign_items.rs +++ b/src/tools/miri/src/shims/unix/linux/foreign_items.rs @@ -1,14 +1,14 @@ use rustc_span::Symbol; use rustc_target::spec::abi::Abi; -use crate::machine::SIGRTMAX; -use crate::machine::SIGRTMIN; -use crate::shims::unix::*; -use crate::*; use self::shims::unix::linux::epoll::EvalContextExt as _; 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::shims::unix::*; +use crate::*; pub fn is_dyn_sym(name: &str) -> bool { matches!(name, "statx") diff --git a/src/tools/miri/src/shims/unix/macos/foreign_items.rs b/src/tools/miri/src/shims/unix/macos/foreign_items.rs index 95a41752059dc..ce4ea0816f016 100644 --- a/src/tools/miri/src/shims/unix/macos/foreign_items.rs +++ b/src/tools/miri/src/shims/unix/macos/foreign_items.rs @@ -80,7 +80,8 @@ pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> { // Random data generation "CCRandomGenerateBytes" => { - let [bytes, count] = this.check_shim(abi, Abi::C { unwind: false }, link_name, args)?; + let [bytes, count] = + this.check_shim(abi, Abi::C { unwind: false }, link_name, args)?; let bytes = this.read_pointer(bytes)?; let count = this.read_target_usize(count)?; let success = this.eval_libc_i32("kCCSuccess"); diff --git a/src/tools/miri/src/shims/windows/env.rs b/src/tools/miri/src/shims/windows/env.rs index 178b0a1a4612e..9707482b1e2c2 100644 --- a/src/tools/miri/src/shims/windows/env.rs +++ b/src/tools/miri/src/shims/windows/env.rs @@ -4,8 +4,8 @@ use std::io::ErrorKind; use rustc_data_structures::fx::FxHashMap; -use crate::*; use self::helpers::windows_check_buffer_size; +use crate::*; #[derive(Default)] pub struct WindowsEnvVars { diff --git a/src/tools/miri/src/shims/windows/foreign_items.rs b/src/tools/miri/src/shims/windows/foreign_items.rs index f385ed4ac115a..998daddf5208f 100644 --- a/src/tools/miri/src/shims/windows/foreign_items.rs +++ b/src/tools/miri/src/shims/windows/foreign_items.rs @@ -8,10 +8,10 @@ use rustc_span::Symbol; use rustc_target::abi::{Align, Size}; use rustc_target::spec::abi::Abi; +use self::shims::windows::handle::{Handle, PseudoHandle}; use crate::shims::os_str::bytes_to_os_str; use crate::shims::windows::*; use crate::*; -use self::shims::windows::handle::{Handle, PseudoHandle}; pub fn is_dyn_sym(name: &str) -> bool { // std does dynamic detection for these symbols diff --git a/src/tools/miri/src/shims/windows/thread.rs b/src/tools/miri/src/shims/windows/thread.rs index 9f93fc5f0810f..a4c177311d46d 100644 --- a/src/tools/miri/src/shims/windows/thread.rs +++ b/src/tools/miri/src/shims/windows/thread.rs @@ -1,8 +1,8 @@ use rustc_middle::ty::layout::LayoutOf; use rustc_target::spec::abi::Abi; -use crate::*; use self::shims::windows::handle::{EvalContextExt as _, Handle, PseudoHandle}; +use crate::*; impl<'tcx> EvalContextExt<'tcx> for crate::MiriInterpCx<'tcx> {} diff --git a/src/tools/miri/src/shims/x86/mod.rs b/src/tools/miri/src/shims/x86/mod.rs index 9139156fd0e4d..211bd168af28b 100644 --- a/src/tools/miri/src/shims/x86/mod.rs +++ b/src/tools/miri/src/shims/x86/mod.rs @@ -8,8 +8,8 @@ use rustc_span::Symbol; use rustc_target::abi::Size; use rustc_target::spec::abi::Abi; -use crate::*; use self::helpers::bool_to_simd_element; +use crate::*; mod aesni; mod avx; diff --git a/src/tools/miri/tests/fail/validity/wrong-dyn-trait-assoc-type.rs b/src/tools/miri/tests/fail/validity/wrong-dyn-trait-assoc-type.rs index 1478abedee0d8..566ddac2cc71a 100644 --- a/src/tools/miri/tests/fail/validity/wrong-dyn-trait-assoc-type.rs +++ b/src/tools/miri/tests/fail/validity/wrong-dyn-trait-assoc-type.rs @@ -5,7 +5,9 @@ trait Trait { impl Trait for T { type Assoc = T; - fn foo(&self) -> T { *self } + fn foo(&self) -> T { + *self + } } fn main() { From cbe2ec05ac0be48f808464cc61ee108ac8315b9a Mon Sep 17 00:00:00 2001 From: Ralf Jung Date: Wed, 25 Sep 2024 08:22:33 +0200 Subject: [PATCH 07/26] add test for std::random --- src/tools/miri/tests/pass/shims/random.rs | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 src/tools/miri/tests/pass/shims/random.rs diff --git a/src/tools/miri/tests/pass/shims/random.rs b/src/tools/miri/tests/pass/shims/random.rs new file mode 100644 index 0000000000000..ae75ebdcd3f32 --- /dev/null +++ b/src/tools/miri/tests/pass/shims/random.rs @@ -0,0 +1,5 @@ +#![feature(random)] + +fn main() { + let _x: i32 = std::random::random(); +} From 60265e456bdce6ca990968179c05f228d7f8669d Mon Sep 17 00:00:00 2001 From: Ralf Jung Date: Wed, 25 Sep 2024 08:29:10 +0200 Subject: [PATCH 08/26] avoid using HashMap in fs test --- src/tools/miri/tests/pass/shims/fs.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/tools/miri/tests/pass/shims/fs.rs b/src/tools/miri/tests/pass/shims/fs.rs index 62424ca26b1c7..81151f4ac4730 100644 --- a/src/tools/miri/tests/pass/shims/fs.rs +++ b/src/tools/miri/tests/pass/shims/fs.rs @@ -4,7 +4,7 @@ #![feature(io_error_more)] #![feature(io_error_uncategorized)] -use std::collections::HashMap; +use std::collections::BTreeMap; use std::ffi::OsString; use std::fs::{ File, OpenOptions, canonicalize, create_dir, read_dir, remove_dir, remove_dir_all, remove_file, @@ -262,7 +262,7 @@ fn test_directory() { create_dir(&dir_1).unwrap(); // Test that read_dir metadata calls succeed assert_eq!( - HashMap::from([ + BTreeMap::from([ (OsString::from("test_file_1"), true), (OsString::from("test_file_2"), true), (OsString::from("test_dir_1"), false) @@ -273,7 +273,7 @@ fn test_directory() { let e = e.unwrap(); (e.file_name(), e.metadata().unwrap().is_file()) }) - .collect::>() + .collect::>() ); // Deleting the directory should fail, since it is not empty. assert_eq!(ErrorKind::DirectoryNotEmpty, remove_dir(&dir_path).unwrap_err().kind()); From a374d1c5896bc06e8f059966710a98f261d3bc81 Mon Sep 17 00:00:00 2001 From: Ralf Jung Date: Wed, 25 Sep 2024 08:30:26 +0200 Subject: [PATCH 09/26] update BASIC test list: no longer test HashMap, add libc-mem instead of 'align' for heap allocator coverage, move 'hello' to UNIX HashMap now needs pretty target-specific randomness functions. It still works on Android, but not on FreeBSD and Solarish. --- src/tools/miri/README.md | 2 +- src/tools/miri/ci/ci.sh | 10 +++++----- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/tools/miri/README.md b/src/tools/miri/README.md index d8636915ea80e..f6349f45f43d0 100644 --- a/src/tools/miri/README.md +++ b/src/tools/miri/README.md @@ -219,7 +219,7 @@ degree documented below): - `solaris` / `illumos`: maintained by @devnexen. Supports `std::{env, thread, sync}`, but not `std::fs`. - `freebsd`: **maintainer wanted**. Supports `std::env` and parts of `std::{thread, fs}`, but not `std::sync`. - `android`: **maintainer wanted**. Support very incomplete, but a basic "hello world" works. - - `wasm`: **maintainer wanted**. Support very incomplete, not even standard output works, but an empty `main` function works. + - `wasi`: **maintainer wanted**. Support very incomplete, not even standard output works, but an empty `main` function works. - For targets on other operating systems, Miri might fail before even reaching the `main` function. However, even for targets that we do support, the degree of support for accessing platform APIs diff --git a/src/tools/miri/ci/ci.sh b/src/tools/miri/ci/ci.sh index c7be71662bd5f..251a5d63e1591 100755 --- a/src/tools/miri/ci/ci.sh +++ b/src/tools/miri/ci/ci.sh @@ -148,15 +148,15 @@ case $HOST_TARGET in TEST_TARGET=arm-unknown-linux-gnueabi run_tests TEST_TARGET=s390x-unknown-linux-gnu run_tests # big-endian architecture of choice # Partially supported targets (tier 2) - BASIC="empty_main integer vec string btreemap hello hashmap heap_alloc align" # ensures we have the basics: stdout/stderr, system allocator, randomness (for HashMap initialization) - UNIX="panic/panic panic/unwind concurrency/simple atomic libc-mem libc-misc libc-random env num_cpus" # the things that are very similar across all Unixes, and hence easily supported there + BASIC="empty_main integer heap_alloc libc-mem vec string btreemap" # ensures we have the basics: pre-main code, system allocator + UNIX="hello panic/panic panic/unwind concurrency/simple atomic libc-mem libc-misc libc-random env num_cpus" # the things that are very similar across all Unixes, and hence easily supported there TEST_TARGET=x86_64-unknown-freebsd run_tests_minimal $BASIC $UNIX threadname pthread time fs TEST_TARGET=i686-unknown-freebsd run_tests_minimal $BASIC $UNIX threadname pthread time fs TEST_TARGET=x86_64-unknown-illumos run_tests_minimal $BASIC $UNIX thread sync available-parallelism time tls TEST_TARGET=x86_64-pc-solaris run_tests_minimal $BASIC $UNIX thread sync available-parallelism time tls - TEST_TARGET=aarch64-linux-android run_tests_minimal $BASIC $UNIX pthread --skip threadname --skip pthread_cond_timedwait - TEST_TARGET=wasm32-wasip2 run_tests_minimal empty_main wasm heap_alloc libc-mem - TEST_TARGET=wasm32-unknown-unknown run_tests_minimal empty_main wasm + TEST_TARGET=aarch64-linux-android run_tests_minimal $BASIC $UNIX hashmap pthread --skip threadname --skip pthread_cond_timedwait + TEST_TARGET=wasm32-wasip2 run_tests_minimal $BASIC wasm + TEST_TARGET=wasm32-unknown-unknown run_tests_minimal no_std empty_main wasm # this target doesn't really have std TEST_TARGET=thumbv7em-none-eabihf run_tests_minimal no_std # Custom target JSON file TEST_TARGET=tests/avr.json MIRI_NO_STD=1 run_tests_minimal no_std From 94339583b89d4f04a2eae7a14e4fdf7c5a02347f Mon Sep 17 00:00:00 2001 From: Ralf Jung Date: Wed, 25 Sep 2024 10:50:41 +0200 Subject: [PATCH 10/26] disable AVR test since it doesn't work --- src/tools/miri/ci/ci.sh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/tools/miri/ci/ci.sh b/src/tools/miri/ci/ci.sh index 251a5d63e1591..2d4cf696d8cb7 100755 --- a/src/tools/miri/ci/ci.sh +++ b/src/tools/miri/ci/ci.sh @@ -159,7 +159,8 @@ case $HOST_TARGET in TEST_TARGET=wasm32-unknown-unknown run_tests_minimal no_std empty_main wasm # this target doesn't really have std TEST_TARGET=thumbv7em-none-eabihf run_tests_minimal no_std # Custom target JSON file - TEST_TARGET=tests/avr.json MIRI_NO_STD=1 run_tests_minimal no_std + # FIXME: disabled due to . + #TEST_TARGET=tests/avr.json MIRI_NO_STD=1 run_tests_minimal no_std ;; i686-pc-windows-msvc) # Host From b44888f7e981632381e395ed5660ddbff06b076f Mon Sep 17 00:00:00 2001 From: Yoh Deadfall Date: Tue, 24 Sep 2024 19:21:53 +0300 Subject: [PATCH 11/26] Android: Fixed tests for libc time API --- src/tools/miri/ci/ci.sh | 2 +- src/tools/miri/src/shims/time.rs | 4 +-- .../miri/tests/pass-dep/libc/libc-time.rs | 30 +++++++++++++++---- 3 files changed, 28 insertions(+), 8 deletions(-) diff --git a/src/tools/miri/ci/ci.sh b/src/tools/miri/ci/ci.sh index 2d4cf696d8cb7..fe0633135df9c 100755 --- a/src/tools/miri/ci/ci.sh +++ b/src/tools/miri/ci/ci.sh @@ -154,7 +154,7 @@ case $HOST_TARGET in TEST_TARGET=i686-unknown-freebsd run_tests_minimal $BASIC $UNIX threadname pthread time fs TEST_TARGET=x86_64-unknown-illumos run_tests_minimal $BASIC $UNIX thread sync available-parallelism time tls TEST_TARGET=x86_64-pc-solaris run_tests_minimal $BASIC $UNIX thread sync available-parallelism time tls - TEST_TARGET=aarch64-linux-android run_tests_minimal $BASIC $UNIX hashmap pthread --skip threadname --skip pthread_cond_timedwait + TEST_TARGET=aarch64-linux-android run_tests_minimal $BASIC $UNIX hashmap pthread time --skip threadname --skip pthread_cond_timedwait TEST_TARGET=wasm32-wasip2 run_tests_minimal $BASIC wasm TEST_TARGET=wasm32-unknown-unknown run_tests_minimal no_std empty_main wasm # this target doesn't really have std TEST_TARGET=thumbv7em-none-eabihf run_tests_minimal no_std diff --git a/src/tools/miri/src/shims/time.rs b/src/tools/miri/src/shims/time.rs index ebec1a70c5cd0..694c52b54657a 100644 --- a/src/tools/miri/src/shims/time.rs +++ b/src/tools/miri/src/shims/time.rs @@ -36,8 +36,8 @@ pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> { let mut relative_clocks; match this.tcx.sess.target.os.as_ref() { - "linux" | "freebsd" => { - // Linux and FreeBSD have two main kinds of clocks. REALTIME clocks return the actual time since the + "linux" | "freebsd" | "android" => { + // Linux, Android, and FreeBSD have two main kinds of clocks. REALTIME clocks return the actual time since the // Unix epoch, including effects which may cause time to move backwards such as NTP. // Linux further distinguishes regular and "coarse" clocks, but the "coarse" version // is just specified to be "faster and less precise", so we implement both the same way. diff --git a/src/tools/miri/tests/pass-dep/libc/libc-time.rs b/src/tools/miri/tests/pass-dep/libc/libc-time.rs index c2c875864920a..84dbd8ad768f1 100644 --- a/src/tools/miri/tests/pass-dep/libc/libc-time.rs +++ b/src/tools/miri/tests/pass-dep/libc/libc-time.rs @@ -15,7 +15,7 @@ fn test_clocks() { assert_eq!(is_error, 0); let is_error = unsafe { libc::clock_gettime(libc::CLOCK_MONOTONIC, tp.as_mut_ptr()) }; assert_eq!(is_error, 0); - #[cfg(any(target_os = "linux", target_os = "freebsd"))] + #[cfg(any(target_os = "linux", target_os = "freebsd", target_os = "android"))] { let is_error = unsafe { libc::clock_gettime(libc::CLOCK_REALTIME_COARSE, tp.as_mut_ptr()) }; assert_eq!(is_error, 0); @@ -63,9 +63,19 @@ fn test_localtime_r() { tm_wday: 0, tm_yday: 0, tm_isdst: 0, - #[cfg(any(target_os = "linux", target_os = "macos", target_os = "freebsd"))] + #[cfg(any( + target_os = "linux", + target_os = "macos", + target_os = "freebsd", + target_os = "android" + ))] tm_gmtoff: 0, - #[cfg(any(target_os = "linux", target_os = "macos", target_os = "freebsd"))] + #[cfg(any( + target_os = "linux", + target_os = "macos", + target_os = "freebsd", + target_os = "android" + ))] tm_zone: std::ptr::null_mut::(), }; let res = unsafe { libc::localtime_r(custom_time_ptr, &mut tm) }; @@ -79,9 +89,19 @@ fn test_localtime_r() { assert_eq!(tm.tm_wday, 0); assert_eq!(tm.tm_yday, 97); assert_eq!(tm.tm_isdst, -1); - #[cfg(any(target_os = "linux", target_os = "macos", target_os = "freebsd"))] + #[cfg(any( + target_os = "linux", + target_os = "macos", + target_os = "freebsd", + target_os = "android" + ))] assert_eq!(tm.tm_gmtoff, 0); - #[cfg(any(target_os = "linux", target_os = "macos", target_os = "freebsd"))] + #[cfg(any( + target_os = "linux", + target_os = "macos", + target_os = "freebsd", + target_os = "android" + ))] unsafe { assert_eq!(std::ffi::CStr::from_ptr(tm.tm_zone).to_str().unwrap(), "+00") }; From c69b457ac211a2da93a0784e221b06f09df297de Mon Sep 17 00:00:00 2001 From: Ralf Jung Date: Wed, 25 Sep 2024 15:07:21 +0200 Subject: [PATCH 12/26] enable pthread_cond_timedwait test on Android --- src/tools/miri/ci/ci.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/tools/miri/ci/ci.sh b/src/tools/miri/ci/ci.sh index fe0633135df9c..1cbb78d825490 100755 --- a/src/tools/miri/ci/ci.sh +++ b/src/tools/miri/ci/ci.sh @@ -154,7 +154,7 @@ case $HOST_TARGET in TEST_TARGET=i686-unknown-freebsd run_tests_minimal $BASIC $UNIX threadname pthread time fs TEST_TARGET=x86_64-unknown-illumos run_tests_minimal $BASIC $UNIX thread sync available-parallelism time tls TEST_TARGET=x86_64-pc-solaris run_tests_minimal $BASIC $UNIX thread sync available-parallelism time tls - TEST_TARGET=aarch64-linux-android run_tests_minimal $BASIC $UNIX hashmap pthread time --skip threadname --skip pthread_cond_timedwait + TEST_TARGET=aarch64-linux-android run_tests_minimal $BASIC $UNIX hashmap pthread time --skip threadname TEST_TARGET=wasm32-wasip2 run_tests_minimal $BASIC wasm TEST_TARGET=wasm32-unknown-unknown run_tests_minimal no_std empty_main wasm # this target doesn't really have std TEST_TARGET=thumbv7em-none-eabihf run_tests_minimal no_std From 897e94179763e5ec4cde76154abdf2a9392bef65 Mon Sep 17 00:00:00 2001 From: Ralf Jung Date: Wed, 25 Sep 2024 16:37:04 +0200 Subject: [PATCH 13/26] switch custom target JSON test to a less exotic target --- src/tools/miri/ci/ci.sh | 3 +-- src/tools/miri/tests/avr.json | 25 ------------------- .../miri/tests/x86_64-unknown-kernel.json | 24 ++++++++++++++++++ 3 files changed, 25 insertions(+), 27 deletions(-) delete mode 100644 src/tools/miri/tests/avr.json create mode 100644 src/tools/miri/tests/x86_64-unknown-kernel.json diff --git a/src/tools/miri/ci/ci.sh b/src/tools/miri/ci/ci.sh index 2d4cf696d8cb7..284a1fa9b992f 100755 --- a/src/tools/miri/ci/ci.sh +++ b/src/tools/miri/ci/ci.sh @@ -159,8 +159,7 @@ case $HOST_TARGET in TEST_TARGET=wasm32-unknown-unknown run_tests_minimal no_std empty_main wasm # this target doesn't really have std TEST_TARGET=thumbv7em-none-eabihf run_tests_minimal no_std # Custom target JSON file - # FIXME: disabled due to . - #TEST_TARGET=tests/avr.json MIRI_NO_STD=1 run_tests_minimal no_std + TEST_TARGET=tests/x86_64-unknown-kernel.json MIRI_NO_STD=1 run_tests_minimal no_std ;; i686-pc-windows-msvc) # Host diff --git a/src/tools/miri/tests/avr.json b/src/tools/miri/tests/avr.json deleted file mode 100644 index 1e00b0f57ef09..0000000000000 --- a/src/tools/miri/tests/avr.json +++ /dev/null @@ -1,25 +0,0 @@ -{ - "arch": "avr", - "cpu": "atmega328p", - "data-layout": "e-P1-p:16:8-i8:8-i16:8-i32:8-i64:8-f32:8-f64:8-n8-a:8", - "env": "", - "executables": true, - "linker": "avr-gcc", - "linker-flavor": "gcc", - "linker-is-gnu": true, - "llvm-target": "avr-unknown-unknown", - "os": "unknown", - "position-independent-executables": false, - "exe-suffix": ".elf", - "eh-frame-header": false, - "pre-link-args": { - "gcc": ["-mmcu=atmega328p"] - }, - "late-link-args": { - "gcc": ["-lgcc"] - }, - "target-c-int-width": "16", - "target-endian": "little", - "target-pointer-width": "16", - "vendor": "unknown" -} diff --git a/src/tools/miri/tests/x86_64-unknown-kernel.json b/src/tools/miri/tests/x86_64-unknown-kernel.json new file mode 100644 index 0000000000000..8135b618d0d36 --- /dev/null +++ b/src/tools/miri/tests/x86_64-unknown-kernel.json @@ -0,0 +1,24 @@ +{ + "llvm-target": "x86_64-unknown-none", + "target-endian": "little", + "target-pointer-width": "64", + "target-c-int-width": "32", + "data-layout": "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128", + "arch": "x86_64", + "os": "none", + "env": "", + "vendor": "unknown", + "linker": "rust-lld", + "linker-flavor": "gnu-lld", + "features": "-mmx,-sse,-sse2,-sse3,-ssse3,-sse4.1,-sse4.2,-avx,-avx2,+soft-float", + "dynamic-linking": false, + "executables": true, + "relocation-model": "static", + "code-model": "kernel", + "disable-redzone": true, + "frame-pointer": "always", + "exe-suffix": "", + "has-rpath": false, + "no-default-libraries": true, + "position-independent-executables": false +} From 824884d743c042cde47a532173b74967f10195ab Mon Sep 17 00:00:00 2001 From: The Miri Cronjob Bot Date: Thu, 26 Sep 2024 05:15:46 +0000 Subject: [PATCH 14/26] Preparing for merge from rustc --- src/tools/miri/rust-version | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/tools/miri/rust-version b/src/tools/miri/rust-version index 79ed6cc7d74b8..b05c409f82319 100644 --- a/src/tools/miri/rust-version +++ b/src/tools/miri/rust-version @@ -1 +1 @@ -1b5aa96d6016bafe50e071b45d4d2e3c90fd766f +76ed7a1fa40c3f54d3fd3f834e12bf9c932d0146 From adbaf13d32f09d134f04b3af77517500f8fd3e86 Mon Sep 17 00:00:00 2001 From: Ralf Jung Date: Thu, 26 Sep 2024 09:18:14 +0200 Subject: [PATCH 15/26] bump rustc-build-sysroot version --- src/tools/miri/cargo-miri/Cargo.lock | 4 ++-- src/tools/miri/cargo-miri/Cargo.toml | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/tools/miri/cargo-miri/Cargo.lock b/src/tools/miri/cargo-miri/Cargo.lock index 7369a3fbf09ae..a873472fd5dc9 100644 --- a/src/tools/miri/cargo-miri/Cargo.lock +++ b/src/tools/miri/cargo-miri/Cargo.lock @@ -190,9 +190,9 @@ dependencies = [ [[package]] name = "rustc-build-sysroot" -version = "0.5.3" +version = "0.5.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2471f8f296262437d7e848e527b4210b44a96e53a3b4435b890227ce3e6da106" +checksum = "d6d984a9db43148467059309bd1e5ad577085162f695d9fe2cf3543aeb25cd38" dependencies = [ "anyhow", "rustc_version", diff --git a/src/tools/miri/cargo-miri/Cargo.toml b/src/tools/miri/cargo-miri/Cargo.toml index 477c60db162a3..ee2004278b4e3 100644 --- a/src/tools/miri/cargo-miri/Cargo.toml +++ b/src/tools/miri/cargo-miri/Cargo.toml @@ -18,7 +18,7 @@ directories = "5" rustc_version = "0.4" serde_json = "1.0.40" cargo_metadata = "0.18.0" -rustc-build-sysroot = "0.5.3" +rustc-build-sysroot = "0.5.4" # Enable some feature flags that dev-dependencies need but dependencies # do not. This makes `./miri install` after `./miri build` faster. From 294fdb820c16ebba2bfa442e53b659752aa48a0d Mon Sep 17 00:00:00 2001 From: Ralf Jung Date: Thu, 26 Sep 2024 09:28:23 +0200 Subject: [PATCH 16/26] clippy --- src/tools/miri/cargo-miri/src/phases.rs | 2 ++ src/tools/miri/src/borrow_tracker/stacked_borrows/mod.rs | 2 +- src/tools/miri/src/shims/unix/linux/epoll.rs | 6 +++--- src/tools/miri/src/shims/unix/linux/eventfd.rs | 2 +- 4 files changed, 7 insertions(+), 5 deletions(-) diff --git a/src/tools/miri/cargo-miri/src/phases.rs b/src/tools/miri/cargo-miri/src/phases.rs index 3743446e27648..e13ecbbe54ba5 100644 --- a/src/tools/miri/cargo-miri/src/phases.rs +++ b/src/tools/miri/cargo-miri/src/phases.rs @@ -666,6 +666,8 @@ pub fn phase_runner(mut binary_args: impl Iterator, phase: Runner match phase { RunnerPhase::Rustdoc => { cmd.stdin(std::process::Stdio::piped()); + // the warning is wrong, we have a `wait` inside the `scope` closure. + #[expect(clippy::zombie_processes)] let mut child = cmd.spawn().expect("failed to spawn process"); let child_stdin = child.stdin.take().unwrap(); // Write stdin in a background thread, as it may block. 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 f792e75ad0855..7eb6773038388 100644 --- a/src/tools/miri/src/borrow_tracker/stacked_borrows/mod.rs +++ b/src/tools/miri/src/borrow_tracker/stacked_borrows/mod.rs @@ -171,7 +171,7 @@ impl NewPermission { /// F2b: No `SharedReadWrite` or `Unique` will ever be added on top of our `SharedReadOnly`. /// F3: If an access happens with an `&` outside `UnsafeCell`, /// it requires the `SharedReadOnly` to still be in the stack. - +/// /// Core relation on `Permission` to define which accesses are allowed impl Permission { /// This defines for a given permission, whether it permits the given kind of access. diff --git a/src/tools/miri/src/shims/unix/linux/epoll.rs b/src/tools/miri/src/shims/unix/linux/epoll.rs index 3d4fe770e99e9..b63c29594b407 100644 --- a/src/tools/miri/src/shims/unix/linux/epoll.rs +++ b/src/tools/miri/src/shims/unix/linux/epoll.rs @@ -401,19 +401,19 @@ pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> { /// list about file descriptors in the interest list that have some /// events available. Up to `maxevents` are returned by `epoll_wait()`. /// The `maxevents` argument must be greater than zero. - + /// /// The `timeout` argument specifies the number of milliseconds that /// `epoll_wait()` will block. Time is measured against the /// CLOCK_MONOTONIC clock. If the timeout is zero, the function will not block, /// while if the timeout is -1, the function will block /// until at least one event has been retrieved (or an error /// occurred). - + /// /// A call to `epoll_wait()` will block until either: /// • a file descriptor delivers an event; /// • the call is interrupted by a signal handler; or /// • the timeout expires. - + /// /// Note that the timeout interval will be rounded up to the system /// clock granularity, and kernel scheduling delays mean that the /// blocking interval may overrun by a small amount. Specifying a diff --git a/src/tools/miri/src/shims/unix/linux/eventfd.rs b/src/tools/miri/src/shims/unix/linux/eventfd.rs index d1d461daa993e..9fbabbd964180 100644 --- a/src/tools/miri/src/shims/unix/linux/eventfd.rs +++ b/src/tools/miri/src/shims/unix/linux/eventfd.rs @@ -110,7 +110,7 @@ impl FileDescription for Event { /// write either blocks until a read is performed on the /// file descriptor, or fails with the error EAGAIN if the /// file descriptor has been made nonblocking. - + /// /// A write fails with the error EINVAL if the size of the /// supplied buffer is less than 8 bytes, or if an attempt is /// made to write the value 0xffffffffffffffff. From bf78aec5106c94fe0d490b91f6b2aaac9c4f6a9c Mon Sep 17 00:00:00 2001 From: Ralf Jung Date: Thu, 26 Sep 2024 09:36:11 +0200 Subject: [PATCH 17/26] fix clippy::needless_return --- src/tools/miri/src/concurrency/sync.rs | 2 +- src/tools/miri/src/concurrency/thread.rs | 2 +- src/tools/miri/src/lib.rs | 1 - src/tools/miri/src/shims/alloc.rs | 2 +- src/tools/miri/src/shims/env.rs | 2 +- src/tools/miri/src/shims/unix/fd.rs | 4 ++-- src/tools/miri/src/shims/unix/linux/epoll.rs | 7 ++++--- src/tools/miri/src/shims/windows/foreign_items.rs | 4 ++-- src/tools/miri/src/shims/windows/sync.rs | 2 +- 9 files changed, 13 insertions(+), 13 deletions(-) diff --git a/src/tools/miri/src/concurrency/sync.rs b/src/tools/miri/src/concurrency/sync.rs index bc4d805687268..2b34db047f379 100644 --- a/src/tools/miri/src/concurrency/sync.rs +++ b/src/tools/miri/src/concurrency/sync.rs @@ -748,7 +748,7 @@ pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> { } ), ); - return Ok(()); + Ok(()) } /// Wake up some thread (if there is any) sleeping on the conditional diff --git a/src/tools/miri/src/concurrency/thread.rs b/src/tools/miri/src/concurrency/thread.rs index 4efe2beb1558e..681e9211246dd 100644 --- a/src/tools/miri/src/concurrency/thread.rs +++ b/src/tools/miri/src/concurrency/thread.rs @@ -849,7 +849,7 @@ trait EvalContextPrivExt<'tcx>: MiriInterpCxExt<'tcx> { // https://github.com/rust-lang/miri/issues/1763). In this case, // just do nothing, which effectively just returns to the // scheduler. - return Ok(()); + Ok(()) } #[inline] diff --git a/src/tools/miri/src/lib.rs b/src/tools/miri/src/lib.rs index 6e015813e77a7..aa0d29d38f42a 100644 --- a/src/tools/miri/src/lib.rs +++ b/src/tools/miri/src/lib.rs @@ -33,7 +33,6 @@ clippy::too_many_arguments, clippy::type_complexity, clippy::single_element_loop, - clippy::needless_return, clippy::bool_to_int_with_if, clippy::box_default, clippy::needless_question_mark, diff --git a/src/tools/miri/src/shims/alloc.rs b/src/tools/miri/src/shims/alloc.rs index a33657d33a2e1..057d7ef5e67b9 100644 --- a/src/tools/miri/src/shims/alloc.rs +++ b/src/tools/miri/src/shims/alloc.rs @@ -71,7 +71,7 @@ pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> { // and not execute any Miri shim. Somewhat unintuitively doing so is done // by returning `NotSupported`, which triggers the `lookup_exported_symbol` // fallback case in `emulate_foreign_item`. - return Ok(EmulateItemResult::NotSupported); + Ok(EmulateItemResult::NotSupported) } AllocatorKind::Default => { default(this)?; diff --git a/src/tools/miri/src/shims/env.rs b/src/tools/miri/src/shims/env.rs index d12a0581b4137..c465ef3d28bc8 100644 --- a/src/tools/miri/src/shims/env.rs +++ b/src/tools/miri/src/shims/env.rs @@ -103,7 +103,7 @@ pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> { fn get_env_var(&mut self, name: &OsStr) -> InterpResult<'tcx, Option> { let this = self.eval_context_ref(); match &this.machine.env_vars { - EnvVars::Uninit => return Ok(None), + EnvVars::Uninit => Ok(None), EnvVars::Unix(vars) => vars.get(this, name), EnvVars::Windows(vars) => vars.get(name), } diff --git a/src/tools/miri/src/shims/unix/fd.rs b/src/tools/miri/src/shims/unix/fd.rs index 6b78ce7ad47bb..5fae746af2b63 100644 --- a/src/tools/miri/src/shims/unix/fd.rs +++ b/src/tools/miri/src/shims/unix/fd.rs @@ -676,12 +676,12 @@ pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> { this.write_bytes_ptr(buf, bytes[..read_bytes].iter().copied())?; // The actual read size is always less than what got originally requested so this cannot fail. this.write_int(u64::try_from(read_bytes).unwrap(), dest)?; - return Ok(()); + Ok(()) } Err(e) => { this.set_last_error_from_io_error(e)?; this.write_int(-1, dest)?; - return Ok(()); + Ok(()) } } } diff --git a/src/tools/miri/src/shims/unix/linux/epoll.rs b/src/tools/miri/src/shims/unix/linux/epoll.rs index b63c29594b407..675a404ae117c 100644 --- a/src/tools/miri/src/shims/unix/linux/epoll.rs +++ b/src/tools/miri/src/shims/unix/linux/epoll.rs @@ -596,7 +596,7 @@ fn ready_list_next( return Some(epoll_event_instance); } } - return None; + None } /// This helper function checks whether an epoll notification should be triggered for a specific @@ -623,9 +623,10 @@ fn check_and_update_one_event_interest<'tcx>( let event_instance = EpollEventInstance::new(flags, epoll_event_interest.data); // Triggers the notification by inserting it to the ready list. ready_list.insert(epoll_key, event_instance); - return Ok(true); + Ok(true) + } else { + Ok(false) } - return Ok(false); } /// Callback function after epoll_wait unblocks diff --git a/src/tools/miri/src/shims/windows/foreign_items.rs b/src/tools/miri/src/shims/windows/foreign_items.rs index 998daddf5208f..cd8f3e59015a3 100644 --- a/src/tools/miri/src/shims/windows/foreign_items.rs +++ b/src/tools/miri/src/shims/windows/foreign_items.rs @@ -23,8 +23,8 @@ pub fn is_dyn_sym(name: &str) -> bool { #[cfg(windows)] fn win_absolute<'tcx>(path: &Path) -> InterpResult<'tcx, io::Result> { - // We are on Windows so we can simply lte the host do this. - return Ok(path::absolute(path)); + // We are on Windows so we can simply let the host do this. + Ok(path::absolute(path)) } #[cfg(unix)] diff --git a/src/tools/miri/src/shims/windows/sync.rs b/src/tools/miri/src/shims/windows/sync.rs index 51b0129356baa..5786b17e50c92 100644 --- a/src/tools/miri/src/shims/windows/sync.rs +++ b/src/tools/miri/src/shims/windows/sync.rs @@ -90,7 +90,7 @@ pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> { } ), ); - return Ok(()); + Ok(()) } fn InitOnceComplete( From 18aa926d0906661f7fdb2936a12fba102abbbb7d Mon Sep 17 00:00:00 2001 From: Ralf Jung Date: Thu, 26 Sep 2024 09:40:57 +0200 Subject: [PATCH 18/26] remove some clippy lints from the list that we do not even trigger any more --- src/tools/miri/src/lib.rs | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/tools/miri/src/lib.rs b/src/tools/miri/src/lib.rs index aa0d29d38f42a..4d0606113f9ea 100644 --- a/src/tools/miri/src/lib.rs +++ b/src/tools/miri/src/lib.rs @@ -32,9 +32,7 @@ clippy::derived_hash_with_manual_eq, clippy::too_many_arguments, clippy::type_complexity, - clippy::single_element_loop, clippy::bool_to_int_with_if, - clippy::box_default, clippy::needless_question_mark, clippy::needless_lifetimes, clippy::too_long_first_doc_paragraph, From 74d7b226ee511700de42e70a34ca47b6e181e031 Mon Sep 17 00:00:00 2001 From: Chris Denton Date: Fri, 27 Sep 2024 17:09:23 +0000 Subject: [PATCH 19/26] Update cc to 1.1.22 --- src/tools/miri/Cargo.lock | 13 +++++++++++-- .../miri/bench-cargo-miri/backtraces/Cargo.lock | 13 +++++++++++-- src/tools/miri/test_dependencies/Cargo.lock | 13 +++++++++++-- 3 files changed, 33 insertions(+), 6 deletions(-) diff --git a/src/tools/miri/Cargo.lock b/src/tools/miri/Cargo.lock index 002c44b0cc56f..14b719300a86e 100644 --- a/src/tools/miri/Cargo.lock +++ b/src/tools/miri/Cargo.lock @@ -137,9 +137,12 @@ dependencies = [ [[package]] name = "cc" -version = "1.1.7" +version = "1.1.22" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "26a5c3fd7bfa1ce3897a3a3501d362b2d87b7f2583ebcb4a949ec25911025cbc" +checksum = "9540e661f81799159abee814118cc139a2004b3a3aa3ea37724a1b66530b90e0" +dependencies = [ + "shlex", +] [[package]] name = "cfg-if" @@ -947,6 +950,12 @@ dependencies = [ "lazy_static", ] +[[package]] +name = "shlex" +version = "1.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0fda2ff0d084019ba4d7c6f371c95d8fd75ce3524c3cb8fb653a3023f6323e64" + [[package]] name = "siphasher" version = "0.3.11" diff --git a/src/tools/miri/bench-cargo-miri/backtraces/Cargo.lock b/src/tools/miri/bench-cargo-miri/backtraces/Cargo.lock index 375b129a7e59b..848864ea1f3be 100644 --- a/src/tools/miri/bench-cargo-miri/backtraces/Cargo.lock +++ b/src/tools/miri/bench-cargo-miri/backtraces/Cargo.lock @@ -41,9 +41,12 @@ dependencies = [ [[package]] name = "cc" -version = "1.0.73" +version = "1.1.22" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2fff2a6927b3bb87f9595d67196a70493f627687a71d87a0d692242c33f58c11" +checksum = "9540e661f81799159abee814118cc139a2004b3a3aa3ea37724a1b66530b90e0" +dependencies = [ + "shlex", +] [[package]] name = "cfg-if" @@ -92,3 +95,9 @@ name = "rustc-demangle" version = "0.1.21" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7ef03e0a2b150c7a90d01faf6254c9c48a41e95fb2a8c2ac1c6f0d2b9aefc342" + +[[package]] +name = "shlex" +version = "1.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0fda2ff0d084019ba4d7c6f371c95d8fd75ce3524c3cb8fb653a3023f6323e64" diff --git a/src/tools/miri/test_dependencies/Cargo.lock b/src/tools/miri/test_dependencies/Cargo.lock index 9a4431eb7048d..64bfc84ef2006 100644 --- a/src/tools/miri/test_dependencies/Cargo.lock +++ b/src/tools/miri/test_dependencies/Cargo.lock @@ -52,9 +52,12 @@ checksum = "8318a53db07bb3f8dca91a600466bdb3f2eaadeedfdbcf02e1accbad9271ba50" [[package]] name = "cc" -version = "1.1.7" +version = "1.1.22" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "26a5c3fd7bfa1ce3897a3a3501d362b2d87b7f2583ebcb4a949ec25911025cbc" +checksum = "9540e661f81799159abee814118cc139a2004b3a3aa3ea37724a1b66530b90e0" +dependencies = [ + "shlex", +] [[package]] name = "cfg-if" @@ -261,6 +264,12 @@ dependencies = [ "windows-sys", ] +[[package]] +name = "shlex" +version = "1.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0fda2ff0d084019ba4d7c6f371c95d8fd75ce3524c3cb8fb653a3023f6323e64" + [[package]] name = "signal-hook-registry" version = "1.4.2" From c1401daf3ff4c70bda523b5d2c46ffe09732d5cc Mon Sep 17 00:00:00 2001 From: Ralf Jung Date: Sat, 28 Sep 2024 13:41:58 +0200 Subject: [PATCH 20/26] add tests for validity of Box with custom allocator --- .../validity/box-custom-alloc-dangling-ptr.rs | 32 ++++++++++++++++ .../box-custom-alloc-dangling-ptr.stderr | 15 ++++++++ .../box-custom-alloc-invalid-alloc.rs | 37 +++++++++++++++++++ .../box-custom-alloc-invalid-alloc.stderr | 15 ++++++++ 4 files changed, 99 insertions(+) create mode 100644 src/tools/miri/tests/fail/validity/box-custom-alloc-dangling-ptr.rs create mode 100644 src/tools/miri/tests/fail/validity/box-custom-alloc-dangling-ptr.stderr create mode 100644 src/tools/miri/tests/fail/validity/box-custom-alloc-invalid-alloc.rs create mode 100644 src/tools/miri/tests/fail/validity/box-custom-alloc-invalid-alloc.stderr diff --git a/src/tools/miri/tests/fail/validity/box-custom-alloc-dangling-ptr.rs b/src/tools/miri/tests/fail/validity/box-custom-alloc-dangling-ptr.rs new file mode 100644 index 0000000000000..5fb81296494e5 --- /dev/null +++ b/src/tools/miri/tests/fail/validity/box-custom-alloc-dangling-ptr.rs @@ -0,0 +1,32 @@ +//! Ensure that a box with a custom allocator detects when the pointer is dangling. +#![feature(allocator_api)] +// This should not need the aliasing model. +//@compile-flags: -Zmiri-disable-stacked-borrows +use std::alloc::Layout; +use std::ptr::NonNull; + +#[allow(unused)] +struct MyAlloc(usize, usize); // make sure `Box` is an `Aggregate` + +unsafe impl std::alloc::Allocator for MyAlloc { + fn allocate(&self, _layout: Layout) -> Result, std::alloc::AllocError> { + unimplemented!() + } + + unsafe fn deallocate(&self, _ptr: NonNull, _layout: Layout) { + unimplemented!() + } +} + +#[repr(C)] +struct MyBox { + ptr: NonNull, + alloc: MyAlloc, +} + +fn main() { + let b = MyBox { ptr: NonNull::::dangling(), alloc: MyAlloc(0, 0) }; + let _b: Box = unsafe { + std::mem::transmute(b) //~ERROR: dangling box + }; +} diff --git a/src/tools/miri/tests/fail/validity/box-custom-alloc-dangling-ptr.stderr b/src/tools/miri/tests/fail/validity/box-custom-alloc-dangling-ptr.stderr new file mode 100644 index 0000000000000..76d7e66cfc55a --- /dev/null +++ b/src/tools/miri/tests/fail/validity/box-custom-alloc-dangling-ptr.stderr @@ -0,0 +1,15 @@ +error: Undefined Behavior: constructing invalid value: encountered a dangling box (0x4[noalloc] has no provenance) + --> tests/fail/validity/box-custom-alloc-dangling-ptr.rs:LL:CC + | +LL | std::mem::transmute(b) + | ^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered a dangling box (0x4[noalloc] has no provenance) + | + = help: this indicates a bug in the program: it performed an invalid operation, and caused Undefined Behavior + = help: see https://doc.rust-lang.org/nightly/reference/behavior-considered-undefined.html for further information + = note: BACKTRACE: + = note: inside `main` at tests/fail/validity/box-custom-alloc-dangling-ptr.rs:LL:CC + +note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace + +error: aborting due to 1 previous error + diff --git a/src/tools/miri/tests/fail/validity/box-custom-alloc-invalid-alloc.rs b/src/tools/miri/tests/fail/validity/box-custom-alloc-invalid-alloc.rs new file mode 100644 index 0000000000000..101a550593f90 --- /dev/null +++ b/src/tools/miri/tests/fail/validity/box-custom-alloc-invalid-alloc.rs @@ -0,0 +1,37 @@ +//! Ensure that a box with a custom allocator detects when the allocator itself is invalid. +#![feature(allocator_api)] +// This should not need the aliasing model. +//@compile-flags: -Zmiri-disable-stacked-borrows +use std::alloc::Layout; +use std::mem::MaybeUninit; +use std::ptr::NonNull; + +// make sure `Box` is an `Aggregate` +#[allow(unused)] +struct MyAlloc { + my_alloc_field1: usize, + my_alloc_field2: usize, +} + +unsafe impl std::alloc::Allocator for MyAlloc { + fn allocate(&self, _layout: Layout) -> Result, std::alloc::AllocError> { + unimplemented!() + } + + unsafe fn deallocate(&self, _ptr: NonNull, _layout: Layout) { + unimplemented!() + } +} + +#[repr(C)] +struct MyBox { + ptr: NonNull, + alloc: MaybeUninit, +} + +fn main() { + let b = MyBox { ptr: NonNull::from(&42), alloc: MaybeUninit::uninit() }; + let _b: Box = unsafe { + std::mem::transmute(b) //~ERROR: uninitialized memory + }; +} diff --git a/src/tools/miri/tests/fail/validity/box-custom-alloc-invalid-alloc.stderr b/src/tools/miri/tests/fail/validity/box-custom-alloc-invalid-alloc.stderr new file mode 100644 index 0000000000000..e151f80dde3dc --- /dev/null +++ b/src/tools/miri/tests/fail/validity/box-custom-alloc-invalid-alloc.stderr @@ -0,0 +1,15 @@ +error: Undefined Behavior: constructing invalid value at .1.my_alloc_field1: encountered uninitialized memory, but expected an integer + --> tests/fail/validity/box-custom-alloc-invalid-alloc.rs:LL:CC + | +LL | std::mem::transmute(b) + | ^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value at .1.my_alloc_field1: encountered uninitialized memory, but expected an integer + | + = help: this indicates a bug in the program: it performed an invalid operation, and caused Undefined Behavior + = help: see https://doc.rust-lang.org/nightly/reference/behavior-considered-undefined.html for further information + = note: BACKTRACE: + = note: inside `main` at tests/fail/validity/box-custom-alloc-invalid-alloc.rs:LL:CC + +note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace + +error: aborting due to 1 previous error + From f14f72eb34243ea13b0c6a1750a999352abe47fe Mon Sep 17 00:00:00 2001 From: David Carlier Date: Thu, 26 Sep 2024 19:32:36 +0100 Subject: [PATCH 21/26] implements arc4random_buf shim for freebsd/solarish platforms. close #3914 --- src/tools/miri/src/shims/unix/foreign_items.rs | 14 ++++++++++++++ src/tools/miri/tests/pass-dep/libc/libc-random.rs | 13 +++++++++++++ 2 files changed, 27 insertions(+) diff --git a/src/tools/miri/src/shims/unix/foreign_items.rs b/src/tools/miri/src/shims/unix/foreign_items.rs index c06ce57e610a0..470f13442f92d 100644 --- a/src/tools/miri/src/shims/unix/foreign_items.rs +++ b/src/tools/miri/src/shims/unix/foreign_items.rs @@ -792,6 +792,20 @@ pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> { this.gen_random(ptr, len)?; this.write_scalar(Scalar::from_target_usize(len, this), dest)?; } + "arc4random_buf" => { + // This function is non-standard but exists with the same signature and + // same behavior (eg never fails) on FreeBSD and Solaris/Illumos. + if !matches!(&*this.tcx.sess.target.os, "freebsd" | "illumos" | "solaris") { + throw_unsup_format!( + "`arc4random_buf` is not supported on {}", + this.tcx.sess.target.os + ); + } + let [ptr, len] = this.check_shim(abi, Abi::C { unwind: false}, link_name, args)?; + let ptr = this.read_pointer(ptr)?; + let len = this.read_target_usize(len)?; + this.gen_random(ptr, len)?; + } "_Unwind_RaiseException" => { // This is not formally part of POSIX, but it is very wide-spread on POSIX systems. // It was originally specified as part of the Itanium C++ ABI: diff --git a/src/tools/miri/tests/pass-dep/libc/libc-random.rs b/src/tools/miri/tests/pass-dep/libc/libc-random.rs index e951603639c3f..8f4398cbd8fe1 100644 --- a/src/tools/miri/tests/pass-dep/libc/libc-random.rs +++ b/src/tools/miri/tests/pass-dep/libc/libc-random.rs @@ -6,6 +6,8 @@ fn main() { test_getentropy(); #[cfg(not(target_os = "macos"))] test_getrandom(); + #[cfg(any(target_os = "freebsd", target_os = "illumos", target_os = "solaris"))] + test_arc4random_buf(); } fn test_getentropy() { @@ -61,3 +63,14 @@ fn test_getrandom() { ); } } + +#[cfg(any(target_os = "freebsd", target_os = "illumos", target_os = "solaris"))] +fn test_arc4random_buf() { + // FIXME: Use declaration from libc once lands. + extern "C" { + fn arc4random_buf(buf: *mut libc::c_void, size: libc::size_t); + } + let mut buf = [0u8; 5]; + unsafe { arc4random_buf(buf.as_mut_ptr() as _, buf.len()) }; + assert!(buf != [0u8; 5]); +} From 7cb5a799af4058306a989ee3d891abec2fbd5fc9 Mon Sep 17 00:00:00 2001 From: Ralf Jung Date: Sat, 28 Sep 2024 21:05:30 +0200 Subject: [PATCH 22/26] make sure the new function is tested --- src/tools/miri/ci/ci.sh | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/tools/miri/ci/ci.sh b/src/tools/miri/ci/ci.sh index 97f06dd933042..5725d6609cc7f 100755 --- a/src/tools/miri/ci/ci.sh +++ b/src/tools/miri/ci/ci.sh @@ -150,10 +150,10 @@ case $HOST_TARGET in # Partially supported targets (tier 2) BASIC="empty_main integer heap_alloc libc-mem vec string btreemap" # ensures we have the basics: pre-main code, system allocator UNIX="hello panic/panic panic/unwind concurrency/simple atomic libc-mem libc-misc libc-random env num_cpus" # the things that are very similar across all Unixes, and hence easily supported there - TEST_TARGET=x86_64-unknown-freebsd run_tests_minimal $BASIC $UNIX threadname pthread time fs - TEST_TARGET=i686-unknown-freebsd run_tests_minimal $BASIC $UNIX threadname pthread time fs - TEST_TARGET=x86_64-unknown-illumos run_tests_minimal $BASIC $UNIX thread sync available-parallelism time tls - TEST_TARGET=x86_64-pc-solaris run_tests_minimal $BASIC $UNIX thread sync available-parallelism time tls + TEST_TARGET=x86_64-unknown-freebsd run_tests_minimal $BASIC $UNIX hashmap random threadname pthread time fs + TEST_TARGET=i686-unknown-freebsd run_tests_minimal $BASIC $UNIX hashmap random threadname pthread time fs + TEST_TARGET=x86_64-unknown-illumos run_tests_minimal $BASIC $UNIX hashmap thread sync available-parallelism time tls + TEST_TARGET=x86_64-pc-solaris run_tests_minimal $BASIC $UNIX hashmap thread sync available-parallelism time tls TEST_TARGET=aarch64-linux-android run_tests_minimal $BASIC $UNIX hashmap pthread time --skip threadname TEST_TARGET=wasm32-wasip2 run_tests_minimal $BASIC wasm TEST_TARGET=wasm32-unknown-unknown run_tests_minimal no_std empty_main wasm # this target doesn't really have std From ab8fa80746a12bcd5f1c75bfbf04429fda1a9750 Mon Sep 17 00:00:00 2001 From: Ralf Jung Date: Sun, 29 Sep 2024 08:26:52 +0200 Subject: [PATCH 23/26] skip old getrandom crate on Solaris --- src/tools/miri/ci/ci.sh | 10 +++++----- src/tools/miri/tests/pass-dep/getrandom.rs | 5 +++++ 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/src/tools/miri/ci/ci.sh b/src/tools/miri/ci/ci.sh index 5725d6609cc7f..689bc6d46fc0c 100755 --- a/src/tools/miri/ci/ci.sh +++ b/src/tools/miri/ci/ci.sh @@ -150,11 +150,11 @@ case $HOST_TARGET in # Partially supported targets (tier 2) BASIC="empty_main integer heap_alloc libc-mem vec string btreemap" # ensures we have the basics: pre-main code, system allocator UNIX="hello panic/panic panic/unwind concurrency/simple atomic libc-mem libc-misc libc-random env num_cpus" # the things that are very similar across all Unixes, and hence easily supported there - TEST_TARGET=x86_64-unknown-freebsd run_tests_minimal $BASIC $UNIX hashmap random threadname pthread time fs - TEST_TARGET=i686-unknown-freebsd run_tests_minimal $BASIC $UNIX hashmap random threadname pthread time fs - TEST_TARGET=x86_64-unknown-illumos run_tests_minimal $BASIC $UNIX hashmap thread sync available-parallelism time tls - TEST_TARGET=x86_64-pc-solaris run_tests_minimal $BASIC $UNIX hashmap thread sync available-parallelism time tls - TEST_TARGET=aarch64-linux-android run_tests_minimal $BASIC $UNIX hashmap pthread time --skip threadname + TEST_TARGET=x86_64-unknown-freebsd run_tests_minimal $BASIC $UNIX time hashmap random threadname pthread fs + TEST_TARGET=i686-unknown-freebsd run_tests_minimal $BASIC $UNIX time hashmap random threadname pthread fs + TEST_TARGET=x86_64-unknown-illumos run_tests_minimal $BASIC $UNIX time hashmap random thread sync available-parallelism tls + TEST_TARGET=x86_64-pc-solaris run_tests_minimal $BASIC $UNIX time hashmap random thread sync available-parallelism tls + TEST_TARGET=aarch64-linux-android run_tests_minimal $BASIC $UNIX time hashmap pthread --skip threadname TEST_TARGET=wasm32-wasip2 run_tests_minimal $BASIC wasm TEST_TARGET=wasm32-unknown-unknown run_tests_minimal no_std empty_main wasm # this target doesn't really have std TEST_TARGET=thumbv7em-none-eabihf run_tests_minimal no_std diff --git a/src/tools/miri/tests/pass-dep/getrandom.rs b/src/tools/miri/tests/pass-dep/getrandom.rs index 53de3af76350c..a5bc5ec7079be 100644 --- a/src/tools/miri/tests/pass-dep/getrandom.rs +++ b/src/tools/miri/tests/pass-dep/getrandom.rs @@ -6,6 +6,11 @@ /// Test direct calls of getrandom 0.1 and 0.2. fn main() { let mut data = vec![0; 16]; + + // Old Solaris had a different return type for `getrandom`, and old versions of the getrandom crate + // used that signature, which Miri is not happy about. + #[cfg(not(target_os = "solaris"))] getrandom_01::getrandom(&mut data).unwrap(); + getrandom_02::getrandom(&mut data).unwrap(); } From 3e4f64c44f44aada1ed3699390f67488dfcbe9ac Mon Sep 17 00:00:00 2001 From: klensy Date: Sun, 29 Sep 2024 12:51:26 +0300 Subject: [PATCH 24/26] bump few deps --- src/tools/miri/Cargo.lock | 9 ++-- src/tools/miri/Cargo.toml | 2 +- src/tools/miri/miri-script/Cargo.lock | 74 +++++++-------------------- src/tools/miri/miri-script/Cargo.toml | 2 +- 4 files changed, 24 insertions(+), 63 deletions(-) diff --git a/src/tools/miri/Cargo.lock b/src/tools/miri/Cargo.lock index 14b719300a86e..05d1c2d1eb3e8 100644 --- a/src/tools/miri/Cargo.lock +++ b/src/tools/miri/Cargo.lock @@ -167,9 +167,9 @@ dependencies = [ [[package]] name = "chrono-tz" -version = "0.9.0" +version = "0.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "93698b29de5e97ad0ae26447b344c482a7284c737d9ddc5f9e52b74a336671bb" +checksum = "cd6dd8046d00723a59a2f8c5f295c515b9bb9a331ee4f8f3d4dd49e428acd3b6" dependencies = [ "chrono", "chrono-tz-build", @@ -178,12 +178,11 @@ dependencies = [ [[package]] name = "chrono-tz-build" -version = "0.3.0" +version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0c088aee841df9c3041febbb73934cfc39708749bf96dc827e3359cd39ef11b1" +checksum = "e94fea34d77a245229e7746bd2beb786cd2a896f306ff491fb8cecb3074b10a7" dependencies = [ "parse-zoneinfo", - "phf", "phf_codegen", ] diff --git a/src/tools/miri/Cargo.toml b/src/tools/miri/Cargo.toml index 30cea9da3732c..cb02914fd93bf 100644 --- a/src/tools/miri/Cargo.toml +++ b/src/tools/miri/Cargo.toml @@ -25,7 +25,7 @@ aes = { version = "0.8.3", features = ["hazmat"] } measureme = "11" ctrlc = "3.2.5" chrono = { version = "0.4.38", default-features = false } -chrono-tz = "0.9" +chrono-tz = "0.10" directories = "5" # Copied from `compiler/rustc/Cargo.toml`. diff --git a/src/tools/miri/miri-script/Cargo.lock b/src/tools/miri/miri-script/Cargo.lock index 8f19576c51db2..146e613c24b36 100644 --- a/src/tools/miri/miri-script/Cargo.lock +++ b/src/tools/miri/miri-script/Cargo.lock @@ -8,12 +8,6 @@ version = "1.0.80" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5ad32ce52e4161730f7098c077cd2ed6229b5804ccf99e5366be1ab72a98b4e1" -[[package]] -name = "bitflags" -version = "1.3.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" - [[package]] name = "bitflags" version = "2.4.2" @@ -112,13 +106,12 @@ checksum = "9c198f91728a82281a64e1f4f9eeb25d82cb32a5de251c6bd1b5154d63a8e7bd" [[package]] name = "libredox" -version = "0.0.1" +version = "0.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "85c833ca1e66078851dba29046874e38f08b2c883700aa29a03ddd3b23814ee8" +checksum = "c0ff37bd590ca25063e35af745c343cb7a0271906fb7b37e4813e8f79f00268d" dependencies = [ - "bitflags 2.4.2", + "bitflags", "libc", - "redox_syscall", ] [[package]] @@ -150,12 +143,6 @@ dependencies = [ "xshell", ] -[[package]] -name = "once_cell" -version = "1.19.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3fdb12b2476b595f9358c5161aa467c2438859caa136dec86c26fdd2efe17b92" - [[package]] name = "option-ext" version = "0.2.0" @@ -186,20 +173,11 @@ dependencies = [ "proc-macro2", ] -[[package]] -name = "redox_syscall" -version = "0.4.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4722d768eff46b75989dd134e5c353f0d6296e5aaa3132e776cbdb56be7731aa" -dependencies = [ - "bitflags 1.3.2", -] - [[package]] name = "redox_users" -version = "0.4.4" +version = "0.4.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a18479200779601e498ada4e8c1e1f50e3ee19deb0259c25825a98b5603b2cb4" +checksum = "ba009ff324d1fc1b900bd1fdb31564febe58a8ccc8a6fdbb93b543d33b13ca43" dependencies = [ "getrandom", "libredox", @@ -221,7 +199,7 @@ version = "0.38.34" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "70dc5ec042f7a43c4a73241207cecc9873a06d45debb38b329f8541d85c2730f" dependencies = [ - "bitflags 2.4.2", + "bitflags", "errno", "libc", "linux-raw-sys", @@ -342,47 +320,25 @@ checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423" [[package]] name = "which" -version = "4.4.2" +version = "6.0.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "87ba24419a2078cd2b0f2ede2691b6c66d8e47836da3b6db8265ebad47afbfc7" +checksum = "b4ee928febd44d98f2f459a4a79bd4d928591333a494a10a868418ac1b39cf1f" dependencies = [ "either", "home", - "once_cell", "rustix", + "winsafe", ] -[[package]] -name = "winapi" -version = "0.3.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5c839a674fcd7a98952e593242ea400abe93992746761e38641405d28b00f419" -dependencies = [ - "winapi-i686-pc-windows-gnu", - "winapi-x86_64-pc-windows-gnu", -] - -[[package]] -name = "winapi-i686-pc-windows-gnu" -version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6" - [[package]] name = "winapi-util" -version = "0.1.6" +version = "0.1.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f29e6f9198ba0d26b4c9f07dbe6f9ed633e1f3d5b8b414090084349e46a52596" +checksum = "cf221c93e13a30d793f7645a0e7762c55d169dbb0a49671918a2319d289b10bb" dependencies = [ - "winapi", + "windows-sys 0.52.0", ] -[[package]] -name = "winapi-x86_64-pc-windows-gnu" -version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" - [[package]] name = "windows-sys" version = "0.48.0" @@ -522,6 +478,12 @@ version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "589f6da84c646204747d1270a2a5661ea66ed1cced2631d546fdfb155959f9ec" +[[package]] +name = "winsafe" +version = "0.0.19" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d135d17ab770252ad95e9a872d365cf3090e3be864a34ab46f48555993efc904" + [[package]] name = "xshell" version = "0.2.6" diff --git a/src/tools/miri/miri-script/Cargo.toml b/src/tools/miri/miri-script/Cargo.toml index 2922c24d6c09c..23b9a62515920 100644 --- a/src/tools/miri/miri-script/Cargo.toml +++ b/src/tools/miri/miri-script/Cargo.toml @@ -13,7 +13,7 @@ edition = "2021" # This is needed to make this package build on stable when the parent package uses unstable cargo features. [dependencies] -which = "4.4" +which = "6.0" walkdir = "2.3" itertools = "0.11" path_macro = "1.0" From ad8a5ce4cae159b8c9703be969cfe17c877e38f5 Mon Sep 17 00:00:00 2001 From: Ralf Jung Date: Sun, 29 Sep 2024 18:51:03 +0200 Subject: [PATCH 25/26] let rustfmt format imports --- .../bench-cargo-miri/backtraces/src/main.rs | 3 +- .../miri/bench-cargo-miri/serde2/src/main.rs | 3 +- src/tools/miri/cargo-miri/src/phases.rs | 3 +- src/tools/miri/miri-script/src/args.rs | 3 +- src/tools/miri/miri-script/src/commands.rs | 7 +--- src/tools/miri/rustfmt.toml | 7 +++- src/tools/miri/src/alloc_addresses/mod.rs | 5 +-- .../miri/src/alloc_addresses/reuse_pool.rs | 4 +- src/tools/miri/src/alloc_bytes.rs | 3 +- src/tools/miri/src/bin/miri.rs | 22 ++++------ src/tools/miri/src/borrow_tracker/mod.rs | 3 +- .../stacked_borrows/diagnostics.rs | 2 +- .../src/borrow_tracker/stacked_borrows/mod.rs | 19 ++++----- .../borrow_tracker/stacked_borrows/stack.rs | 6 +-- .../tree_borrows/diagnostics.rs | 8 ++-- .../src/borrow_tracker/tree_borrows/mod.rs | 13 +++--- .../src/borrow_tracker/tree_borrows/tree.rs | 13 +++--- .../borrow_tracker/tree_borrows/tree/tests.rs | 3 +- .../src/borrow_tracker/tree_borrows/unimap.rs | 3 +- src/tools/miri/src/concurrency/data_race.rs | 21 ++++------ .../miri/src/concurrency/range_object_map.rs | 2 +- src/tools/miri/src/concurrency/sync.rs | 3 +- src/tools/miri/src/concurrency/thread.rs | 1 - .../miri/src/concurrency/vector_clock.rs | 15 +++---- src/tools/miri/src/concurrency/weak_memory.rs | 15 +++---- src/tools/miri/src/eval.rs | 16 +++---- src/tools/miri/src/helpers.rs | 19 +++------ src/tools/miri/src/intrinsics/atomic.rs | 3 +- src/tools/miri/src/intrinsics/mod.rs | 6 +-- src/tools/miri/src/intrinsics/simd.rs | 4 +- src/tools/miri/src/lib.rs | 42 +++++++++---------- src/tools/miri/src/machine.rs | 31 +++++--------- src/tools/miri/src/operator.rs | 3 +- src/tools/miri/src/provenance_gc.rs | 1 - src/tools/miri/src/shims/backtrace.rs | 6 ++- src/tools/miri/src/shims/env.rs | 3 +- src/tools/miri/src/shims/foreign_items.rs | 17 ++++---- src/tools/miri/src/shims/native_lib.rs | 3 +- src/tools/miri/src/shims/os_str.rs | 3 +- src/tools/miri/src/shims/unix/env.rs | 3 +- src/tools/miri/src/shims/unix/fd.rs | 3 +- .../miri/src/shims/unix/foreign_items.rs | 9 ++-- src/tools/miri/src/shims/unix/fs.rs | 15 +++---- .../miri/src/shims/unix/linux/eventfd.rs | 3 +- .../src/shims/unix/linux/foreign_items.rs | 3 +- src/tools/miri/src/shims/unix/linux/mem.rs | 3 +- src/tools/miri/src/shims/unix/mem.rs | 3 +- src/tools/miri/src/shims/unix/mod.rs | 11 ++--- src/tools/miri/src/shims/unix/thread.rs | 3 +- .../miri/src/shims/unix/unnamed_socket.rs | 3 +- .../miri/src/shims/windows/foreign_items.rs | 4 +- src/tools/miri/src/shims/windows/handle.rs | 3 +- src/tools/miri/src/shims/windows/mod.rs | 3 +- src/tools/miri/src/shims/x86/avx.rs | 2 +- src/tools/miri/src/shims/x86/mod.rs | 4 +- src/tools/miri/test-cargo-miri/src/main.rs | 3 +- .../miri/test-cargo-miri/subcrate/test.rs | 1 - .../concurrency/libc_pthread_join_multiple.rs | 3 +- .../miri/tests/fail-dep/libc/affinity.rs | 4 +- .../fail-dep/libc/env-set_var-data-race.rs | 3 +- .../miri/tests/fail/coroutine-pinned-moved.rs | 6 +-- .../data_race/atomic_read_na_write_race2.rs | 3 +- .../data_race/atomic_write_na_read_race1.rs | 3 +- .../data_race/atomic_write_na_write_race2.rs | 3 +- .../fail/tree_borrows/children-can-alias.rs | 3 +- .../tests/pass-dep/concurrency/linux-futex.rs | 3 +- .../concurrency/tls_pthread_drop_order.rs | 3 +- src/tools/miri/tests/pass-dep/libc/gettid.rs | 3 +- .../miri/tests/pass-dep/libc/libc-affinity.rs | 3 +- .../miri/tests/pass-dep/libc/libc-fs-flock.rs | 4 +- src/tools/miri/tests/pass-dep/libc/libc-fs.rs | 3 +- .../miri/tests/pass-dep/tokio/file-io.rs | 1 + .../miri/tests/pass/async-niche-aliasing.rs | 12 +++--- ...atomic-compare-exchange-weak-never-fail.rs | 3 +- src/tools/miri/tests/pass/atomic.rs | 5 +-- .../tests/pass/box-custom-alloc-aliasing.rs | 12 +++--- src/tools/miri/tests/pass/box-custom-alloc.rs | 3 +- .../address_reuse_happens_before.rs | 3 +- .../pass/concurrency/sync_singlethread.rs | 3 +- src/tools/miri/tests/pass/coroutine.rs | 6 +-- .../miri/tests/pass/dyn-arbitrary-self.rs | 10 ++--- .../tests/pass/function_calls/abi_compat.rs | 4 +- .../tests/pass/intrinsics/portable-simd.rs | 3 +- ...iri-3541-dyn-vtable-trait-normalization.rs | 3 +- src/tools/miri/tests/pass/leak-in-static.rs | 6 +-- src/tools/miri/tests/pass/ptr_int_casts.rs | 3 +- src/tools/miri/tests/pass/shims/env/var.rs | 3 +- .../tests/pass/shims/windows-threadname.rs | 3 +- src/tools/miri/tests/pass/slices.rs | 3 +- .../coroutine-self-referential.rs | 6 +-- .../pass/stacked-borrows/stack-printing.rs | 6 +-- .../tests/pass/tree_borrows/tree-borrows.rs | 3 +- src/tools/miri/tests/ui.rs | 3 +- 93 files changed, 255 insertions(+), 319 deletions(-) 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 eba51c60dbc5b..b1a58712becb6 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 83c04b9dd5f57..8842d4ce31077 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 e13ecbbe54ba5..52bc8e1a3b6d7 100644 --- a/src/tools/miri/cargo-miri/src/phases.rs +++ b/src/tools/miri/cargo-miri/src/phases.rs @@ -8,7 +8,8 @@ use std::{env, thread}; 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 c1688ca0fb6b2..55d9de4233d9b 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 b0e62d5cda6f0..36175c8dd2bd2 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 3f9311d9d1a50..49650d8486c40 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 c19a962e6523e..f71edafb4b2ad 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::cell::RefCell; 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 f6c1675634460..b5366d5ce929c 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 84225d83b6aec..6ada8c66fde69 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 14f43f576d3a4..8d3ae97e0e9fa 100644 --- a/src/tools/miri/src/bin/miri.rs +++ b/src/tools/miri/src/bin/miri.rs @@ -28,31 +28,27 @@ use std::num::NonZero; 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 9e205cd0064aa..89fd8c28af2ae 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::cell::RefCell; 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 12eeaae0eff47..146f9902f6fe0 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 7eb6773038388..b270e484bdba4 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 item; 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 5c040983142f8..6b5ef7d59c554 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 rustc_data_structures::fx::FxHashSet; 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 44ea7533b00cb..af9ec129c69f7 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_data_structures::fx::FxHashMap; use rustc_span::{Span, SpanData}; use crate::borrow_tracker::ProtectorKind; -use crate::borrow_tracker::tree_borrows::{ - perms::{PermTransition, Permission}, - tree::LocationState, - unimap::UniIndex, -}; +use crate::borrow_tracker::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 2afe02dc2c7f8..30e940b4439a4 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 a99c71d96b4b1..9fe134ed34bc9 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 5cd5040f80776..5d51a72852ca9 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 cbc25724cb685..7874721c0ac37 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 b5b43f589f699..8ee039b6ddc89 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 859eb4bbb60d2..d36ed36ac1a6c 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 2b34db047f379..7fe67e5c6727e 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 681e9211246dd..f6b453efcbeb7 100644 --- a/src/tools/miri/src/concurrency/thread.rs +++ b/src/tools/miri/src/concurrency/thread.rs @@ -7,7 +7,6 @@ use std::task::Poll; 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 901b097c1bd77..f9025e06c684e 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 @@ impl Index for VClock { /// 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 0605b744e6afd..307695436c61e 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 8c8ed9c4ddc3b..3739d46bd60f0 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_target::spec::abi::Abi; - +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 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 10e5882b5ba89..0cd6ba69aac9d 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 f38c3b821742a..b6fd9ba1e825c 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 d8d267f5ba693..23ce2f8ed1f91 100644 --- a/src/tools/miri/src/intrinsics/mod.rs +++ b/src/tools/miri/src/intrinsics/mod.rs @@ -5,10 +5,8 @@ mod simd; 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 2bc11d63a3951..802a70e5a54aa 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 4d0606113f9ea..78e7bf704552d 100644 --- a/src/tools/miri/src/lib.rs +++ b/src/tools/miri/src/lib.rs @@ -92,15 +92,14 @@ mod range_map; 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 OpTy<'tcx> = interpret::OpTy<'tcx, machine::Provenance>; 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::stacked_borrows::{ 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 @@ pub use crate::eval::{ 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::mono_hash_map::MonoHashMap; 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 b93feeeee3365..fb5ccbcd4fe22 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 1b6a7255eefbe..6b8c0fe87adb3 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 d4bed69c6707a..c5a35bc14f591 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 edff17c0514ce..1d20189b6fd8f 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 c465ef3d28bc8..557d648682c7c 100644 --- a/src/tools/miri/src/shims/env.rs +++ b/src/tools/miri/src/shims/env.rs @@ -2,7 +2,8 @@ use std::ffi::{OsStr, OsString}; 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 c0484dde59b5b..6a835098e6048 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 e4998c37f3fe6..2b5acee244cba 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 a1be2ae8b588b..17c451059208f 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 324607cc1eda3..184a6c238b392 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 5fae746af2b63..6bd753d0d6bee 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::any::Any; 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 470f13442f92d..528d068ea92c0 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_span::Symbol; 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 1b657db5cccc0..92514b67beab1 100644 --- a/src/tools/miri/src/shims/unix/fs.rs +++ b/src/tools/miri/src/shims/unix/fs.rs @@ -11,14 +11,13 @@ use std::time::SystemTime; 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 @@ impl FileDescription for FileHandle { #[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 9fbabbd964180..ab7652ca721ca 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::cell::{Cell, RefCell}; 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 07527a9d6e332..e2e76aad7cd6e 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::epoll::EvalContextExt as _; 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 3b32612e8baf0..b11f60048a070 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 33ed0e2698226..0397ba3b91ad9 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 a95b4d3d30793..9bc310e8d0a5d 100644 --- a/src/tools/miri/src/shims/unix/mod.rs +++ b/src/tools/miri/src/shims/unix/mod.rs @@ -14,14 +14,11 @@ mod linux; 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 56e8270aa62ac..96af4ae51efaa 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 db6872319ea48..d1bfa563387dd 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 std::io::{Error, ErrorKind, Read}; 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 cd8f3e59015a3..22634c509bed0 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 ec461a4cd3681..0a8e0e8fdfb75 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 537c724e52665..892bd6924fc93 100644 --- a/src/tools/miri/src/shims/windows/mod.rs +++ b/src/tools/miri/src/shims/windows/mod.rs @@ -5,9 +5,8 @@ mod handle; 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 bdc4fc9446915..169f8f8111adb 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 211bd168af28b..8132de7d64697 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 d171ec1c0d1c4..efe95bf3abab7 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 b60cf20339b77..e663643f20b42 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 6a49625d75d60..b2a398e0a198e 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 d7d5c59e1bc17..09f096e46f1e6 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 c7d8bacd37950..3a832bb0ce0c1 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 46ec58810a62d..abed638e44359 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 8bceba9380adf..c67ce65eb3404 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 1a2746a26f4d8..5e328740e8517 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 b494bd3a003d3..fdc0f9e20f079 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 036267dc11e9d..d3f272dfbf81d 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 255a93226a958..20e642a0a2952 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 2dc09709b8eed..b57386000404f 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 ca352e0109a47..51f1a5ed70898 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 ff152eaea5c50..8aa8c7dcb8e6a 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 be11f65a1e081..99d6d2b38f8de 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 17e6e507c2750..f85abe2cc4377 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 14c27285a6ae5..6e88b907f5dc8 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 ab82c929a94c2..fe4ddd9d80088 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 8d3d71869f42e..0a236377a9c61 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 781cc9bd30942..f84fe825d0106 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 a1371242f60d9..0a61db960c1d4 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 8d6da0733fe17..71ce019187c44 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 cfc1ef7ae455a..255f4061abce7 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 5663e1c1426c9..e52dbd3186e1e 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 7822c136d91b6..9ec9b1fc5bc48 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 dc2b9e4491b27..d993e5ad68ccc 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 pin_box_dyn() { } 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 stdlib_pointers() { } 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 0cfcd532ff4b2..b5feac8c67726 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 cd606a5282a98..f560669dd6351 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 c46031de2d84f..123fe6ed6425c 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 9523394408806..6f08b64ada45f 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 684e8f6ec7bdd..4e274f62981d1 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 a576c1fc8bb8c..655b29674e340 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 29c3fa5d5f3aa..f1c05fa37905b 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 459d04d6761c1..39e1d1cb97f26 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 259fc72d3929e..72e360fe19a1f 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 9c9db4d1b3b53..1478b21d6c180 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 c741e4de6d5b1..b9d5ca06ed058 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 2430140eea1d4..9553a37c9a82f 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; From 8c0adc6716ff1c5b1ef3de0e8972d45cb1053b27 Mon Sep 17 00:00:00 2001 From: Ralf Jung Date: Sun, 29 Sep 2024 23:08:25 +0200 Subject: [PATCH 26/26] update lockfile --- Cargo.lock | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 5e9808c806884..7a9701a9cad53 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -432,9 +432,9 @@ dependencies = [ [[package]] name = "chrono-tz" -version = "0.9.0" +version = "0.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "93698b29de5e97ad0ae26447b344c482a7284c737d9ddc5f9e52b74a336671bb" +checksum = "cd6dd8046d00723a59a2f8c5f295c515b9bb9a331ee4f8f3d4dd49e428acd3b6" dependencies = [ "chrono", "chrono-tz-build", @@ -443,12 +443,11 @@ dependencies = [ [[package]] name = "chrono-tz-build" -version = "0.3.0" +version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0c088aee841df9c3041febbb73934cfc39708749bf96dc827e3359cd39ef11b1" +checksum = "e94fea34d77a245229e7746bd2beb786cd2a896f306ff491fb8cecb3074b10a7" dependencies = [ "parse-zoneinfo", - "phf", "phf_codegen", ] @@ -3119,9 +3118,9 @@ dependencies = [ [[package]] name = "rustc-build-sysroot" -version = "0.5.3" +version = "0.5.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2471f8f296262437d7e848e527b4210b44a96e53a3b4435b890227ce3e6da106" +checksum = "d6d984a9db43148467059309bd1e5ad577085162f695d9fe2cf3543aeb25cd38" dependencies = [ "anyhow", "rustc_version",