diff options
| author | Nicholas Nethercote <n.nethercote@gmail.com> | 2024-07-29 08:13:50 +1000 |
|---|---|---|
| committer | Nicholas Nethercote <n.nethercote@gmail.com> | 2024-07-29 08:26:52 +1000 |
| commit | 84ac80f1921afc243d71fd0caaa4f2838c294102 (patch) | |
| tree | 29006db815bf547dfd0129910b23b8c54675bd98 /compiler/rustc_data_structures | |
| parent | 118f9350c5b902e462a6dcc4325670f3da701600 (diff) | |
| download | rust-84ac80f1921afc243d71fd0caaa4f2838c294102.tar.gz rust-84ac80f1921afc243d71fd0caaa4f2838c294102.zip | |
Reformat `use` declarations.
The previous commit updated `rustfmt.toml` appropriately. This commit is the outcome of running `x fmt --all` with the new formatting options.
Diffstat (limited to 'compiler/rustc_data_structures')
45 files changed, 158 insertions, 144 deletions
diff --git a/compiler/rustc_data_structures/src/base_n.rs b/compiler/rustc_data_structures/src/base_n.rs index 80810df14d0..1c2321623e4 100644 --- a/compiler/rustc_data_structures/src/base_n.rs +++ b/compiler/rustc_data_structures/src/base_n.rs @@ -1,8 +1,7 @@ //! Converts unsigned integers into a string representation with some base. //! Bases up to and including 36 can be used for case-insensitive things. -use std::ascii; -use std::fmt; +use std::{ascii, fmt}; #[cfg(test)] mod tests; diff --git a/compiler/rustc_data_structures/src/fingerprint.rs b/compiler/rustc_data_structures/src/fingerprint.rs index 30e3d6aa86c..efc56dc9337 100644 --- a/compiler/rustc_data_structures/src/fingerprint.rs +++ b/compiler/rustc_data_structures/src/fingerprint.rs @@ -1,8 +1,11 @@ -use crate::stable_hasher::impl_stable_traits_for_trivial_type; -use crate::stable_hasher::{FromStableHash, Hash64, StableHasherHash}; -use rustc_serialize::{Decodable, Decoder, Encodable, Encoder}; use std::hash::{Hash, Hasher}; +use rustc_serialize::{Decodable, Decoder, Encodable, Encoder}; + +use crate::stable_hasher::{ + impl_stable_traits_for_trivial_type, FromStableHash, Hash64, StableHasherHash, +}; + #[cfg(test)] mod tests; diff --git a/compiler/rustc_data_structures/src/flat_map_in_place.rs b/compiler/rustc_data_structures/src/flat_map_in_place.rs index f58844f2817..e66b00b7557 100644 --- a/compiler/rustc_data_structures/src/flat_map_in_place.rs +++ b/compiler/rustc_data_structures/src/flat_map_in_place.rs @@ -1,5 +1,6 @@ -use smallvec::{Array, SmallVec}; use std::ptr; + +use smallvec::{Array, SmallVec}; use thin_vec::ThinVec; pub trait FlatMapInPlace<T>: Sized { diff --git a/compiler/rustc_data_structures/src/flock/unix.rs b/compiler/rustc_data_structures/src/flock/unix.rs index eff9e8f838f..12b8b41210d 100644 --- a/compiler/rustc_data_structures/src/flock/unix.rs +++ b/compiler/rustc_data_structures/src/flock/unix.rs @@ -1,8 +1,7 @@ use std::fs::{File, OpenOptions}; -use std::io; -use std::mem; use std::os::unix::prelude::*; use std::path::Path; +use std::{io, mem}; #[derive(Debug)] pub struct Lock { diff --git a/compiler/rustc_data_structures/src/flock/windows.rs b/compiler/rustc_data_structures/src/flock/windows.rs index 7dc72661939..0d76df27a0a 100644 --- a/compiler/rustc_data_structures/src/flock/windows.rs +++ b/compiler/rustc_data_structures/src/flock/windows.rs @@ -2,16 +2,14 @@ use std::fs::{File, OpenOptions}; use std::io; use std::os::windows::prelude::*; use std::path::Path; -use tracing::debug; -use windows::{ - Win32::Foundation::{ERROR_INVALID_FUNCTION, HANDLE}, - Win32::Storage::FileSystem::{ - LockFileEx, FILE_SHARE_DELETE, FILE_SHARE_READ, FILE_SHARE_WRITE, LOCKFILE_EXCLUSIVE_LOCK, - LOCKFILE_FAIL_IMMEDIATELY, LOCK_FILE_FLAGS, - }, - Win32::System::IO::OVERLAPPED, +use tracing::debug; +use windows::Win32::Foundation::{ERROR_INVALID_FUNCTION, HANDLE}; +use windows::Win32::Storage::FileSystem::{ + LockFileEx, FILE_SHARE_DELETE, FILE_SHARE_READ, FILE_SHARE_WRITE, LOCKFILE_EXCLUSIVE_LOCK, + LOCKFILE_FAIL_IMMEDIATELY, LOCK_FILE_FLAGS, }; +use windows::Win32::System::IO::OVERLAPPED; #[derive(Debug)] pub struct Lock { diff --git a/compiler/rustc_data_structures/src/graph/dominators/mod.rs b/compiler/rustc_data_structures/src/graph/dominators/mod.rs index d1d2de670b8..7cb013fdbd8 100644 --- a/compiler/rustc_data_structures/src/graph/dominators/mod.rs +++ b/compiler/rustc_data_structures/src/graph/dominators/mod.rs @@ -9,10 +9,11 @@ //! Thomas Lengauer and Robert Endre Tarjan. //! <https://www.cs.princeton.edu/courses/archive/spr03/cs423/download/dominators.pdf> -use super::ControlFlowGraph; +use std::cmp::Ordering; + use rustc_index::{Idx, IndexSlice, IndexVec}; -use std::cmp::Ordering; +use super::ControlFlowGraph; #[cfg(test)] mod tests; diff --git a/compiler/rustc_data_structures/src/graph/dominators/tests.rs b/compiler/rustc_data_structures/src/graph/dominators/tests.rs index 39725ba4301..6c078ca7c6e 100644 --- a/compiler/rustc_data_structures/src/graph/dominators/tests.rs +++ b/compiler/rustc_data_structures/src/graph/dominators/tests.rs @@ -1,6 +1,5 @@ -use super::*; - use super::super::tests::TestGraph; +use super::*; #[test] fn diamond() { diff --git a/compiler/rustc_data_structures/src/graph/implementation/mod.rs b/compiler/rustc_data_structures/src/graph/implementation/mod.rs index 8cf4b4153db..43fdfe6ee0d 100644 --- a/compiler/rustc_data_structures/src/graph/implementation/mod.rs +++ b/compiler/rustc_data_structures/src/graph/implementation/mod.rs @@ -20,8 +20,9 @@ //! the field `next_edge`). Each of those fields is an array that should //! be indexed by the direction (see the type `Direction`). -use rustc_index::bit_set::BitSet; use std::fmt::Debug; + +use rustc_index::bit_set::BitSet; use tracing::debug; #[cfg(test)] diff --git a/compiler/rustc_data_structures/src/graph/implementation/tests.rs b/compiler/rustc_data_structures/src/graph/implementation/tests.rs index b4dbd65db94..32a6d9ec881 100644 --- a/compiler/rustc_data_structures/src/graph/implementation/tests.rs +++ b/compiler/rustc_data_structures/src/graph/implementation/tests.rs @@ -1,6 +1,7 @@ -use crate::graph::implementation::*; use tracing::debug; +use crate::graph::implementation::*; + type TestGraph = Graph<&'static str, &'static str>; fn create_graph() -> TestGraph { diff --git a/compiler/rustc_data_structures/src/graph/iterate/mod.rs b/compiler/rustc_data_structures/src/graph/iterate/mod.rs index 6fca57d32f7..cbc6664d853 100644 --- a/compiler/rustc_data_structures/src/graph/iterate/mod.rs +++ b/compiler/rustc_data_structures/src/graph/iterate/mod.rs @@ -1,7 +1,9 @@ -use super::{DirectedGraph, StartNode, Successors}; +use std::ops::ControlFlow; + use rustc_index::bit_set::BitSet; use rustc_index::{IndexSlice, IndexVec}; -use std::ops::ControlFlow; + +use super::{DirectedGraph, StartNode, Successors}; #[cfg(test)] mod tests; diff --git a/compiler/rustc_data_structures/src/graph/iterate/tests.rs b/compiler/rustc_data_structures/src/graph/iterate/tests.rs index c498c289337..eb7d0bd14b6 100644 --- a/compiler/rustc_data_structures/src/graph/iterate/tests.rs +++ b/compiler/rustc_data_structures/src/graph/iterate/tests.rs @@ -1,5 +1,4 @@ use super::super::tests::TestGraph; - use super::*; #[test] diff --git a/compiler/rustc_data_structures/src/graph/scc/mod.rs b/compiler/rustc_data_structures/src/graph/scc/mod.rs index 8b96b36a851..96fc8ae3887 100644 --- a/compiler/rustc_data_structures/src/graph/scc/mod.rs +++ b/compiler/rustc_data_structures/src/graph/scc/mod.rs @@ -8,14 +8,16 @@ //! Typical examples would include: minimum element in SCC, maximum element //! reachable from it, etc. -use crate::fx::FxHashSet; -use crate::graph::vec_graph::VecGraph; -use crate::graph::{DirectedGraph, NumEdges, Successors}; -use rustc_index::{Idx, IndexSlice, IndexVec}; use std::fmt::Debug; use std::ops::Range; + +use rustc_index::{Idx, IndexSlice, IndexVec}; use tracing::{debug, instrument}; +use crate::fx::FxHashSet; +use crate::graph::vec_graph::VecGraph; +use crate::graph::{DirectedGraph, NumEdges, Successors}; + #[cfg(test)] mod tests; diff --git a/compiler/rustc_data_structures/src/graph/tests.rs b/compiler/rustc_data_structures/src/graph/tests.rs index 85c2703cc25..b69b9dbc4a8 100644 --- a/compiler/rustc_data_structures/src/graph/tests.rs +++ b/compiler/rustc_data_structures/src/graph/tests.rs @@ -1,7 +1,7 @@ -use crate::fx::FxHashMap; use std::cmp::max; use super::*; +use crate::fx::FxHashMap; pub struct TestGraph { num_nodes: usize, diff --git a/compiler/rustc_data_structures/src/graph/vec_graph/mod.rs b/compiler/rustc_data_structures/src/graph/vec_graph/mod.rs index 120244c8918..96784c2540a 100644 --- a/compiler/rustc_data_structures/src/graph/vec_graph/mod.rs +++ b/compiler/rustc_data_structures/src/graph/vec_graph/mod.rs @@ -1,6 +1,7 @@ -use crate::graph::{DirectedGraph, NumEdges, Predecessors, Successors}; use rustc_index::{Idx, IndexVec}; +use crate::graph::{DirectedGraph, NumEdges, Predecessors, Successors}; + #[cfg(test)] mod tests; diff --git a/compiler/rustc_data_structures/src/graph/vec_graph/tests.rs b/compiler/rustc_data_structures/src/graph/vec_graph/tests.rs index a077d9d0813..78caf75f5b4 100644 --- a/compiler/rustc_data_structures/src/graph/vec_graph/tests.rs +++ b/compiler/rustc_data_structures/src/graph/vec_graph/tests.rs @@ -1,6 +1,5 @@ -use crate::graph; - use super::*; +use crate::graph; fn create_graph() -> VecGraph<usize> { // Create a simple graph diff --git a/compiler/rustc_data_structures/src/hashes.rs b/compiler/rustc_data_structures/src/hashes.rs index ef5d2e845ef..f98c8de1eb0 100644 --- a/compiler/rustc_data_structures/src/hashes.rs +++ b/compiler/rustc_data_structures/src/hashes.rs @@ -11,11 +11,13 @@ //! connect the fact that they can only be produced by a `StableHasher` to their //! `Encode`/`Decode` impls. -use crate::stable_hasher::{FromStableHash, StableHasherHash}; -use rustc_serialize::{Decodable, Decoder, Encodable, Encoder}; use std::fmt; use std::ops::BitXorAssign; +use rustc_serialize::{Decodable, Decoder, Encodable, Encoder}; + +use crate::stable_hasher::{FromStableHash, StableHasherHash}; + #[derive(Clone, Copy, PartialEq, Eq, Hash, PartialOrd, Ord, Default)] pub struct Hash64 { inner: u64, diff --git a/compiler/rustc_data_structures/src/intern.rs b/compiler/rustc_data_structures/src/intern.rs index e0f8c350c2a..850b052f564 100644 --- a/compiler/rustc_data_structures/src/intern.rs +++ b/compiler/rustc_data_structures/src/intern.rs @@ -1,10 +1,11 @@ -use crate::stable_hasher::{HashStable, StableHasher}; use std::cmp::Ordering; use std::fmt::{self, Debug}; use std::hash::{Hash, Hasher}; use std::ops::Deref; use std::ptr; +use crate::stable_hasher::{HashStable, StableHasher}; + mod private { #[derive(Clone, Copy, Debug)] pub struct PrivateZst; diff --git a/compiler/rustc_data_structures/src/jobserver.rs b/compiler/rustc_data_structures/src/jobserver.rs index 89088bc5c1b..d09f7efc8ff 100644 --- a/compiler/rustc_data_structures/src/jobserver.rs +++ b/compiler/rustc_data_structures/src/jobserver.rs @@ -1,9 +1,8 @@ -pub use jobserver_crate::Client; +use std::sync::{LazyLock, OnceLock}; +pub use jobserver_crate::Client; use jobserver_crate::{FromEnv, FromEnvErrorKind}; -use std::sync::{LazyLock, OnceLock}; - // We can only call `from_env_ext` once per process // We stick this in a global because there could be multiple rustc instances diff --git a/compiler/rustc_data_structures/src/lib.rs b/compiler/rustc_data_structures/src/lib.rs index 3f18b036940..4f654eb0901 100644 --- a/compiler/rustc_data_structures/src/lib.rs +++ b/compiler/rustc_data_structures/src/lib.rs @@ -39,14 +39,12 @@ #![feature(unwrap_infallible)] // tidy-alphabetical-end +use std::fmt; + pub use atomic_ref::AtomicRef; -pub use ena::snapshot_vec; -pub use ena::undo_log; -pub use ena::unify; +pub use ena::{snapshot_vec, undo_log, unify}; pub use rustc_index::static_assert_size; -use std::fmt; - pub mod aligned; pub mod base_n; pub mod binary_search_util; diff --git a/compiler/rustc_data_structures/src/obligation_forest/graphviz.rs b/compiler/rustc_data_structures/src/obligation_forest/graphviz.rs index 4b6aa116520..60cde9a52b4 100644 --- a/compiler/rustc_data_structures/src/obligation_forest/graphviz.rs +++ b/compiler/rustc_data_structures/src/obligation_forest/graphviz.rs @@ -1,11 +1,12 @@ -use crate::obligation_forest::{ForestObligation, ObligationForest}; -use rustc_graphviz as dot; use std::env::var_os; use std::fs::File; use std::io::BufWriter; use std::path::Path; -use std::sync::atomic::AtomicUsize; -use std::sync::atomic::Ordering; +use std::sync::atomic::{AtomicUsize, Ordering}; + +use rustc_graphviz as dot; + +use crate::obligation_forest::{ForestObligation, ObligationForest}; impl<O: ForestObligation> ObligationForest<O> { /// Creates a graphviz representation of the obligation forest. Given a directory this will diff --git a/compiler/rustc_data_structures/src/obligation_forest/mod.rs b/compiler/rustc_data_structures/src/obligation_forest/mod.rs index 3883b0736db..cfe7dd13e80 100644 --- a/compiler/rustc_data_structures/src/obligation_forest/mod.rs +++ b/compiler/rustc_data_structures/src/obligation_forest/mod.rs @@ -69,14 +69,16 @@ //! step, we compress the vector to remove completed and error nodes, which //! aren't needed anymore. -use crate::fx::{FxHashMap, FxHashSet}; use std::cell::Cell; use std::collections::hash_map::Entry; use std::fmt::Debug; use std::hash; use std::marker::PhantomData; + use tracing::debug; +use crate::fx::{FxHashMap, FxHashSet}; + mod graphviz; #[cfg(test)] diff --git a/compiler/rustc_data_structures/src/obligation_forest/tests.rs b/compiler/rustc_data_structures/src/obligation_forest/tests.rs index d09c8e54436..a58c6ee1bcc 100644 --- a/compiler/rustc_data_structures/src/obligation_forest/tests.rs +++ b/compiler/rustc_data_structures/src/obligation_forest/tests.rs @@ -1,7 +1,7 @@ -use super::*; - use std::fmt; +use super::*; + impl<'a> super::ForestObligation for &'a str { type CacheKey = &'a str; diff --git a/compiler/rustc_data_structures/src/owned_slice.rs b/compiler/rustc_data_structures/src/owned_slice.rs index bb664795860..bbe6691e548 100644 --- a/compiler/rustc_data_structures/src/owned_slice.rs +++ b/compiler/rustc_data_structures/src/owned_slice.rs @@ -1,10 +1,11 @@ -use std::{borrow::Borrow, ops::Deref}; +use std::borrow::Borrow; +use std::ops::Deref; -use crate::sync::Lrc; // Use our fake Send/Sync traits when on not parallel compiler, // so that `OwnedSlice` only implements/requires Send/Sync // for parallel compiler builds. use crate::sync; +use crate::sync::Lrc; /// An owned slice. /// diff --git a/compiler/rustc_data_structures/src/owned_slice/tests.rs b/compiler/rustc_data_structures/src/owned_slice/tests.rs index 520871a12be..324b8ecf2d3 100644 --- a/compiler/rustc_data_structures/src/owned_slice/tests.rs +++ b/compiler/rustc_data_structures/src/owned_slice/tests.rs @@ -1,15 +1,9 @@ -use std::{ - ops::Deref, - sync::{ - atomic::{self, AtomicBool}, - Arc, - }, -}; - -use crate::{ - defer, - owned_slice::{slice_owned, try_slice_owned, OwnedSlice}, -}; +use std::ops::Deref; +use std::sync::atomic::{self, AtomicBool}; +use std::sync::Arc; + +use crate::defer; +use crate::owned_slice::{slice_owned, try_slice_owned, OwnedSlice}; #[test] fn smoke() { diff --git a/compiler/rustc_data_structures/src/packed.rs b/compiler/rustc_data_structures/src/packed.rs index 0a392d91988..f54b12b5b53 100644 --- a/compiler/rustc_data_structures/src/packed.rs +++ b/compiler/rustc_data_structures/src/packed.rs @@ -1,8 +1,10 @@ -use crate::stable_hasher::{HashStable, StableHasher}; -use rustc_serialize::{Decodable, Decoder, Encodable, Encoder}; use std::cmp::Ordering; use std::fmt; +use rustc_serialize::{Decodable, Decoder, Encodable, Encoder}; + +use crate::stable_hasher::{HashStable, StableHasher}; + /// A packed 128-bit integer. Useful for reducing the size of structures in /// some cases. #[derive(Copy, Clone, Debug, Hash, PartialEq, Eq, PartialOrd, Ord)] diff --git a/compiler/rustc_data_structures/src/profiling.rs b/compiler/rustc_data_structures/src/profiling.rs index 240f2671c3b..19050746c2f 100644 --- a/compiler/rustc_data_structures/src/profiling.rs +++ b/compiler/rustc_data_structures/src/profiling.rs @@ -81,19 +81,15 @@ //! //! [mm]: https://github.com/rust-lang/measureme/ -use crate::fx::FxHashMap; -use crate::outline; - use std::borrow::Borrow; use std::collections::hash_map::Entry; use std::error::Error; use std::fmt::Display; -use std::fs; use std::intrinsics::unlikely; use std::path::Path; -use std::process; use std::sync::Arc; use std::time::{Duration, Instant}; +use std::{fs, process}; pub use measureme::EventId; use measureme::{EventIdBuilder, Profiler, SerializableString, StringId}; @@ -101,6 +97,9 @@ use parking_lot::RwLock; use smallvec::SmallVec; use tracing::warn; +use crate::fx::FxHashMap; +use crate::outline; + bitflags::bitflags! { #[derive(Clone, Copy)] struct EventFilter: u16 { diff --git a/compiler/rustc_data_structures/src/sharded.rs b/compiler/rustc_data_structures/src/sharded.rs index 4b02b183460..03aa1d8f678 100644 --- a/compiler/rustc_data_structures/src/sharded.rs +++ b/compiler/rustc_data_structures/src/sharded.rs @@ -1,14 +1,15 @@ +use std::borrow::Borrow; +use std::collections::hash_map::RawEntryMut; +use std::hash::{Hash, Hasher}; +use std::{iter, mem}; + +#[cfg(parallel_compiler)] +use either::Either; + use crate::fx::{FxHashMap, FxHasher}; #[cfg(parallel_compiler)] use crate::sync::{is_dyn_thread_safe, CacheAligned}; use crate::sync::{Lock, LockGuard, Mode}; -#[cfg(parallel_compiler)] -use either::Either; -use std::borrow::Borrow; -use std::collections::hash_map::RawEntryMut; -use std::hash::{Hash, Hasher}; -use std::iter; -use std::mem; // 32 shards is sufficient to reduce contention on an 8-core Ryzen 7 1700, // but this should be tested on higher core count CPUs. How the `Sharded` type gets used diff --git a/compiler/rustc_data_structures/src/snapshot_map/mod.rs b/compiler/rustc_data_structures/src/snapshot_map/mod.rs index 8a50179cd3b..d50365b6b06 100644 --- a/compiler/rustc_data_structures/src/snapshot_map/mod.rs +++ b/compiler/rustc_data_structures/src/snapshot_map/mod.rs @@ -1,11 +1,11 @@ -use crate::fx::FxHashMap; -use crate::undo_log::{Rollback, Snapshots, UndoLogs, VecLog}; use std::borrow::{Borrow, BorrowMut}; use std::hash::Hash; use std::marker::PhantomData; use std::ops; +use crate::fx::FxHashMap; pub use crate::undo_log::Snapshot; +use crate::undo_log::{Rollback, Snapshots, UndoLogs, VecLog}; #[cfg(test)] mod tests; diff --git a/compiler/rustc_data_structures/src/sorted_map.rs b/compiler/rustc_data_structures/src/sorted_map.rs index 885f023122a..066ea03b4ac 100644 --- a/compiler/rustc_data_structures/src/sorted_map.rs +++ b/compiler/rustc_data_structures/src/sorted_map.rs @@ -1,10 +1,12 @@ -use crate::stable_hasher::{HashStable, StableHasher, StableOrd}; -use rustc_macros::{Decodable_Generic, Encodable_Generic}; use std::borrow::Borrow; use std::fmt::Debug; use std::mem; use std::ops::{Bound, Index, IndexMut, RangeBounds}; +use rustc_macros::{Decodable_Generic, Encodable_Generic}; + +use crate::stable_hasher::{HashStable, StableHasher, StableOrd}; + mod index_map; pub use index_map::SortedIndexMultiMap; diff --git a/compiler/rustc_data_structures/src/sorted_map/index_map.rs b/compiler/rustc_data_structures/src/sorted_map/index_map.rs index c172ee1c970..e9a5fb51975 100644 --- a/compiler/rustc_data_structures/src/sorted_map/index_map.rs +++ b/compiler/rustc_data_structures/src/sorted_map/index_map.rs @@ -2,9 +2,10 @@ use std::hash::{Hash, Hasher}; -use crate::stable_hasher::{HashStable, StableHasher}; use rustc_index::{Idx, IndexVec}; +use crate::stable_hasher::{HashStable, StableHasher}; + /// An indexed multi-map that preserves insertion order while permitting both *O*(log *n*) lookup of /// an item by key and *O*(1) lookup by index. /// diff --git a/compiler/rustc_data_structures/src/sso/map.rs b/compiler/rustc_data_structures/src/sso/map.rs index 2ef4a2ccd84..3200249a2dc 100644 --- a/compiler/rustc_data_structures/src/sso/map.rs +++ b/compiler/rustc_data_structures/src/sso/map.rs @@ -1,10 +1,12 @@ -use crate::fx::FxHashMap; -use arrayvec::ArrayVec; -use either::Either; use std::fmt; use std::hash::Hash; use std::ops::Index; +use arrayvec::ArrayVec; +use either::Either; + +use crate::fx::FxHashMap; + /// For pointer-sized arguments arrays /// are faster than set/map for up to 64 /// arguments. diff --git a/compiler/rustc_data_structures/src/stable_hasher.rs b/compiler/rustc_data_structures/src/stable_hasher.rs index 83883eeba9c..9673f94d7a4 100644 --- a/compiler/rustc_data_structures/src/stable_hasher.rs +++ b/compiler/rustc_data_structures/src/stable_hasher.rs @@ -1,19 +1,20 @@ -use rustc_index::bit_set::{self, BitSet}; -use rustc_index::{Idx, IndexSlice, IndexVec}; -use smallvec::SmallVec; use std::hash::{BuildHasher, Hash, Hasher}; use std::marker::PhantomData; use std::mem; use std::num::NonZero; +use rustc_index::bit_set::{self, BitSet}; +use rustc_index::{Idx, IndexSlice, IndexVec}; +use smallvec::SmallVec; + #[cfg(test)] mod tests; -pub use crate::hashes::{Hash128, Hash64}; +pub use rustc_stable_hash::{ + FromStableHash, SipHasher128Hash as StableHasherHash, StableSipHasher128 as StableHasher, +}; -pub use rustc_stable_hash::FromStableHash; -pub use rustc_stable_hash::SipHasher128Hash as StableHasherHash; -pub use rustc_stable_hash::StableSipHasher128 as StableHasher; +pub use crate::hashes::{Hash128, Hash64}; /// Something that implements `HashStable<CTX>` can be hashed in a way that is /// stable across multiple compilation sessions. diff --git a/compiler/rustc_data_structures/src/svh.rs b/compiler/rustc_data_structures/src/svh.rs index 38629ea9801..391a7c9f30d 100644 --- a/compiler/rustc_data_structures/src/svh.rs +++ b/compiler/rustc_data_structures/src/svh.rs @@ -5,10 +5,12 @@ //! mismatches where we have two versions of the same crate that were //! compiled from distinct sources. +use std::fmt; + +use rustc_macros::{Decodable_Generic, Encodable_Generic}; + use crate::fingerprint::Fingerprint; use crate::stable_hasher; -use rustc_macros::{Decodable_Generic, Encodable_Generic}; -use std::fmt; #[derive(Copy, Clone, PartialEq, Eq, Debug, Encodable_Generic, Decodable_Generic, Hash)] pub struct Svh { diff --git a/compiler/rustc_data_structures/src/sync.rs b/compiler/rustc_data_structures/src/sync.rs index 058a675c40d..6df94bc0e94 100644 --- a/compiler/rustc_data_structures/src/sync.rs +++ b/compiler/rustc_data_structures/src/sync.rs @@ -41,10 +41,11 @@ //! //! [^2]: `MTRef`, `MTLockRef` are type aliases. -pub use crate::marker::*; use std::collections::HashMap; use std::hash::{BuildHasher, Hash}; +pub use crate::marker::*; + mod lock; #[doc(no_inline)] pub use lock::{Lock, LockGuard, Mode}; @@ -56,7 +57,6 @@ mod parallel; #[cfg(parallel_compiler)] pub use parallel::scope; pub use parallel::{join, par_for_each_in, par_map, parallel_guard, try_par_for_each_in}; - pub use vec::{AppendOnlyIndexVec, AppendOnlyVec}; mod vec; diff --git a/compiler/rustc_data_structures/src/sync/freeze.rs b/compiler/rustc_data_structures/src/sync/freeze.rs index 466c44f59bb..fad5f583d1c 100644 --- a/compiler/rustc_data_structures/src/sync/freeze.rs +++ b/compiler/rustc_data_structures/src/sync/freeze.rs @@ -1,14 +1,13 @@ +use std::cell::UnsafeCell; +use std::intrinsics::likely; +use std::marker::PhantomData; +use std::ops::{Deref, DerefMut}; +use std::ptr::NonNull; +use std::sync::atomic::Ordering; + use crate::sync::{AtomicBool, ReadGuard, RwLock, WriteGuard}; #[cfg(parallel_compiler)] use crate::sync::{DynSend, DynSync}; -use std::{ - cell::UnsafeCell, - intrinsics::likely, - marker::PhantomData, - ops::{Deref, DerefMut}, - ptr::NonNull, - sync::atomic::Ordering, -}; /// A type which allows mutation using a lock until /// the value is frozen and can be accessed lock-free. diff --git a/compiler/rustc_data_structures/src/sync/lock.rs b/compiler/rustc_data_structures/src/sync/lock.rs index 780be773945..7cf942685e3 100644 --- a/compiler/rustc_data_structures/src/sync/lock.rs +++ b/compiler/rustc_data_structures/src/sync/lock.rs @@ -19,19 +19,20 @@ pub enum Mode { } mod maybe_sync { - use super::Mode; - use crate::sync::mode; - #[cfg(parallel_compiler)] - use crate::sync::{DynSend, DynSync}; - use parking_lot::lock_api::RawMutex as _; - use parking_lot::RawMutex; - use std::cell::Cell; - use std::cell::UnsafeCell; + use std::cell::{Cell, UnsafeCell}; use std::intrinsics::unlikely; use std::marker::PhantomData; use std::mem::ManuallyDrop; use std::ops::{Deref, DerefMut}; + use parking_lot::lock_api::RawMutex as _; + use parking_lot::RawMutex; + + use super::Mode; + use crate::sync::mode; + #[cfg(parallel_compiler)] + use crate::sync::{DynSend, DynSync}; + /// A guard holding mutable access to a `Lock` which is in a locked state. #[must_use = "if unused the Lock will immediately unlock"] pub struct LockGuard<'a, T> { @@ -186,12 +187,12 @@ mod maybe_sync { } mod no_sync { - use super::Mode; use std::cell::RefCell; - #[doc(no_inline)] pub use std::cell::RefMut as LockGuard; + use super::Mode; + pub struct Lock<T>(RefCell<T>); impl<T> Lock<T> { diff --git a/compiler/rustc_data_structures/src/sync/parallel.rs b/compiler/rustc_data_structures/src/sync/parallel.rs index 7783de57fba..2b89431c2ed 100644 --- a/compiler/rustc_data_structures/src/sync/parallel.rs +++ b/compiler/rustc_data_structures/src/sync/parallel.rs @@ -3,9 +3,6 @@ #![allow(dead_code)] -use crate::sync::IntoDynSyncSend; -use crate::FatalErrorMarker; -use parking_lot::Mutex; use std::any::Any; use std::panic::{catch_unwind, resume_unwind, AssertUnwindSafe}; @@ -13,6 +10,10 @@ use std::panic::{catch_unwind, resume_unwind, AssertUnwindSafe}; pub use disabled::*; #[cfg(parallel_compiler)] pub use enabled::*; +use parking_lot::Mutex; + +use crate::sync::IntoDynSyncSend; +use crate::FatalErrorMarker; /// A guard used to hold panics that occur during a parallel section to later by unwound. /// This is used for the parallel compiler to prevent fatal errors from non-deterministically diff --git a/compiler/rustc_data_structures/src/sync/worker_local.rs b/compiler/rustc_data_structures/src/sync/worker_local.rs index 07a361ba260..4950481d311 100644 --- a/compiler/rustc_data_structures/src/sync/worker_local.rs +++ b/compiler/rustc_data_structures/src/sync/worker_local.rs @@ -1,11 +1,10 @@ -use parking_lot::Mutex; -use std::cell::Cell; -use std::cell::OnceCell; +use std::cell::{Cell, OnceCell}; use std::num::NonZero; use std::ops::Deref; use std::ptr; use std::sync::Arc; +use parking_lot::Mutex; #[cfg(parallel_compiler)] use {crate::outline, crate::sync::CacheAligned}; diff --git a/compiler/rustc_data_structures/src/tagged_ptr/copy.rs b/compiler/rustc_data_structures/src/tagged_ptr/copy.rs index 8b9e834b60b..25e107b0f41 100644 --- a/compiler/rustc_data_structures/src/tagged_ptr/copy.rs +++ b/compiler/rustc_data_structures/src/tagged_ptr/copy.rs @@ -1,5 +1,3 @@ -use super::{Pointer, Tag}; -use crate::stable_hasher::{HashStable, StableHasher}; use std::fmt; use std::hash::{Hash, Hasher}; use std::marker::PhantomData; @@ -8,6 +6,9 @@ use std::num::NonZero; use std::ops::{Deref, DerefMut}; use std::ptr::NonNull; +use super::{Pointer, Tag}; +use crate::stable_hasher::{HashStable, StableHasher}; + /// A [`Copy`] tagged pointer. /// /// This is essentially `{ pointer: P, tag: T }` packed in a single pointer. diff --git a/compiler/rustc_data_structures/src/tagged_ptr/drop.rs b/compiler/rustc_data_structures/src/tagged_ptr/drop.rs index 4e42b5b4afe..319a8cdd399 100644 --- a/compiler/rustc_data_structures/src/tagged_ptr/drop.rs +++ b/compiler/rustc_data_structures/src/tagged_ptr/drop.rs @@ -2,8 +2,7 @@ use std::fmt; use std::hash::{Hash, Hasher}; use std::ops::{Deref, DerefMut}; -use super::CopyTaggedPtr; -use super::{Pointer, Tag}; +use super::{CopyTaggedPtr, Pointer, Tag}; use crate::stable_hasher::{HashStable, StableHasher}; /// A tagged pointer that supports pointers that implement [`Drop`]. diff --git a/compiler/rustc_data_structures/src/tagged_ptr/drop/tests.rs b/compiler/rustc_data_structures/src/tagged_ptr/drop/tests.rs index 2c17d678d3a..4d342c72cc5 100644 --- a/compiler/rustc_data_structures/src/tagged_ptr/drop/tests.rs +++ b/compiler/rustc_data_structures/src/tagged_ptr/drop/tests.rs @@ -1,4 +1,5 @@ -use std::{ptr, sync::Arc}; +use std::ptr; +use std::sync::Arc; use crate::tagged_ptr::{Pointer, Tag, Tag2, TaggedPtr}; diff --git a/compiler/rustc_data_structures/src/temp_dir.rs b/compiler/rustc_data_structures/src/temp_dir.rs index 621d3011a2a..4dbe11d707d 100644 --- a/compiler/rustc_data_structures/src/temp_dir.rs +++ b/compiler/rustc_data_structures/src/temp_dir.rs @@ -1,5 +1,6 @@ use std::mem::ManuallyDrop; use std::path::Path; + use tempfile::TempDir; /// This is used to avoid TempDir being dropped on error paths unintentionally. diff --git a/compiler/rustc_data_structures/src/transitive_relation.rs b/compiler/rustc_data_structures/src/transitive_relation.rs index cd391fe357a..26b00e0af3a 100644 --- a/compiler/rustc_data_structures/src/transitive_relation.rs +++ b/compiler/rustc_data_structures/src/transitive_relation.rs @@ -1,11 +1,13 @@ -use crate::frozen::Frozen; -use crate::fx::{FxHashSet, FxIndexSet}; -use rustc_index::bit_set::BitMatrix; use std::fmt::Debug; use std::hash::Hash; use std::mem; use std::ops::Deref; +use rustc_index::bit_set::BitMatrix; + +use crate::frozen::Frozen; +use crate::fx::{FxHashSet, FxIndexSet}; + #[cfg(test)] mod tests; diff --git a/compiler/rustc_data_structures/src/unord.rs b/compiler/rustc_data_structures/src/unord.rs index 1ccd22a56c9..bafb16a8b5e 100644 --- a/compiler/rustc_data_structures/src/unord.rs +++ b/compiler/rustc_data_structures/src/unord.rs @@ -2,21 +2,17 @@ //! ordering. This is a useful property for deterministic computations, such //! as required by the query system. +use std::borrow::{Borrow, BorrowMut}; +use std::collections::hash_map::{Entry, OccupiedError}; +use std::hash::Hash; +use std::iter::{Product, Sum}; +use std::ops::Index; + use rustc_hash::{FxHashMap, FxHashSet}; use rustc_macros::{Decodable_Generic, Encodable_Generic}; -use std::collections::hash_map::OccupiedError; -use std::{ - borrow::{Borrow, BorrowMut}, - collections::hash_map::Entry, - hash::Hash, - iter::{Product, Sum}, - ops::Index, -}; - -use crate::{ - fingerprint::Fingerprint, - stable_hasher::{HashStable, StableCompare, StableHasher, ToStableHashKey}, -}; + +use crate::fingerprint::Fingerprint; +use crate::stable_hasher::{HashStable, StableCompare, StableHasher, ToStableHashKey}; /// `UnordItems` is the order-less version of `Iterator`. It only contains methods /// that don't (easily) expose an ordering of the underlying items. diff --git a/compiler/rustc_data_structures/src/work_queue.rs b/compiler/rustc_data_structures/src/work_queue.rs index 9db6b6f20be..490d7d3ddd5 100644 --- a/compiler/rustc_data_structures/src/work_queue.rs +++ b/compiler/rustc_data_structures/src/work_queue.rs @@ -1,6 +1,7 @@ +use std::collections::VecDeque; + use rustc_index::bit_set::BitSet; use rustc_index::Idx; -use std::collections::VecDeque; /// A work queue is a handy data structure for tracking work left to /// do. (For example, basic blocks left to process.) It is basically a |
