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.
This commit is contained in:
Nicholas Nethercote 2024-07-29 08:13:50 +10:00
parent 118f9350c5
commit 84ac80f192
1865 changed files with 8367 additions and 9199 deletions

View file

@ -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;

View file

@ -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;

View file

@ -1,5 +1,6 @@
use smallvec::{Array, SmallVec};
use std::ptr;
use smallvec::{Array, SmallVec};
use thin_vec::ThinVec;
pub trait FlatMapInPlace<T>: Sized {

View file

@ -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 {

View file

@ -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 {

View file

@ -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;

View file

@ -1,6 +1,5 @@
use super::*;
use super::super::tests::TestGraph;
use super::*;
#[test]
fn diamond() {

View file

@ -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)]

View file

@ -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 {

View file

@ -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;

View file

@ -1,5 +1,4 @@
use super::super::tests::TestGraph;
use super::*;
#[test]

View file

@ -8,13 +8,15 @@
//! Typical examples would include: minimum element in SCC, maximum element
//! reachable from it, etc.
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};
use rustc_index::{Idx, IndexSlice, IndexVec};
use std::fmt::Debug;
use std::ops::Range;
use tracing::{debug, instrument};
#[cfg(test)]
mod tests;

View file

@ -1,7 +1,7 @@
use crate::fx::FxHashMap;
use std::cmp::max;
use super::*;
use crate::fx::FxHashMap;
pub struct TestGraph {
num_nodes: usize,

View file

@ -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;

View file

@ -1,6 +1,5 @@
use crate::graph;
use super::*;
use crate::graph;
fn create_graph() -> VecGraph<usize> {
// Create a simple graph

View file

@ -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,

View file

@ -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;

View file

@ -1,9 +1,8 @@
pub use jobserver_crate::Client;
use jobserver_crate::{FromEnv, FromEnvErrorKind};
use std::sync::{LazyLock, OnceLock};
pub use jobserver_crate::Client;
use jobserver_crate::{FromEnv, FromEnvErrorKind};
// We can only call `from_env_ext` once per process
// We stick this in a global because there could be multiple rustc instances

View file

@ -39,14 +39,12 @@
#![feature(unwrap_infallible)]
// tidy-alphabetical-end
pub use atomic_ref::AtomicRef;
pub use ena::snapshot_vec;
pub use ena::undo_log;
pub use ena::unify;
pub use rustc_index::static_assert_size;
use std::fmt;
pub use atomic_ref::AtomicRef;
pub use ena::{snapshot_vec, undo_log, unify};
pub use rustc_index::static_assert_size;
pub mod aligned;
pub mod base_n;
pub mod binary_search_util;

View file

@ -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

View file

@ -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)]

View file

@ -1,7 +1,7 @@
use super::*;
use std::fmt;
use super::*;
impl<'a> super::ForestObligation for &'a str {
type CacheKey = &'a str;

View file

@ -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.
///

View file

@ -1,15 +1,9 @@
use std::{
ops::Deref,
sync::{
atomic::{self, AtomicBool},
Arc,
},
};
use std::ops::Deref;
use std::sync::atomic::{self, AtomicBool};
use std::sync::Arc;
use crate::{
defer,
owned_slice::{slice_owned, try_slice_owned, OwnedSlice},
};
use crate::defer;
use crate::owned_slice::{slice_owned, try_slice_owned, OwnedSlice};
#[test]
fn smoke() {

View file

@ -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)]

View file

@ -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 {

View file

@ -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

View file

@ -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;

View file

@ -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;

View file

@ -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.
///

View file

@ -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.

View file

@ -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.

View file

@ -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 {

View file

@ -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;

View file

@ -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.

View file

@ -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> {

View file

@ -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

View file

@ -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};

View file

@ -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.

View file

@ -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`].

View file

@ -1,4 +1,5 @@
use std::{ptr, sync::Arc};
use std::ptr;
use std::sync::Arc;
use crate::tagged_ptr::{Pointer, Tag, Tag2, TaggedPtr};

View file

@ -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.

View file

@ -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;

View file

@ -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.

View file

@ -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