Skip to content

Commit 1fef435

Browse files
committed
Reformat use declarations.
As decided in rust-lang/compiler-team#750. Use declarations are currently wildly inconsistent because rustfmt is quite unopinionated about how they should be formatted. The `rustfmt.toml` additions makes rustfmt more opinionated, which avoids the need for any decision when adding new use declarations to a file.
1 parent bb8a398 commit 1fef435

File tree

1,816 files changed

+8254
-9086
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

1,816 files changed

+8254
-9086
lines changed

compiler/rustc_abi/src/layout.rs

+4-5
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,7 @@
11
use std::borrow::{Borrow, Cow};
2-
use std::cmp;
32
use std::fmt::{self, Write};
4-
use std::iter;
5-
use std::ops::Bound;
6-
use std::ops::Deref;
3+
use std::ops::{Bound, Deref};
4+
use std::{cmp, iter};
75

86
use rustc_index::Idx;
97
use tracing::debug;
@@ -982,7 +980,8 @@ fn univariant<
982980
if repr.can_randomize_type_layout() && cfg!(feature = "randomize") {
983981
#[cfg(feature = "randomize")]
984982
{
985-
use rand::{seq::SliceRandom, SeedableRng};
983+
use rand::seq::SliceRandom;
984+
use rand::SeedableRng;
986985
// `ReprOptions.field_shuffle_seed` is a deterministic seed we can use to randomize field
987986
// ordering.
988987
let mut rng =

compiler/rustc_abi/src/lib.rs

+3-4
Original file line numberDiff line numberDiff line change
@@ -4,21 +4,20 @@
44
#![cfg_attr(feature = "nightly", feature(rustdoc_internals))]
55

66
use std::fmt;
7+
#[cfg(feature = "nightly")]
8+
use std::iter::Step;
79
use std::num::{NonZeroUsize, ParseIntError};
810
use std::ops::{Add, AddAssign, Mul, RangeInclusive, Sub};
911
use std::str::FromStr;
1012

1113
use bitflags::bitflags;
12-
use rustc_index::{Idx, IndexSlice, IndexVec};
13-
1414
#[cfg(feature = "nightly")]
1515
use rustc_data_structures::stable_hasher::StableOrd;
16+
use rustc_index::{Idx, IndexSlice, IndexVec};
1617
#[cfg(feature = "nightly")]
1718
use rustc_macros::HashStable_Generic;
1819
#[cfg(feature = "nightly")]
1920
use rustc_macros::{Decodable_Generic, Encodable_Generic};
20-
#[cfg(feature = "nightly")]
21-
use std::iter::Step;
2221

2322
mod layout;
2423
#[cfg(test)]

compiler/rustc_arena/src/lib.rs

+3-4
Original file line numberDiff line numberDiff line change
@@ -25,15 +25,14 @@
2525
#![allow(internal_features)]
2626
#![allow(clippy::mut_from_ref)] // Arena allocators are one of the places where this pattern is fine.
2727

28-
use smallvec::SmallVec;
29-
3028
use std::alloc::Layout;
3129
use std::cell::{Cell, RefCell};
3230
use std::marker::PhantomData;
3331
use std::mem::{self, MaybeUninit};
3432
use std::ptr::{self, NonNull};
35-
use std::slice;
36-
use std::{cmp, intrinsics};
33+
use std::{cmp, intrinsics, slice};
34+
35+
use smallvec::SmallVec;
3736

3837
/// This calls the passed function while ensuring it won't be inlined into the caller.
3938
#[inline(never)]

compiler/rustc_arena/src/tests.rs

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
extern crate test;
2-
use super::TypedArena;
32
use std::cell::Cell;
3+
44
use test::Bencher;
55

6+
use super::TypedArena;
7+
68
#[allow(dead_code)]
79
#[derive(Debug, Eq, PartialEq)]
810
struct Point {

compiler/rustc_ast/src/ast.rs

+12-12
Original file line numberDiff line numberDiff line change
@@ -18,15 +18,8 @@
1818
//! - [`Attribute`]: Metadata associated with item.
1919
//! - [`UnOp`], [`BinOp`], and [`BinOpKind`]: Unary and binary operators.
2020
21-
pub use crate::format::*;
22-
pub use crate::util::parser::ExprPrecedence;
23-
pub use rustc_span::AttrId;
24-
pub use GenericArgs::*;
25-
pub use UnsafeSource::*;
21+
use std::{cmp, fmt, mem};
2622

27-
use crate::ptr::P;
28-
use crate::token::{self, CommentKind, Delimiter};
29-
use crate::tokenstream::{DelimSpan, LazyAttrTokenStream, TokenStream};
3023
pub use rustc_ast_ir::{Movability, Mutability};
3124
use rustc_data_structures::packed::Pu128;
3225
use rustc_data_structures::stable_hasher::{HashStable, StableHasher};
@@ -35,11 +28,17 @@ use rustc_data_structures::sync::Lrc;
3528
use rustc_macros::{Decodable, Encodable, HashStable_Generic};
3629
use rustc_span::source_map::{respan, Spanned};
3730
use rustc_span::symbol::{kw, sym, Ident, Symbol};
31+
pub use rustc_span::AttrId;
3832
use rustc_span::{ErrorGuaranteed, Span, DUMMY_SP};
39-
use std::cmp;
40-
use std::fmt;
41-
use std::mem;
4233
use thin_vec::{thin_vec, ThinVec};
34+
pub use GenericArgs::*;
35+
pub use UnsafeSource::*;
36+
37+
pub use crate::format::*;
38+
use crate::ptr::P;
39+
use crate::token::{self, CommentKind, Delimiter};
40+
use crate::tokenstream::{DelimSpan, LazyAttrTokenStream, TokenStream};
41+
pub use crate::util::parser::ExprPrecedence;
4342

4443
/// A "Label" is an identifier of some point in sources,
4544
/// e.g. in the following code:
@@ -3465,8 +3464,9 @@ pub type ForeignItem = Item<ForeignItemKind>;
34653464
// Some nodes are used a lot. Make sure they don't unintentionally get bigger.
34663465
#[cfg(target_pointer_width = "64")]
34673466
mod size_asserts {
3468-
use super::*;
34693467
use rustc_data_structures::static_assert_size;
3468+
3469+
use super::*;
34703470
// tidy-alphabetical-start
34713471
static_assert_size!(AssocItem, 88);
34723472
static_assert_size!(AssocItemKind, 16);

compiler/rustc_ast/src/ast_traits.rs

+10-9
Original file line numberDiff line numberDiff line change
@@ -2,18 +2,19 @@
22
//! typically those used in AST fragments during macro expansion.
33
//! The traits are not implemented exhaustively, only when actually necessary.
44
5-
use crate::ptr::P;
6-
use crate::token::Nonterminal;
7-
use crate::tokenstream::LazyAttrTokenStream;
8-
use crate::{Arm, Crate, ExprField, FieldDef, GenericParam, Param, PatField, Variant};
9-
use crate::{AssocItem, Expr, ForeignItem, Item, NodeId};
10-
use crate::{AttrItem, AttrKind, Block, Pat, Path, Ty, Visibility};
11-
use crate::{AttrVec, Attribute, Stmt, StmtKind};
5+
use std::fmt;
6+
use std::marker::PhantomData;
127

138
use rustc_span::Span;
149

15-
use std::fmt;
16-
use std::marker::PhantomData;
10+
use crate::ptr::P;
11+
use crate::token::Nonterminal;
12+
use crate::tokenstream::LazyAttrTokenStream;
13+
use crate::{
14+
Arm, AssocItem, AttrItem, AttrKind, AttrVec, Attribute, Block, Crate, Expr, ExprField,
15+
FieldDef, ForeignItem, GenericParam, Item, NodeId, Param, Pat, PatField, Path, Stmt, StmtKind,
16+
Ty, Variant, Visibility,
17+
};
1718

1819
/// A utility trait to reduce boilerplate.
1920
/// Standard `Deref(Mut)` cannot be reused due to coherence.

compiler/rustc_ast/src/attr/mod.rs

+13-13
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,24 @@
11
//! Functions dealing with attributes and meta items.
22
3+
use std::iter;
4+
use std::sync::atomic::{AtomicU32, Ordering};
5+
6+
use rustc_index::bit_set::GrowableBitSet;
7+
use rustc_span::symbol::{sym, Ident, Symbol};
8+
use rustc_span::Span;
9+
use smallvec::{smallvec, SmallVec};
10+
use thin_vec::{thin_vec, ThinVec};
11+
312
use crate::ast::{
4-
AttrArgs, AttrArgsEq, AttrId, AttrItem, AttrKind, AttrStyle, AttrVec, Attribute, Safety,
13+
AttrArgs, AttrArgsEq, AttrId, AttrItem, AttrKind, AttrStyle, AttrVec, Attribute, DelimArgs,
14+
Expr, ExprKind, LitKind, MetaItem, MetaItemKind, MetaItemLit, NestedMetaItem, NormalAttr, Path,
15+
PathSegment, Safety, DUMMY_NODE_ID,
516
};
6-
use crate::ast::{DelimArgs, Expr, ExprKind, LitKind, MetaItemLit};
7-
use crate::ast::{MetaItem, MetaItemKind, NestedMetaItem, NormalAttr};
8-
use crate::ast::{Path, PathSegment, DUMMY_NODE_ID};
917
use crate::ptr::P;
1018
use crate::token::{self, CommentKind, Delimiter, Token};
11-
use crate::tokenstream::{DelimSpan, Spacing, TokenTree};
12-
use crate::tokenstream::{LazyAttrTokenStream, TokenStream};
19+
use crate::tokenstream::{DelimSpan, LazyAttrTokenStream, Spacing, TokenStream, TokenTree};
1320
use crate::util::comments;
1421
use crate::util::literal::escape_string_symbol;
15-
use rustc_index::bit_set::GrowableBitSet;
16-
use rustc_span::symbol::{sym, Ident, Symbol};
17-
use rustc_span::Span;
18-
use smallvec::{smallvec, SmallVec};
19-
use std::iter;
20-
use std::sync::atomic::{AtomicU32, Ordering};
21-
use thin_vec::{thin_vec, ThinVec};
2222

2323
pub struct MarkedAttrs(GrowableBitSet<AttrId>);
2424

compiler/rustc_ast/src/entry.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
1-
use crate::{attr, Attribute};
21
use rustc_span::symbol::sym;
32
use rustc_span::Symbol;
43

4+
use crate::{attr, Attribute};
5+
56
#[derive(Debug)]
67
pub enum EntryPointType {
78
/// This function is not an entrypoint.

compiler/rustc_ast/src/expand/mod.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
//! Definitions shared by macros / syntax extensions and e.g. `rustc_middle`.
22
33
use rustc_macros::{Decodable, Encodable, HashStable_Generic};
4-
use rustc_span::{def_id::DefId, symbol::Ident};
4+
use rustc_span::def_id::DefId;
5+
use rustc_span::symbol::Ident;
56

67
use crate::MetaItem;
78

compiler/rustc_ast/src/format.rs

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
1-
use crate::ptr::P;
2-
use crate::Expr;
31
use rustc_data_structures::fx::FxHashMap;
42
use rustc_macros::{Decodable, Encodable};
53
use rustc_span::symbol::{Ident, Symbol};
64
use rustc_span::Span;
75

6+
use crate::ptr::P;
7+
use crate::Expr;
8+
89
// Definitions:
910
//
1011
// format_args!("hello {abc:.xyz$}!!", abc="world");

compiler/rustc_ast/src/lib.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -41,11 +41,11 @@ pub mod token;
4141
pub mod tokenstream;
4242
pub mod visit;
4343

44+
use rustc_data_structures::stable_hasher::{HashStable, StableHasher};
45+
4446
pub use self::ast::*;
4547
pub use self::ast_traits::{AstDeref, AstNodeWrapper, HasAttrs, HasNodeId, HasSpan, HasTokens};
4648

47-
use rustc_data_structures::stable_hasher::{HashStable, StableHasher};
48-
4949
/// Requirements for a `StableHashingContext` to be used in this crate.
5050
/// This is a hack to allow using the `HashStable_Generic` derive macro
5151
/// instead of implementing everything in `rustc_middle`.

compiler/rustc_ast/src/mut_visit.rs

+7-6
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,8 @@
77
//! a `MutVisitor` renaming item names in a module will miss all of those
88
//! that are created by the expansion of a macro.
99
10-
use crate::ast::*;
11-
use crate::ptr::P;
12-
use crate::token::{self, Token};
13-
use crate::tokenstream::*;
10+
use std::ops::DerefMut;
11+
use std::{panic, ptr};
1412

1513
use rustc_data_structures::flat_map_in_place::FlatMapInPlace;
1614
use rustc_data_structures::stack::ensure_sufficient_stack;
@@ -19,10 +17,13 @@ use rustc_span::source_map::Spanned;
1917
use rustc_span::symbol::Ident;
2018
use rustc_span::Span;
2119
use smallvec::{smallvec, Array, SmallVec};
22-
use std::ops::DerefMut;
23-
use std::{panic, ptr};
2420
use thin_vec::ThinVec;
2521

22+
use crate::ast::*;
23+
use crate::ptr::P;
24+
use crate::token::{self, Token};
25+
use crate::tokenstream::*;
26+
2627
pub trait ExpectOne<A: Array> {
2728
fn expect_one(self, err: &'static str) -> A::Item;
2829
}

compiler/rustc_ast/src/node_id.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
1-
use rustc_span::LocalExpnId;
21
use std::fmt;
32

3+
use rustc_span::LocalExpnId;
4+
45
rustc_index::newtype_index! {
56
/// Identifies an AST node.
67
///

compiler/rustc_ast/src/ptr.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,8 @@ use std::fmt::{self, Debug, Display};
2121
use std::ops::{Deref, DerefMut};
2222
use std::{slice, vec};
2323

24-
use rustc_serialize::{Decodable, Decoder, Encodable, Encoder};
25-
2624
use rustc_data_structures::stable_hasher::{HashStable, StableHasher};
25+
use rustc_serialize::{Decodable, Decoder, Encodable, Encoder};
2726
/// An owned smart pointer.
2827
///
2928
/// See the [module level documentation][crate::ptr] for details.

compiler/rustc_ast/src/token.rs

+14-12
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,23 @@
1-
pub use BinOpToken::*;
2-
pub use LitKind::*;
3-
pub use Nonterminal::*;
4-
pub use TokenKind::*;
5-
6-
use crate::ast;
7-
use crate::ptr::P;
8-
use crate::util::case::Case;
1+
use std::borrow::Cow;
2+
use std::fmt;
93

104
use rustc_data_structures::stable_hasher::{HashStable, StableHasher};
115
use rustc_data_structures::sync::Lrc;
126
use rustc_macros::{Decodable, Encodable, HashStable_Generic};
7+
use rustc_span::edition::Edition;
138
use rustc_span::symbol::{kw, sym};
149
#[allow(clippy::useless_attribute)] // FIXME: following use of `hidden_glob_reexports` incorrectly triggers `useless_attribute` lint.
1510
#[allow(hidden_glob_reexports)]
1611
use rustc_span::symbol::{Ident, Symbol};
17-
use rustc_span::{edition::Edition, ErrorGuaranteed, Span, DUMMY_SP};
18-
use std::borrow::Cow;
19-
use std::fmt;
12+
use rustc_span::{ErrorGuaranteed, Span, DUMMY_SP};
13+
pub use BinOpToken::*;
14+
pub use LitKind::*;
15+
pub use Nonterminal::*;
16+
pub use TokenKind::*;
17+
18+
use crate::ast;
19+
use crate::ptr::P;
20+
use crate::util::case::Case;
2021

2122
#[derive(Clone, Copy, PartialEq, Encodable, Decodable, Debug, HashStable_Generic)]
2223
pub enum CommentKind {
@@ -1023,8 +1024,9 @@ where
10231024
// Some types are used a lot. Make sure they don't unintentionally get bigger.
10241025
#[cfg(target_pointer_width = "64")]
10251026
mod size_asserts {
1026-
use super::*;
10271027
use rustc_data_structures::static_assert_size;
1028+
1029+
use super::*;
10281030
// tidy-alphabetical-start
10291031
static_assert_size!(Lit, 12);
10301032
static_assert_size!(LitKind, 2);

compiler/rustc_ast/src/tokenstream.rs

+8-7
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,8 @@
1313
//! and a borrowed `TokenStream` is sufficient to build an owned `TokenStream` without taking
1414
//! ownership of the original.
1515
16-
use crate::ast::{AttrStyle, StmtKind};
17-
use crate::ast_traits::{HasAttrs, HasSpan, HasTokens};
18-
use crate::token::{self, Delimiter, Nonterminal, Token, TokenKind};
19-
use crate::AttrVec;
16+
use std::borrow::Cow;
17+
use std::{cmp, fmt, iter};
2018

2119
use rustc_data_structures::stable_hasher::{HashStable, StableHasher};
2220
use rustc_data_structures::sync::{self, Lrc};
@@ -25,8 +23,10 @@ use rustc_serialize::{Decodable, Encodable};
2523
use rustc_span::{sym, Span, SpanDecoder, SpanEncoder, Symbol, DUMMY_SP};
2624
use smallvec::{smallvec, SmallVec};
2725

28-
use std::borrow::Cow;
29-
use std::{cmp, fmt, iter};
26+
use crate::ast::{AttrStyle, StmtKind};
27+
use crate::ast_traits::{HasAttrs, HasSpan, HasTokens};
28+
use crate::token::{self, Delimiter, Nonterminal, Token, TokenKind};
29+
use crate::AttrVec;
3030

3131
/// Part of a `TokenStream`.
3232
#[derive(Debug, Clone, PartialEq, Encodable, Decodable, HashStable_Generic)]
@@ -772,8 +772,9 @@ impl DelimSpacing {
772772
// Some types are used a lot. Make sure they don't unintentionally get bigger.
773773
#[cfg(target_pointer_width = "64")]
774774
mod size_asserts {
775-
use super::*;
776775
use rustc_data_structures::static_assert_size;
776+
777+
use super::*;
777778
// tidy-alphabetical-start
778779
static_assert_size!(AttrTokenStream, 8);
779780
static_assert_size!(AttrTokenTree, 32);

compiler/rustc_ast/src/util/classify.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
//! Routines the parser and pretty-printer use to classify AST nodes.
22
3+
use crate::ast;
34
use crate::ast::ExprKind::*;
4-
use crate::{ast, token::Delimiter};
5+
use crate::token::Delimiter;
56

67
/// This classification determines whether various syntactic positions break out
78
/// of parsing the current expression (true) or continue parsing more of the

compiler/rustc_ast/src/util/comments.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
1-
use crate::token::CommentKind;
21
use rustc_span::{BytePos, Symbol};
32

3+
use crate::token::CommentKind;
4+
45
#[cfg(test)]
56
mod tests;
67

0 commit comments

Comments
 (0)