From 3bd56711a604b151156eb8cab9c9eda189afe28e Mon Sep 17 00:00:00 2001 From: Ralf Jung Date: Tue, 28 May 2024 18:13:09 +0200 Subject: [PATCH] fix unclear_local_imports in Miri --- .../src/borrow_tracker/stacked_borrows/mod.rs | 6 +++--- .../tree_borrows/diagnostics.rs | 2 +- .../src/borrow_tracker/tree_borrows/mod.rs | 4 ++-- .../src/borrow_tracker/tree_borrows/perms.rs | 2 +- .../src/borrow_tracker/tree_borrows/tree.rs | 2 +- src/tools/miri/src/concurrency/data_race.rs | 2 +- src/tools/miri/src/concurrency/mod.rs | 2 +- src/tools/miri/src/diagnostics.rs | 6 +++--- src/tools/miri/src/eval.rs | 2 +- src/tools/miri/src/intrinsics/atomic.rs | 2 +- src/tools/miri/src/intrinsics/mod.rs | 6 +++--- src/tools/miri/src/lib.rs | 1 + src/tools/miri/src/shims/env.rs | 2 +- src/tools/miri/src/shims/foreign_items.rs | 2 +- src/tools/miri/src/shims/mod.rs | 2 +- src/tools/miri/src/shims/panic.rs | 2 +- src/tools/miri/src/shims/tls.rs | 2 +- .../miri/src/shims/unix/foreign_items.rs | 10 +++++----- src/tools/miri/src/shims/unix/fs.rs | 2 +- .../src/shims/unix/linux/foreign_items.rs | 8 ++++---- src/tools/miri/src/shims/unix/mod.rs | 20 +++++++++---------- src/tools/miri/src/shims/windows/env.rs | 2 +- .../miri/src/shims/windows/foreign_items.rs | 2 +- src/tools/miri/src/shims/windows/mod.rs | 10 +++++----- src/tools/miri/src/shims/windows/thread.rs | 2 +- src/tools/miri/src/shims/x86/mod.rs | 2 +- 26 files changed, 53 insertions(+), 52 deletions(-) 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 2786668695e27..b59e5bb4fd319 100644 --- a/src/tools/miri/src/borrow_tracker/stacked_borrows/mod.rs +++ b/src/tools/miri/src/borrow_tracker/stacked_borrows/mod.rs @@ -21,9 +21,9 @@ use crate::borrow_tracker::{ use crate::concurrency::data_race::{NaReadType, NaWriteType}; use crate::*; -use diagnostics::{RetagCause, RetagInfo}; -pub use item::{Item, Permission}; -pub use stack::Stack; +use self::diagnostics::{RetagCause, RetagInfo}; +pub use self::item::{Item, Permission}; +pub use self::stack::Stack; pub type AllocState = Stacks; 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 8abc8530f7c46..d21de0cb96077 100644 --- a/src/tools/miri/src/borrow_tracker/tree_borrows/diagnostics.rs +++ b/src/tools/miri/src/borrow_tracker/tree_borrows/diagnostics.rs @@ -297,7 +297,7 @@ pub(super) struct TbError<'node> { impl TbError<'_> { /// Produce a UB error. pub fn build<'tcx>(self) -> InterpError<'tcx> { - use TransitionError::*; + use self::TransitionError::*; let cause = self.access_cause; let accessed = self.accessed_info; let conflicting = self.conflicting_info; 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 e1c06b2bd98e5..913e96a140824 100644 --- a/src/tools/miri/src/borrow_tracker/tree_borrows/mod.rs +++ b/src/tools/miri/src/borrow_tracker/tree_borrows/mod.rs @@ -23,8 +23,8 @@ mod unimap; #[cfg(test)] mod exhaustive; -use perms::Permission; -pub use tree::Tree; +use self::perms::Permission; +pub use self::tree::Tree; pub type AllocState = Tree; diff --git a/src/tools/miri/src/borrow_tracker/tree_borrows/perms.rs b/src/tools/miri/src/borrow_tracker/tree_borrows/perms.rs index fb3a4c8dad91c..9e49ceb5ab8f4 100644 --- a/src/tools/miri/src/borrow_tracker/tree_borrows/perms.rs +++ b/src/tools/miri/src/borrow_tracker/tree_borrows/perms.rs @@ -36,7 +36,7 @@ enum PermissionPriv { /// rejects: all child accesses (UB). Disabled, } -use PermissionPriv::*; +use self::PermissionPriv::*; impl PartialOrd for PermissionPriv { /// PermissionPriv is ordered by the reflexive transitive closure of 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 ff4589657aff2..f72e49989d7bc 100644 --- a/src/tools/miri/src/borrow_tracker/tree_borrows/tree.rs +++ b/src/tools/miri/src/borrow_tracker/tree_borrows/tree.rs @@ -793,7 +793,7 @@ impl AccessRelatedness { /// for the child node. This function assumes that we propagate away from the initial /// access. pub fn for_child(self) -> Self { - use AccessRelatedness::*; + use self::AccessRelatedness::*; match self { AncestorAccess | This => AncestorAccess, StrictChildAccess | DistantAccess => DistantAccess, diff --git a/src/tools/miri/src/concurrency/data_race.rs b/src/tools/miri/src/concurrency/data_race.rs index 719c262290ef2..25c9d9c563c1d 100644 --- a/src/tools/miri/src/concurrency/data_race.rs +++ b/src/tools/miri/src/concurrency/data_race.rs @@ -1266,7 +1266,7 @@ trait EvalContextPrivExt<'tcx>: MiriInterpCxExt<'tcx> { place: &MPlaceTy<'tcx, Provenance>, atomic: AtomicRwOrd, ) -> InterpResult<'tcx> { - use AtomicRwOrd::*; + use self::AtomicRwOrd::*; let acquire = matches!(atomic, Acquire | AcqRel | SeqCst); let release = matches!(atomic, Release | AcqRel | SeqCst); let this = self.eval_context_mut(); diff --git a/src/tools/miri/src/concurrency/mod.rs b/src/tools/miri/src/concurrency/mod.rs index 15e1a94d6db0e..d5b15901bc155 100644 --- a/src/tools/miri/src/concurrency/mod.rs +++ b/src/tools/miri/src/concurrency/mod.rs @@ -7,4 +7,4 @@ pub mod thread; mod vector_clock; pub mod weak_memory; -pub use vector_clock::VClock; +pub use self::vector_clock::VClock; diff --git a/src/tools/miri/src/diagnostics.rs b/src/tools/miri/src/diagnostics.rs index d55f21d74efc8..0bbef71d77f16 100644 --- a/src/tools/miri/src/diagnostics.rs +++ b/src/tools/miri/src/diagnostics.rs @@ -59,7 +59,7 @@ pub struct RacingOp { impl fmt::Display for TerminationInfo { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { - use TerminationInfo::*; + use self::TerminationInfo::*; match self { Exit { code, .. } => write!(f, "the evaluated program completed with exit code {code}"), Abort(msg) => write!(f, "{msg}"), @@ -212,7 +212,7 @@ pub fn report_error<'tcx>( let (title, helps) = if let MachineStop(info) = e.kind() { let info = info.downcast_ref::().expect("invalid MachineStop payload"); - use TerminationInfo::*; + use self::TerminationInfo::*; let title = match info { Exit { code, leak_check } => return Some((*code, *leak_check)), Abort(_) => Some("abnormal termination"), @@ -579,7 +579,7 @@ pub fn report_msg<'tcx>( impl<'tcx> MiriMachine<'tcx> { pub fn emit_diagnostic(&self, e: NonHaltingDiagnostic) { - use NonHaltingDiagnostic::*; + use self::NonHaltingDiagnostic::*; let stacktrace = Frame::generate_stacktrace_from_stack(self.threads.active_thread_stack()); let (stacktrace, _was_pruned) = prune_stacktrace(stacktrace, self); diff --git a/src/tools/miri/src/eval.rs b/src/tools/miri/src/eval.rs index 35f7f43f123f1..68bd8080db300 100644 --- a/src/tools/miri/src/eval.rs +++ b/src/tools/miri/src/eval.rs @@ -216,7 +216,7 @@ impl<'tcx> MainThreadState<'tcx> { &mut self, this: &mut MiriInterpCx<'tcx>, ) -> InterpResult<'tcx, Poll<()>> { - use MainThreadState::*; + use self::MainThreadState::*; match self { Running => { *self = TlsDtors(Default::default()); diff --git a/src/tools/miri/src/intrinsics/atomic.rs b/src/tools/miri/src/intrinsics/atomic.rs index 17f95df9aa150..c60f8fd6dff44 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 helpers::check_arg_count; +use self::helpers::check_arg_count; 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 e39b78d3816f7..7135a6eb53373 100644 --- a/src/tools/miri/src/intrinsics/mod.rs +++ b/src/tools/miri/src/intrinsics/mod.rs @@ -14,9 +14,9 @@ use rustc_span::{sym, Symbol}; use rustc_target::abi::Size; use crate::*; -use atomic::EvalContextExt as _; -use helpers::{check_arg_count, ToHost, ToSoft}; -use simd::EvalContextExt as _; +use self::atomic::EvalContextExt as _; +use self::helpers::{check_arg_count, ToHost, ToSoft}; +use self::simd::EvalContextExt as _; impl<'tcx> EvalContextExt<'tcx> for crate::MiriInterpCx<'tcx> {} pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> { diff --git a/src/tools/miri/src/lib.rs b/src/tools/miri/src/lib.rs index 2fa88b6a24619..759b5debe2bd8 100644 --- a/src/tools/miri/src/lib.rs +++ b/src/tools/miri/src/lib.rs @@ -48,6 +48,7 @@ clippy::cast_lossless, clippy::cast_possible_truncation, )] +#![cfg_attr(not(bootstrap), warn(unclear_local_imports))] // Needed for rustdoc from bootstrap (with `-Znormalize-docs`). #![recursion_limit = "256"] diff --git a/src/tools/miri/src/shims/env.rs b/src/tools/miri/src/shims/env.rs index 7ad395cccb799..a73524166cdf5 100644 --- a/src/tools/miri/src/shims/env.rs +++ b/src/tools/miri/src/shims/env.rs @@ -3,7 +3,7 @@ use std::ffi::{OsStr, OsString}; use rustc_data_structures::fx::FxHashMap; use crate::*; -use shims::{unix::UnixEnvVars, windows::WindowsEnvVars}; +use self::shims::{unix::UnixEnvVars, windows::WindowsEnvVars}; #[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 6dfd9866cae97..64bf612745dfc 100644 --- a/src/tools/miri/src/shims/foreign_items.rs +++ b/src/tools/miri/src/shims/foreign_items.rs @@ -15,7 +15,7 @@ use rustc_target::{ use super::alloc::{check_alloc_request, EvalContextExt as _}; use super::backtrace::EvalContextExt as _; use crate::*; -use helpers::{ToHost, ToSoft}; +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/mod.rs b/src/tools/miri/src/shims/mod.rs index a41a2883c9153..c56699bf23949 100644 --- a/src/tools/miri/src/shims/mod.rs +++ b/src/tools/miri/src/shims/mod.rs @@ -17,7 +17,7 @@ pub mod panic; pub mod time; pub mod tls; -pub use unix::{DirTable, FdTable}; +pub use self::unix::{DirTable, FdTable}; /// What needs to be done after emulating an item (a shim or an intrinsic) is done. pub enum EmulateItemResult { diff --git a/src/tools/miri/src/shims/panic.rs b/src/tools/miri/src/shims/panic.rs index 8aed6d4f463fa..37a4b9a84e319 100644 --- a/src/tools/miri/src/shims/panic.rs +++ b/src/tools/miri/src/shims/panic.rs @@ -17,7 +17,7 @@ use rustc_target::spec::abi::Abi; use rustc_target::spec::PanicStrategy; use crate::*; -use helpers::check_arg_count; +use self::helpers::check_arg_count; /// Holds all of the relevant data for when unwinding hits a `try` frame. #[derive(Debug)] diff --git a/src/tools/miri/src/shims/tls.rs b/src/tools/miri/src/shims/tls.rs index fa52b036ce948..2d0ecb976c901 100644 --- a/src/tools/miri/src/shims/tls.rs +++ b/src/tools/miri/src/shims/tls.rs @@ -237,7 +237,7 @@ impl<'tcx> TlsDtorsState<'tcx> { &mut self, this: &mut MiriInterpCx<'tcx>, ) -> InterpResult<'tcx, Poll<()>> { - use TlsDtorsStatePriv::*; + use self::TlsDtorsStatePriv::*; let new_state = 'new_state: { match &mut self.0 { Init => { diff --git a/src/tools/miri/src/shims/unix/foreign_items.rs b/src/tools/miri/src/shims/unix/foreign_items.rs index 052715e239f23..c065c0a357ff9 100644 --- a/src/tools/miri/src/shims/unix/foreign_items.rs +++ b/src/tools/miri/src/shims/unix/foreign_items.rs @@ -9,11 +9,11 @@ use crate::shims::alloc::EvalContextExt as _; use crate::shims::unix::*; use crate::*; -use shims::unix::android::foreign_items as android; -use shims::unix::freebsd::foreign_items as freebsd; -use shims::unix::linux::foreign_items as linux; -use shims::unix::macos::foreign_items as macos; -use shims::unix::solarish::foreign_items as solarish; +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; 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 8e3d547b0750c..28f7bdb0ba13b 100644 --- a/src/tools/miri/src/shims/unix/fs.rs +++ b/src/tools/miri/src/shims/unix/fs.rs @@ -14,7 +14,7 @@ use rustc_target::abi::Size; use crate::shims::os_str::bytes_to_os_str; use crate::shims::unix::*; use crate::*; -use shims::time::system_time_to_duration; +use self::shims::time::system_time_to_duration; use self::fd::FileDescriptor; 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 7d0c8be1eaa08..4263944dbc50f 100644 --- a/src/tools/miri/src/shims/unix/linux/foreign_items.rs +++ b/src/tools/miri/src/shims/unix/linux/foreign_items.rs @@ -5,10 +5,10 @@ use crate::machine::SIGRTMAX; use crate::machine::SIGRTMIN; use crate::shims::unix::*; use crate::*; -use shims::unix::linux::epoll::EvalContextExt as _; -use shims::unix::linux::eventfd::EvalContextExt as _; -use shims::unix::linux::mem::EvalContextExt as _; -use shims::unix::linux::sync::futex; +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; pub fn is_dyn_sym(name: &str) -> bool { matches!(name, "statx") diff --git a/src/tools/miri/src/shims/unix/mod.rs b/src/tools/miri/src/shims/unix/mod.rs index dc9068fddde1e..16e436b29ab9f 100644 --- a/src/tools/miri/src/shims/unix/mod.rs +++ b/src/tools/miri/src/shims/unix/mod.rs @@ -14,17 +14,17 @@ mod linux; mod macos; mod solarish; -pub use env::UnixEnvVars; -pub use fd::{FdTable, FileDescription}; -pub use fs::DirTable; +pub use self::env::UnixEnvVars; +pub use self::fd::{FdTable, FileDescription}; +pub use self::fs::DirTable; // All the Unix-specific extension traits -pub use env::EvalContextExt as _; -pub use fd::EvalContextExt as _; -pub use fs::EvalContextExt as _; -pub use mem::EvalContextExt as _; -pub use socket::EvalContextExt as _; -pub use sync::EvalContextExt as _; -pub use thread::EvalContextExt as _; +pub use self::env::EvalContextExt as _; +pub use self::fd::EvalContextExt as _; +pub use self::fs::EvalContextExt as _; +pub use self::mem::EvalContextExt as _; +pub use self::socket::EvalContextExt as _; +pub use self::sync::EvalContextExt as _; +pub use self::thread::EvalContextExt as _; // Make up some constants. const UID: u32 = 1000; diff --git a/src/tools/miri/src/shims/windows/env.rs b/src/tools/miri/src/shims/windows/env.rs index 488a05366d238..dad4c257af57e 100644 --- a/src/tools/miri/src/shims/windows/env.rs +++ b/src/tools/miri/src/shims/windows/env.rs @@ -5,7 +5,7 @@ use std::io::ErrorKind; use rustc_data_structures::fx::FxHashMap; use crate::*; -use helpers::windows_check_buffer_size; +use self::helpers::windows_check_buffer_size; #[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 a60c2a337cfc5..2209658deae0f 100644 --- a/src/tools/miri/src/shims/windows/foreign_items.rs +++ b/src/tools/miri/src/shims/windows/foreign_items.rs @@ -11,7 +11,7 @@ use rustc_target::spec::abi::Abi; use crate::shims::os_str::bytes_to_os_str; use crate::shims::windows::*; use crate::*; -use shims::windows::handle::{Handle, PseudoHandle}; +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/mod.rs b/src/tools/miri/src/shims/windows/mod.rs index 65f682b9dad9a..537c724e52665 100644 --- a/src/tools/miri/src/shims/windows/mod.rs +++ b/src/tools/miri/src/shims/windows/mod.rs @@ -5,9 +5,9 @@ mod handle; mod sync; mod thread; -pub use env::WindowsEnvVars; +pub use self::env::WindowsEnvVars; // All the Windows-specific extension traits -pub use env::EvalContextExt as _; -pub use handle::EvalContextExt as _; -pub use sync::EvalContextExt as _; -pub use thread::EvalContextExt as _; +pub use self::env::EvalContextExt as _; +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/windows/thread.rs b/src/tools/miri/src/shims/windows/thread.rs index a9ef03d14ae4f..ed87c5ba41112 100644 --- a/src/tools/miri/src/shims/windows/thread.rs +++ b/src/tools/miri/src/shims/windows/thread.rs @@ -2,7 +2,7 @@ use rustc_middle::ty::layout::LayoutOf; use rustc_target::spec::abi::Abi; use crate::*; -use shims::windows::handle::{EvalContextExt as _, Handle, PseudoHandle}; +use self::shims::windows::handle::{EvalContextExt as _, Handle, PseudoHandle}; 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 b5951e9e895bb..2353b7c326825 100644 --- a/src/tools/miri/src/shims/x86/mod.rs +++ b/src/tools/miri/src/shims/x86/mod.rs @@ -9,7 +9,7 @@ use rustc_target::abi::Size; use rustc_target::spec::abi::Abi; use crate::*; -use helpers::bool_to_simd_element; +use self::helpers::bool_to_simd_element; mod aesni; mod avx;