1
Fork 0

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,7 +1,9 @@
use std::ops::Range;
use rustc_data_structures::sync::Lrc;
use crate::source_map::SourceMap;
use crate::{BytePos, Pos, RelativeBytePos, SourceFile, SpanData};
use rustc_data_structures::sync::Lrc;
use std::ops::Range;
#[derive(Clone)]
struct CacheEntry {

View file

@ -1,4 +1,6 @@
use crate::{HashStableContext, SpanDecoder, SpanEncoder, Symbol};
use std::fmt;
use std::hash::{BuildHasherDefault, Hash, Hasher};
use rustc_data_structures::fingerprint::Fingerprint;
use rustc_data_structures::stable_hasher::{
Hash64, HashStable, StableHasher, StableOrd, ToStableHashKey,
@ -8,8 +10,8 @@ use rustc_data_structures::AtomicRef;
use rustc_index::Idx;
use rustc_macros::{Decodable, Encodable, HashStable_Generic};
use rustc_serialize::{Decodable, Encodable};
use std::fmt;
use std::hash::{BuildHasherDefault, Hash, Hasher};
use crate::{HashStableContext, SpanDecoder, SpanEncoder, Symbol};
pub type StableCrateIdMap =
indexmap::IndexMap<StableCrateId, CrateNum, BuildHasherDefault<Unhasher>>;

View file

@ -9,9 +9,10 @@
// algorithm should not matter to the caller of the methods, which is why it is not noted in the
// documentation.
use crate::symbol::Symbol;
use std::{cmp, mem};
use crate::symbol::Symbol;
#[cfg(test)]
mod tests;

View file

@ -24,10 +24,11 @@
// because getting it wrong can lead to nested `HygieneData::with` calls that
// trigger runtime aborts. (Fortunately these are obvious and easy to fix.)
use crate::def_id::{CrateNum, DefId, StableCrateId, CRATE_DEF_ID, LOCAL_CRATE};
use crate::edition::Edition;
use crate::symbol::{kw, sym, Symbol};
use crate::{with_session_globals, HashStableContext, Span, SpanDecoder, SpanEncoder, DUMMY_SP};
use std::cell::RefCell;
use std::collections::hash_map::Entry;
use std::fmt;
use std::hash::Hash;
use rustc_data_structures::fingerprint::Fingerprint;
use rustc_data_structures::fx::{FxHashMap, FxHashSet};
use rustc_data_structures::stable_hasher::{Hash64, HashStable, HashingControls, StableHasher};
@ -36,12 +37,13 @@ use rustc_data_structures::unhash::UnhashMap;
use rustc_index::IndexVec;
use rustc_macros::{Decodable, Encodable, HashStable_Generic};
use rustc_serialize::{Decodable, Decoder, Encodable, Encoder};
use std::cell::RefCell;
use std::collections::hash_map::Entry;
use std::fmt;
use std::hash::Hash;
use tracing::{debug, trace};
use crate::def_id::{CrateNum, DefId, StableCrateId, CRATE_DEF_ID, LOCAL_CRATE};
use crate::edition::Edition;
use crate::symbol::{kw, sym, Symbol};
use crate::{with_session_globals, HashStableContext, Span, SpanDecoder, SpanEncoder, DUMMY_SP};
/// A `SyntaxContext` represents a chain of pairs `(ExpnId, Transparency)` named "marks".
#[derive(Clone, Copy, PartialEq, Eq, Hash)]
pub struct SyntaxContext(u32);

View file

@ -47,15 +47,17 @@ use tracing::debug;
mod caching_source_map_view;
pub mod source_map;
pub use self::caching_source_map_view::CachingSourceMapView;
use source_map::{SourceMap, SourceMapInputs};
pub use self::caching_source_map_view::CachingSourceMapView;
pub mod edition;
use edition::Edition;
pub mod hygiene;
use hygiene::Transparency;
pub use hygiene::{DesugaringKind, ExpnKind, MacroKind};
pub use hygiene::{ExpnData, ExpnHash, ExpnId, LocalExpnId, SyntaxContext};
pub use hygiene::{
DesugaringKind, ExpnData, ExpnHash, ExpnId, ExpnKind, LocalExpnId, MacroKind, SyntaxContext,
};
use rustc_data_structures::stable_hasher::HashingControls;
pub mod def_id;
use def_id::{CrateNum, DefId, DefIndex, DefPathHash, LocalDefId, StableCrateId, LOCAL_CRATE};
@ -71,10 +73,6 @@ pub mod fatal_error;
pub mod profiling;
use rustc_data_structures::fx::FxHashMap;
use rustc_data_structures::stable_hasher::{Hash128, Hash64, HashStable, StableHasher};
use rustc_data_structures::sync::{FreezeLock, FreezeWriteGuard, Lock, Lrc};
use std::borrow::Cow;
use std::cmp::{self, Ordering};
use std::hash::Hash;
@ -83,8 +81,10 @@ use std::path::{Path, PathBuf};
use std::str::FromStr;
use std::{fmt, iter};
use md5::Digest;
use md5::Md5;
use md5::{Digest, Md5};
use rustc_data_structures::fx::FxHashMap;
use rustc_data_structures::stable_hasher::{Hash128, Hash64, HashStable, StableHasher};
use rustc_data_structures::sync::{FreezeLock, FreezeWriteGuard, Lock, Lrc};
use sha1::Sha1;
use sha2::Sha256;

View file

@ -1,9 +1,9 @@
use crate::source_map::SourceMap;
use std::borrow::Borrow;
use rustc_data_structures::profiling::EventArgRecorder;
use crate::source_map::SourceMap;
/// Extension trait for self-profiling purposes: allows to record spans within a generic activity's
/// event arguments.
pub trait SpannedEventArgRecorder {

View file

@ -9,15 +9,16 @@
//! within the `SourceMap`, which upon request can be converted to line and column
//! information, source code snippets, etc.
use crate::*;
use std::io::{self, BorrowedBuf, Read};
use std::{fs, path};
use rustc_data_structures::sync::{IntoDynSyncSend, MappedReadGuard, ReadGuard, RwLock};
use rustc_data_structures::unhash::UnhashMap;
use rustc_macros::{Decodable, Encodable};
use std::fs;
use std::io::{self, BorrowedBuf, Read};
use std::path;
use tracing::{debug, instrument, trace};
use crate::*;
#[cfg(test)]
mod tests;

View file

@ -1,14 +1,12 @@
use crate::def_id::{DefIndex, LocalDefId};
use crate::hygiene::SyntaxContext;
use crate::SPAN_TRACK;
use crate::{BytePos, SpanData};
use rustc_data_structures::fx::FxIndexSet;
// This code is very hot and uses lots of arithmetic, avoid overflow checks for performance.
// See https://github.com/rust-lang/rust/pull/119440#issuecomment-1874255727
use rustc_serialize::int_overflow::DebugStrictAdd;
use crate::def_id::{DefIndex, LocalDefId};
use crate::hygiene::SyntaxContext;
use crate::{BytePos, SpanData, SPAN_TRACK};
/// A compressed span.
///
/// [`SpanData`] is 16 bytes, which is too big to stick everywhere. `Span` only

View file

@ -2,6 +2,9 @@
//! allows bidirectional lookup; i.e., given a value, one can easily find the
//! type, and vice versa.
use std::hash::{Hash, Hasher};
use std::{fmt, str};
use rustc_arena::DroplessArena;
use rustc_data_structures::fx::FxIndexSet;
use rustc_data_structures::stable_hasher::{
@ -10,10 +13,6 @@ use rustc_data_structures::stable_hasher::{
use rustc_data_structures::sync::Lock;
use rustc_macros::{symbols, Decodable, Encodable, HashStable_Generic};
use std::fmt;
use std::hash::{Hash, Hasher};
use std::str;
use crate::{with_session_globals, Edition, Span, DUMMY_SP};
#[cfg(test)]
@ -2446,13 +2445,11 @@ pub mod kw {
/// Given that `sym` is imported, use them like `sym::symbol_name`.
/// For example `sym::rustfmt` or `sym::u8`.
pub mod sym {
use super::Symbol;
#[doc(inline)]
pub use super::sym_generated::*;
// Used from a macro in `librustc_feature/accepted.rs`
pub use super::kw::MacroRules as macro_rules;
#[doc(inline)]
pub use super::sym_generated::*;
use super::Symbol;
/// Get the symbol for an integer.
///

View file

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