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_ast/src | |
| 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_ast/src')
| -rw-r--r-- | compiler/rustc_ast/src/ast.rs | 26 | ||||
| -rw-r--r-- | compiler/rustc_ast/src/ast_traits.rs | 15 | ||||
| -rw-r--r-- | compiler/rustc_ast/src/attr/mod.rs | 26 | ||||
| -rw-r--r-- | compiler/rustc_ast/src/entry.rs | 3 | ||||
| -rw-r--r-- | compiler/rustc_ast/src/expand/mod.rs | 3 | ||||
| -rw-r--r-- | compiler/rustc_ast/src/format.rs | 5 | ||||
| -rw-r--r-- | compiler/rustc_ast/src/lib.rs | 4 | ||||
| -rw-r--r-- | compiler/rustc_ast/src/mut_visit.rs | 15 | ||||
| -rw-r--r-- | compiler/rustc_ast/src/node_id.rs | 3 | ||||
| -rw-r--r-- | compiler/rustc_ast/src/ptr.rs | 3 | ||||
| -rw-r--r-- | compiler/rustc_ast/src/token.rs | 26 | ||||
| -rw-r--r-- | compiler/rustc_ast/src/tokenstream.rs | 15 | ||||
| -rw-r--r-- | compiler/rustc_ast/src/util/comments.rs | 3 | ||||
| -rw-r--r-- | compiler/rustc_ast/src/util/comments/tests.rs | 3 | ||||
| -rw-r--r-- | compiler/rustc_ast/src/util/literal.rs | 8 | ||||
| -rw-r--r-- | compiler/rustc_ast/src/util/parser.rs | 3 | ||||
| -rw-r--r-- | compiler/rustc_ast/src/visit.rs | 9 | 
17 files changed, 91 insertions, 79 deletions
| diff --git a/compiler/rustc_ast/src/ast.rs b/compiler/rustc_ast/src/ast.rs index 628badd6f23..fc1af3fc3dd 100644 --- a/compiler/rustc_ast/src/ast.rs +++ b/compiler/rustc_ast/src/ast.rs @@ -18,15 +18,9 @@ //! - [`Attribute`]: Metadata associated with item. //! - [`UnOp`], [`BinOp`], and [`BinOpKind`]: Unary and binary operators. -pub use crate::format::*; -pub use crate::util::parser::ExprPrecedence; -pub use rustc_span::AttrId; -pub use GenericArgs::*; -pub use UnsafeSource::*; +use std::borrow::Cow; +use std::{cmp, fmt, mem}; -use crate::ptr::P; -use crate::token::{self, CommentKind, Delimiter}; -use crate::tokenstream::{DelimSpan, LazyAttrTokenStream, TokenStream}; pub use rustc_ast_ir::{Movability, Mutability}; use rustc_data_structures::packed::Pu128; use rustc_data_structures::stable_hasher::{HashStable, StableHasher}; @@ -35,12 +29,17 @@ use rustc_data_structures::sync::Lrc; use rustc_macros::{Decodable, Encodable, HashStable_Generic}; use rustc_span::source_map::{respan, Spanned}; use rustc_span::symbol::{kw, sym, Ident, Symbol}; +pub use rustc_span::AttrId; use rustc_span::{ErrorGuaranteed, Span, DUMMY_SP}; -use std::borrow::Cow; -use std::cmp; -use std::fmt; -use std::mem; use thin_vec::{thin_vec, ThinVec}; +pub use GenericArgs::*; +pub use UnsafeSource::*; + +pub use crate::format::*; +use crate::ptr::P; +use crate::token::{self, CommentKind, Delimiter}; +use crate::tokenstream::{DelimSpan, LazyAttrTokenStream, TokenStream}; +pub use crate::util::parser::ExprPrecedence; /// A "Label" is an identifier of some point in sources, /// e.g. in the following code: @@ -3491,8 +3490,9 @@ pub type ForeignItem = Item<ForeignItemKind>; // Some nodes are used a lot. Make sure they don't unintentionally get bigger. #[cfg(target_pointer_width = "64")] mod size_asserts { - use super::*; use rustc_data_structures::static_assert_size; + + use super::*; // tidy-alphabetical-start static_assert_size!(AssocItem, 88); static_assert_size!(AssocItemKind, 16); diff --git a/compiler/rustc_ast/src/ast_traits.rs b/compiler/rustc_ast/src/ast_traits.rs index 7754ca0a0f5..6b95fb7dd36 100644 --- a/compiler/rustc_ast/src/ast_traits.rs +++ b/compiler/rustc_ast/src/ast_traits.rs @@ -2,16 +2,17 @@ //! typically those used in AST fragments during macro expansion. //! The traits are not implemented exhaustively, only when actually necessary. +use std::fmt; +use std::marker::PhantomData; + use crate::ptr::P; use crate::token::Nonterminal; use crate::tokenstream::LazyAttrTokenStream; -use crate::{Arm, Crate, ExprField, FieldDef, GenericParam, Param, PatField, Variant}; -use crate::{AssocItem, Expr, ForeignItem, Item, NodeId}; -use crate::{AttrItem, AttrKind, Block, Pat, Path, Ty, Visibility}; -use crate::{AttrVec, Attribute, Stmt, StmtKind}; - -use std::fmt; -use std::marker::PhantomData; +use crate::{ + Arm, AssocItem, AttrItem, AttrKind, AttrVec, Attribute, Block, Crate, Expr, ExprField, + FieldDef, ForeignItem, GenericParam, Item, NodeId, Param, Pat, PatField, Path, Stmt, StmtKind, + Ty, Variant, Visibility, +}; /// A utility trait to reduce boilerplate. /// Standard `Deref(Mut)` cannot be reused due to coherence. diff --git a/compiler/rustc_ast/src/attr/mod.rs b/compiler/rustc_ast/src/attr/mod.rs index d2c7b1c0753..94a00ab1a04 100644 --- a/compiler/rustc_ast/src/attr/mod.rs +++ b/compiler/rustc_ast/src/attr/mod.rs @@ -1,24 +1,24 @@ //! Functions dealing with attributes and meta items. +use std::iter; +use std::sync::atomic::{AtomicU32, Ordering}; + +use rustc_index::bit_set::GrowableBitSet; +use rustc_span::symbol::{sym, Ident, Symbol}; +use rustc_span::Span; +use smallvec::{smallvec, SmallVec}; +use thin_vec::{thin_vec, ThinVec}; + use crate::ast::{ - AttrArgs, AttrArgsEq, AttrId, AttrItem, AttrKind, AttrStyle, AttrVec, Attribute, Safety, + AttrArgs, AttrArgsEq, AttrId, AttrItem, AttrKind, AttrStyle, AttrVec, Attribute, DelimArgs, + Expr, ExprKind, LitKind, MetaItem, MetaItemKind, MetaItemLit, NestedMetaItem, NormalAttr, Path, + PathSegment, Safety, DUMMY_NODE_ID, }; -use crate::ast::{DelimArgs, Expr, ExprKind, LitKind, MetaItemLit}; -use crate::ast::{MetaItem, MetaItemKind, NestedMetaItem, NormalAttr}; -use crate::ast::{Path, PathSegment, DUMMY_NODE_ID}; use crate::ptr::P; use crate::token::{self, CommentKind, Delimiter, Token}; -use crate::tokenstream::{DelimSpan, Spacing, TokenTree}; -use crate::tokenstream::{LazyAttrTokenStream, TokenStream}; +use crate::tokenstream::{DelimSpan, LazyAttrTokenStream, Spacing, TokenStream, TokenTree}; use crate::util::comments; use crate::util::literal::escape_string_symbol; -use rustc_index::bit_set::GrowableBitSet; -use rustc_span::symbol::{sym, Ident, Symbol}; -use rustc_span::Span; -use smallvec::{smallvec, SmallVec}; -use std::iter; -use std::sync::atomic::{AtomicU32, Ordering}; -use thin_vec::{thin_vec, ThinVec}; pub struct MarkedAttrs(GrowableBitSet<AttrId>); diff --git a/compiler/rustc_ast/src/entry.rs b/compiler/rustc_ast/src/entry.rs index dd231e286d5..60a12614f06 100644 --- a/compiler/rustc_ast/src/entry.rs +++ b/compiler/rustc_ast/src/entry.rs @@ -1,7 +1,8 @@ -use crate::{attr, Attribute}; use rustc_span::symbol::sym; use rustc_span::Symbol; +use crate::{attr, Attribute}; + #[derive(Debug)] pub enum EntryPointType { /// This function is not an entrypoint. diff --git a/compiler/rustc_ast/src/expand/mod.rs b/compiler/rustc_ast/src/expand/mod.rs index 37caadd0414..13413281bc7 100644 --- a/compiler/rustc_ast/src/expand/mod.rs +++ b/compiler/rustc_ast/src/expand/mod.rs @@ -1,7 +1,8 @@ //! Definitions shared by macros / syntax extensions and e.g. `rustc_middle`. use rustc_macros::{Decodable, Encodable, HashStable_Generic}; -use rustc_span::{def_id::DefId, symbol::Ident}; +use rustc_span::def_id::DefId; +use rustc_span::symbol::Ident; use crate::MetaItem; diff --git a/compiler/rustc_ast/src/format.rs b/compiler/rustc_ast/src/format.rs index 49910e2283d..e72d32d9b75 100644 --- a/compiler/rustc_ast/src/format.rs +++ b/compiler/rustc_ast/src/format.rs @@ -1,10 +1,11 @@ -use crate::ptr::P; -use crate::Expr; use rustc_data_structures::fx::FxHashMap; use rustc_macros::{Decodable, Encodable}; use rustc_span::symbol::{Ident, Symbol}; use rustc_span::Span; +use crate::ptr::P; +use crate::Expr; + // Definitions: // // format_args!("hello {abc:.xyz$}!!", abc="world"); diff --git a/compiler/rustc_ast/src/lib.rs b/compiler/rustc_ast/src/lib.rs index 846a108091f..27e9f3d137f 100644 --- a/compiler/rustc_ast/src/lib.rs +++ b/compiler/rustc_ast/src/lib.rs @@ -43,11 +43,11 @@ pub mod token; pub mod tokenstream; pub mod visit; +use rustc_data_structures::stable_hasher::{HashStable, StableHasher}; + pub use self::ast::*; pub use self::ast_traits::{AstDeref, AstNodeWrapper, HasAttrs, HasNodeId, HasTokens}; -use rustc_data_structures::stable_hasher::{HashStable, StableHasher}; - /// Requirements for a `StableHashingContext` to be used in this crate. /// This is a hack to allow using the `HashStable_Generic` derive macro /// instead of implementing everything in `rustc_middle`. diff --git a/compiler/rustc_ast/src/mut_visit.rs b/compiler/rustc_ast/src/mut_visit.rs index 8387e4499ae..8a66894a356 100644 --- a/compiler/rustc_ast/src/mut_visit.rs +++ b/compiler/rustc_ast/src/mut_visit.rs @@ -7,11 +7,8 @@ //! a `MutVisitor` renaming item names in a module will miss all of those //! that are created by the expansion of a macro. -use crate::ast::*; -use crate::ptr::P; -use crate::token::{self, Token}; -use crate::tokenstream::*; -use crate::visit::{AssocCtxt, BoundKind}; +use std::ops::DerefMut; +use std::panic; use rustc_data_structures::flat_map_in_place::FlatMapInPlace; use rustc_data_structures::stack::ensure_sufficient_stack; @@ -20,10 +17,14 @@ use rustc_span::source_map::Spanned; use rustc_span::symbol::Ident; use rustc_span::Span; use smallvec::{smallvec, Array, SmallVec}; -use std::ops::DerefMut; -use std::panic; use thin_vec::ThinVec; +use crate::ast::*; +use crate::ptr::P; +use crate::token::{self, Token}; +use crate::tokenstream::*; +use crate::visit::{AssocCtxt, BoundKind}; + pub trait ExpectOne<A: Array> { fn expect_one(self, err: &'static str) -> A::Item; } diff --git a/compiler/rustc_ast/src/node_id.rs b/compiler/rustc_ast/src/node_id.rs index 1cd24495309..adca1844b61 100644 --- a/compiler/rustc_ast/src/node_id.rs +++ b/compiler/rustc_ast/src/node_id.rs @@ -1,6 +1,7 @@ -use rustc_span::LocalExpnId; use std::fmt; +use rustc_span::LocalExpnId; + rustc_index::newtype_index! { /// Identifies an AST node. /// diff --git a/compiler/rustc_ast/src/ptr.rs b/compiler/rustc_ast/src/ptr.rs index 34c539ea16b..97c714df8fd 100644 --- a/compiler/rustc_ast/src/ptr.rs +++ b/compiler/rustc_ast/src/ptr.rs @@ -21,9 +21,8 @@ use std::fmt::{self, Debug, Display}; use std::ops::{Deref, DerefMut}; use std::{slice, vec}; -use rustc_serialize::{Decodable, Decoder, Encodable, Encoder}; - use rustc_data_structures::stable_hasher::{HashStable, StableHasher}; +use rustc_serialize::{Decodable, Decoder, Encodable, Encoder}; /// An owned smart pointer. /// /// See the [module level documentation][crate::ptr] for details. diff --git a/compiler/rustc_ast/src/token.rs b/compiler/rustc_ast/src/token.rs index 9478da236c3..43d87b96ead 100644 --- a/compiler/rustc_ast/src/token.rs +++ b/compiler/rustc_ast/src/token.rs @@ -1,3 +1,15 @@ +use std::borrow::Cow; +use std::fmt; + +use rustc_data_structures::stable_hasher::{HashStable, StableHasher}; +use rustc_data_structures::sync::Lrc; +use rustc_macros::{Decodable, Encodable, HashStable_Generic}; +use rustc_span::edition::Edition; +use rustc_span::symbol::{kw, sym}; +#[allow(clippy::useless_attribute)] // FIXME: following use of `hidden_glob_reexports` incorrectly triggers `useless_attribute` lint. +#[allow(hidden_glob_reexports)] +use rustc_span::symbol::{Ident, Symbol}; +use rustc_span::{ErrorGuaranteed, Span, DUMMY_SP}; pub use BinOpToken::*; pub use LitKind::*; pub use Nonterminal::*; @@ -9,17 +21,6 @@ use crate::ast; use crate::ptr::P; use crate::util::case::Case; -use rustc_data_structures::stable_hasher::{HashStable, StableHasher}; -use rustc_data_structures::sync::Lrc; -use rustc_macros::{Decodable, Encodable, HashStable_Generic}; -use rustc_span::symbol::{kw, sym}; -#[allow(clippy::useless_attribute)] // FIXME: following use of `hidden_glob_reexports` incorrectly triggers `useless_attribute` lint. -#[allow(hidden_glob_reexports)] -use rustc_span::symbol::{Ident, Symbol}; -use rustc_span::{edition::Edition, ErrorGuaranteed, Span, DUMMY_SP}; -use std::borrow::Cow; -use std::fmt; - #[derive(Clone, Copy, PartialEq, Encodable, Decodable, Debug, HashStable_Generic)] pub enum CommentKind { Line, @@ -1062,8 +1063,9 @@ where // Some types are used a lot. Make sure they don't unintentionally get bigger. #[cfg(target_pointer_width = "64")] mod size_asserts { - use super::*; use rustc_data_structures::static_assert_size; + + use super::*; // tidy-alphabetical-start static_assert_size!(Lit, 12); static_assert_size!(LitKind, 2); diff --git a/compiler/rustc_ast/src/tokenstream.rs b/compiler/rustc_ast/src/tokenstream.rs index a92ef575777..057b4455dca 100644 --- a/compiler/rustc_ast/src/tokenstream.rs +++ b/compiler/rustc_ast/src/tokenstream.rs @@ -13,10 +13,8 @@ //! and a borrowed `TokenStream` is sufficient to build an owned `TokenStream` without taking //! ownership of the original. -use crate::ast::{AttrStyle, StmtKind}; -use crate::ast_traits::{HasAttrs, HasTokens}; -use crate::token::{self, Delimiter, Nonterminal, Token, TokenKind}; -use crate::{AttrVec, Attribute}; +use std::borrow::Cow; +use std::{cmp, fmt, iter}; use rustc_data_structures::stable_hasher::{HashStable, StableHasher}; use rustc_data_structures::sync::{self, Lrc}; @@ -24,8 +22,10 @@ use rustc_macros::{Decodable, Encodable, HashStable_Generic}; use rustc_serialize::{Decodable, Encodable}; use rustc_span::{sym, Span, SpanDecoder, SpanEncoder, Symbol, DUMMY_SP}; -use std::borrow::Cow; -use std::{cmp, fmt, iter}; +use crate::ast::{AttrStyle, StmtKind}; +use crate::ast_traits::{HasAttrs, HasTokens}; +use crate::token::{self, Delimiter, Nonterminal, Token, TokenKind}; +use crate::{AttrVec, Attribute}; /// Part of a `TokenStream`. #[derive(Debug, Clone, PartialEq, Encodable, Decodable, HashStable_Generic)] @@ -767,8 +767,9 @@ impl DelimSpacing { // Some types are used a lot. Make sure they don't unintentionally get bigger. #[cfg(target_pointer_width = "64")] mod size_asserts { - use super::*; use rustc_data_structures::static_assert_size; + + use super::*; // tidy-alphabetical-start static_assert_size!(AttrTokenStream, 8); static_assert_size!(AttrTokenTree, 32); diff --git a/compiler/rustc_ast/src/util/comments.rs b/compiler/rustc_ast/src/util/comments.rs index cbc1afc6bf1..f39142f08ba 100644 --- a/compiler/rustc_ast/src/util/comments.rs +++ b/compiler/rustc_ast/src/util/comments.rs @@ -1,6 +1,7 @@ -use crate::token::CommentKind; use rustc_span::{BytePos, Symbol}; +use crate::token::CommentKind; + #[cfg(test)] mod tests; diff --git a/compiler/rustc_ast/src/util/comments/tests.rs b/compiler/rustc_ast/src/util/comments/tests.rs index 11d50603a10..61bb2468e79 100644 --- a/compiler/rustc_ast/src/util/comments/tests.rs +++ b/compiler/rustc_ast/src/util/comments/tests.rs @@ -1,6 +1,7 @@ -use super::*; use rustc_span::create_default_session_globals_then; +use super::*; + #[test] fn test_block_doc_comment_1() { create_default_session_globals_then(|| { diff --git a/compiler/rustc_ast/src/util/literal.rs b/compiler/rustc_ast/src/util/literal.rs index cb73b7908c2..3bd2a80d361 100644 --- a/compiler/rustc_ast/src/util/literal.rs +++ b/compiler/rustc_ast/src/util/literal.rs @@ -1,15 +1,17 @@ //! Code related to parsing literals. -use crate::ast::{self, LitKind, MetaItemLit, StrStyle}; -use crate::token::{self, Token}; +use std::{ascii, fmt, str}; + use rustc_lexer::unescape::{ byte_from_char, unescape_byte, unescape_char, unescape_mixed, unescape_unicode, MixedUnit, Mode, }; use rustc_span::symbol::{kw, sym, Symbol}; use rustc_span::Span; -use std::{ascii, fmt, str}; use tracing::debug; +use crate::ast::{self, LitKind, MetaItemLit, StrStyle}; +use crate::token::{self, Token}; + // Escapes a string, represented as a symbol. Reuses the original symbol, // avoiding interning, if no changes are required. pub fn escape_string_symbol(symbol: Symbol) -> Symbol { diff --git a/compiler/rustc_ast/src/util/parser.rs b/compiler/rustc_ast/src/util/parser.rs index ad92bf2cd40..8436c760d16 100644 --- a/compiler/rustc_ast/src/util/parser.rs +++ b/compiler/rustc_ast/src/util/parser.rs @@ -1,6 +1,7 @@ +use rustc_span::symbol::kw; + use crate::ast::{self, BinOpKind}; use crate::token::{self, BinOpToken, Token}; -use rustc_span::symbol::kw; /// Associative operator with precedence. /// diff --git a/compiler/rustc_ast/src/visit.rs b/compiler/rustc_ast/src/visit.rs index f6929057bed..fe07ec48f1f 100644 --- a/compiler/rustc_ast/src/visit.rs +++ b/compiler/rustc_ast/src/visit.rs @@ -13,14 +13,13 @@ //! instance, a walker looking for item names in a module will miss all of //! those that are created by the expansion of a macro. -use crate::ast::*; -use crate::ptr::P; - +pub use rustc_ast_ir::visit::VisitorResult; +pub use rustc_ast_ir::{try_visit, visit_opt, walk_list, walk_visitable_list}; use rustc_span::symbol::Ident; use rustc_span::Span; -pub use rustc_ast_ir::visit::VisitorResult; -pub use rustc_ast_ir::{try_visit, visit_opt, walk_list, walk_visitable_list}; +use crate::ast::*; +use crate::ptr::P; #[derive(Copy, Clone, Debug, PartialEq)] pub enum AssocCtxt { | 
