about summary refs log tree commit diff
path: root/library/alloc/src/collections
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2024-07-29 02:43:41 +0000
committerbors <bors@rust-lang.org>2024-07-29 02:43:41 +0000
commit2e630267b2bce50af3258ce4817e377fa09c145b (patch)
tree29006db815bf547dfd0129910b23b8c54675bd98 /library/alloc/src/collections
parent2cbbe8b8bb2be672b14cf741a2f0ec24a49f3f0b (diff)
parent84ac80f1921afc243d71fd0caaa4f2838c294102 (diff)
Auto merge of #125443 - nnethercote:rustfmt-use-decls, r=lcnr,cuviper,GuillaumeGomez
rustfmt `use` declarations

This PR implements https://github.com/rust-lang/compiler-team/issues/750, which changes how `use` declarations are formatted by adding these options to `rustfmt.toml`:
```
group_imports = "StdExternalCrate"
imports_granularity = "Module"
```

r? `@ghost`
Diffstat (limited to 'library/alloc/src/collections')
-rw-r--r--library/alloc/src/collections/binary_heap/mod.rs3
-rw-r--r--library/alloc/src/collections/binary_heap/tests.rs6
-rw-r--r--library/alloc/src/collections/btree/append.rs5
-rw-r--r--library/alloc/src/collections/btree/fix.rs7
-rw-r--r--library/alloc/src/collections/btree/map.rs12
-rw-r--r--library/alloc/src/collections/btree/map/entry.rs5
-rw-r--r--library/alloc/src/collections/btree/map/tests.rs12
-rw-r--r--library/alloc/src/collections/btree/mem.rs4
-rw-r--r--library/alloc/src/collections/btree/navigate.rs7
-rw-r--r--library/alloc/src/collections/btree/remove.rs7
-rw-r--r--library/alloc/src/collections/btree/search.rs5
-rw-r--r--library/alloc/src/collections/btree/set.rs3
-rw-r--r--library/alloc/src/collections/btree/set/tests.rs5
-rw-r--r--library/alloc/src/collections/btree/split.rs6
-rw-r--r--library/alloc/src/collections/linked_list.rs3
-rw-r--r--library/alloc/src/collections/linked_list/tests.rs12
-rw-r--r--library/alloc/src/collections/mod.rs7
-rw-r--r--library/alloc/src/collections/vec_deque/drain.rs3
-rw-r--r--library/alloc/src/collections/vec_deque/into_iter.rs7
-rw-r--r--library/alloc/src/collections/vec_deque/mod.rs12
-rw-r--r--library/alloc/src/collections/vec_deque/spec_extend.rs4
21 files changed, 67 insertions, 68 deletions
diff --git a/library/alloc/src/collections/binary_heap/mod.rs b/library/alloc/src/collections/binary_heap/mod.rs
index 11aef5f913e..cc5f33c3685 100644
--- a/library/alloc/src/collections/binary_heap/mod.rs
+++ b/library/alloc/src/collections/binary_heap/mod.rs
@@ -144,12 +144,11 @@
 #![stable(feature = "rust1", since = "1.0.0")]
 
 use core::alloc::Allocator;
-use core::fmt;
 use core::iter::{FusedIterator, InPlaceIterable, SourceIter, TrustedFused, TrustedLen};
 use core::mem::{self, swap, ManuallyDrop};
 use core::num::NonZero;
 use core::ops::{Deref, DerefMut};
-use core::ptr;
+use core::{fmt, ptr};
 
 use crate::alloc::Global;
 use crate::collections::TryReserveError;
diff --git a/library/alloc/src/collections/binary_heap/tests.rs b/library/alloc/src/collections/binary_heap/tests.rs
index d4bc6226a14..1cb07c62149 100644
--- a/library/alloc/src/collections/binary_heap/tests.rs
+++ b/library/alloc/src/collections/binary_heap/tests.rs
@@ -1,7 +1,8 @@
+use std::panic::{catch_unwind, AssertUnwindSafe};
+
 use super::*;
 use crate::boxed::Box;
 use crate::testing::crash_test::{CrashTestDummy, Panic};
-use std::panic::{catch_unwind, AssertUnwindSafe};
 
 #[test]
 fn test_iterator() {
@@ -504,11 +505,12 @@ fn test_retain_catch_unwind() {
 #[cfg(not(target_os = "emscripten"))]
 #[cfg_attr(not(panic = "unwind"), ignore = "test requires unwinding support")]
 fn panic_safe() {
-    use rand::seq::SliceRandom;
     use std::cmp;
     use std::panic::{self, AssertUnwindSafe};
     use std::sync::atomic::{AtomicUsize, Ordering};
 
+    use rand::seq::SliceRandom;
+
     static DROP_COUNTER: AtomicUsize = AtomicUsize::new(0);
 
     #[derive(Eq, PartialEq, Ord, Clone, Debug)]
diff --git a/library/alloc/src/collections/btree/append.rs b/library/alloc/src/collections/btree/append.rs
index b6989afb625..47372938fbe 100644
--- a/library/alloc/src/collections/btree/append.rs
+++ b/library/alloc/src/collections/btree/append.rs
@@ -1,8 +1,9 @@
-use super::merge_iter::MergeIterInner;
-use super::node::{self, Root};
 use core::alloc::Allocator;
 use core::iter::FusedIterator;
 
+use super::merge_iter::MergeIterInner;
+use super::node::{self, Root};
+
 impl<K, V> Root<K, V> {
     /// Appends all key-value pairs from the union of two ascending iterators,
     /// incrementing a `length` variable along the way. The latter makes it
diff --git a/library/alloc/src/collections/btree/fix.rs b/library/alloc/src/collections/btree/fix.rs
index 91b61218005..4c1e19ead40 100644
--- a/library/alloc/src/collections/btree/fix.rs
+++ b/library/alloc/src/collections/btree/fix.rs
@@ -1,7 +1,10 @@
-use super::map::MIN_LEN;
-use super::node::{marker, ForceResult::*, Handle, LeftOrRight::*, NodeRef, Root};
 use core::alloc::Allocator;
 
+use super::map::MIN_LEN;
+use super::node::ForceResult::*;
+use super::node::LeftOrRight::*;
+use super::node::{marker, Handle, NodeRef, Root};
+
 impl<'a, K: 'a, V: 'a> NodeRef<marker::Mut<'a>, K, V, marker::LeafOrInternal> {
     /// Stocks up a possibly underfull node by merging with or stealing from a
     /// sibling. If successful but at the cost of shrinking the parent node,
diff --git a/library/alloc/src/collections/btree/map.rs b/library/alloc/src/collections/btree/map.rs
index 3875f61efaf..8fe4cd7144b 100644
--- a/library/alloc/src/collections/btree/map.rs
+++ b/library/alloc/src/collections/btree/map.rs
@@ -1,4 +1,3 @@
-use crate::vec::Vec;
 use core::borrow::Borrow;
 use core::cmp::Ordering;
 use core::error::Error;
@@ -10,20 +9,21 @@ use core::mem::{self, ManuallyDrop};
 use core::ops::{Bound, Index, RangeBounds};
 use core::ptr;
 
-use crate::alloc::{Allocator, Global};
-
 use super::borrow::DormantMutRef;
 use super::dedup_sorted_iter::DedupSortedIter;
 use super::navigate::{LazyLeafRange, LeafRange};
-use super::node::{self, marker, ForceResult::*, Handle, NodeRef, Root};
-use super::search::{SearchBound, SearchResult::*};
+use super::node::ForceResult::*;
+use super::node::{self, marker, Handle, NodeRef, Root};
+use super::search::SearchBound;
+use super::search::SearchResult::*;
 use super::set_val::SetValZST;
+use crate::alloc::{Allocator, Global};
+use crate::vec::Vec;
 
 mod entry;
 
 #[stable(feature = "rust1", since = "1.0.0")]
 pub use entry::{Entry, OccupiedEntry, OccupiedError, VacantEntry};
-
 use Entry::*;
 
 /// Minimum number of elements in a node that is not a root.
diff --git a/library/alloc/src/collections/btree/map/entry.rs b/library/alloc/src/collections/btree/map/entry.rs
index b5b389bbd25..d128ad8ee5f 100644
--- a/library/alloc/src/collections/btree/map/entry.rs
+++ b/library/alloc/src/collections/btree/map/entry.rs
@@ -2,13 +2,12 @@ use core::fmt::{self, Debug};
 use core::marker::PhantomData;
 use core::mem;
 
-use crate::alloc::{Allocator, Global};
+use Entry::*;
 
 use super::super::borrow::DormantMutRef;
 use super::super::node::{marker, Handle, NodeRef};
 use super::BTreeMap;
-
-use Entry::*;
+use crate::alloc::{Allocator, Global};
 
 /// A view into a single entry in a map, which may either be vacant or occupied.
 ///
diff --git a/library/alloc/src/collections/btree/map/tests.rs b/library/alloc/src/collections/btree/map/tests.rs
index ba1f38dcc3e..ff1254a5a0c 100644
--- a/library/alloc/src/collections/btree/map/tests.rs
+++ b/library/alloc/src/collections/btree/map/tests.rs
@@ -1,3 +1,10 @@
+use core::assert_matches::assert_matches;
+use std::iter;
+use std::ops::Bound::{Excluded, Included, Unbounded};
+use std::panic::{catch_unwind, AssertUnwindSafe};
+use std::sync::atomic::AtomicUsize;
+use std::sync::atomic::Ordering::SeqCst;
+
 use super::*;
 use crate::boxed::Box;
 use crate::fmt::Debug;
@@ -6,11 +13,6 @@ use crate::string::{String, ToString};
 use crate::testing::crash_test::{CrashTestDummy, Panic};
 use crate::testing::ord_chaos::{Cyclic3, Governed, Governor};
 use crate::testing::rng::DeterministicRng;
-use core::assert_matches::assert_matches;
-use std::iter;
-use std::ops::Bound::{Excluded, Included, Unbounded};
-use std::panic::{catch_unwind, AssertUnwindSafe};
-use std::sync::atomic::{AtomicUsize, Ordering::SeqCst};
 
 // Minimum number of elements to insert, to guarantee a tree with 2 levels,
 // i.e., a tree who's root is an internal node at height 1, with edges to leaf nodes.
diff --git a/library/alloc/src/collections/btree/mem.rs b/library/alloc/src/collections/btree/mem.rs
index e1363d1ae1f..d738c5c47b4 100644
--- a/library/alloc/src/collections/btree/mem.rs
+++ b/library/alloc/src/collections/btree/mem.rs
@@ -1,6 +1,4 @@
-use core::intrinsics;
-use core::mem;
-use core::ptr;
+use core::{intrinsics, mem, ptr};
 
 /// This replaces the value behind the `v` unique reference by calling the
 /// relevant function.
diff --git a/library/alloc/src/collections/btree/navigate.rs b/library/alloc/src/collections/btree/navigate.rs
index 5e6a26f65c4..f5c621e2c17 100644
--- a/library/alloc/src/collections/btree/navigate.rs
+++ b/library/alloc/src/collections/btree/navigate.rs
@@ -1,11 +1,10 @@
 use core::borrow::Borrow;
-use core::hint;
 use core::ops::RangeBounds;
-use core::ptr;
+use core::{hint, ptr};
 
-use super::node::{marker, ForceResult::*, Handle, NodeRef};
+use super::node::ForceResult::*;
+use super::node::{marker, Handle, NodeRef};
 use super::search::SearchBound;
-
 use crate::alloc::Allocator;
 // `front` and `back` are always both `None` or both `Some`.
 pub struct LeafRange<BorrowType, K, V> {
diff --git a/library/alloc/src/collections/btree/remove.rs b/library/alloc/src/collections/btree/remove.rs
index 0904299254f..c46422c2f1d 100644
--- a/library/alloc/src/collections/btree/remove.rs
+++ b/library/alloc/src/collections/btree/remove.rs
@@ -1,7 +1,10 @@
-use super::map::MIN_LEN;
-use super::node::{marker, ForceResult::*, Handle, LeftOrRight::*, NodeRef};
 use core::alloc::Allocator;
 
+use super::map::MIN_LEN;
+use super::node::ForceResult::*;
+use super::node::LeftOrRight::*;
+use super::node::{marker, Handle, NodeRef};
+
 impl<'a, K: 'a, V: 'a> Handle<NodeRef<marker::Mut<'a>, K, V, marker::LeafOrInternal>, marker::KV> {
     /// Removes a key-value pair from the tree, and returns that pair, as well as
     /// the leaf edge corresponding to that former pair. It's possible this empties
diff --git a/library/alloc/src/collections/btree/search.rs b/library/alloc/src/collections/btree/search.rs
index ad3522b4e04..1d5c927175e 100644
--- a/library/alloc/src/collections/btree/search.rs
+++ b/library/alloc/src/collections/btree/search.rs
@@ -2,11 +2,12 @@ use core::borrow::Borrow;
 use core::cmp::Ordering;
 use core::ops::{Bound, RangeBounds};
 
-use super::node::{marker, ForceResult::*, Handle, NodeRef};
-
 use SearchBound::*;
 use SearchResult::*;
 
+use super::node::ForceResult::*;
+use super::node::{marker, Handle, NodeRef};
+
 pub enum SearchBound<T> {
     /// An inclusive bound to look for, just like `Bound::Included(T)`.
     Included(T),
diff --git a/library/alloc/src/collections/btree/set.rs b/library/alloc/src/collections/btree/set.rs
index b0bd6ef2d3c..74b000fd1c4 100644
--- a/library/alloc/src/collections/btree/set.rs
+++ b/library/alloc/src/collections/btree/set.rs
@@ -1,4 +1,3 @@
-use crate::vec::Vec;
 use core::borrow::Borrow;
 use core::cmp::Ordering::{self, Equal, Greater, Less};
 use core::cmp::{max, min};
@@ -12,8 +11,8 @@ use super::map::{BTreeMap, Keys};
 use super::merge_iter::MergeIterInner;
 use super::set_val::SetValZST;
 use super::Recover;
-
 use crate::alloc::{Allocator, Global};
+use crate::vec::Vec;
 
 /// An ordered set based on a B-Tree.
 ///
diff --git a/library/alloc/src/collections/btree/set/tests.rs b/library/alloc/src/collections/btree/set/tests.rs
index 48bf7674138..f947b6108c9 100644
--- a/library/alloc/src/collections/btree/set/tests.rs
+++ b/library/alloc/src/collections/btree/set/tests.rs
@@ -1,8 +1,9 @@
+use std::ops::Bound::{Excluded, Included};
+use std::panic::{catch_unwind, AssertUnwindSafe};
+
 use super::*;
 use crate::testing::crash_test::{CrashTestDummy, Panic};
 use crate::testing::rng::DeterministicRng;
-use std::ops::Bound::{Excluded, Included};
-use std::panic::{catch_unwind, AssertUnwindSafe};
 
 #[test]
 fn test_clone_eq() {
diff --git a/library/alloc/src/collections/btree/split.rs b/library/alloc/src/collections/btree/split.rs
index 638dc98fc3e..c188ed1da61 100644
--- a/library/alloc/src/collections/btree/split.rs
+++ b/library/alloc/src/collections/btree/split.rs
@@ -1,8 +1,10 @@
-use super::node::{ForceResult::*, Root};
-use super::search::SearchResult::*;
 use core::alloc::Allocator;
 use core::borrow::Borrow;
 
+use super::node::ForceResult::*;
+use super::node::Root;
+use super::search::SearchResult::*;
+
 impl<K, V> Root<K, V> {
     /// Calculates the length of both trees that result from splitting up
     /// a given number of distinct key-value pairs.
diff --git a/library/alloc/src/collections/linked_list.rs b/library/alloc/src/collections/linked_list.rs
index 077483a174b..0cd410c0fb7 100644
--- a/library/alloc/src/collections/linked_list.rs
+++ b/library/alloc/src/collections/linked_list.rs
@@ -13,12 +13,11 @@
 #![stable(feature = "rust1", since = "1.0.0")]
 
 use core::cmp::Ordering;
-use core::fmt;
 use core::hash::{Hash, Hasher};
 use core::iter::FusedIterator;
 use core::marker::PhantomData;
-use core::mem;
 use core::ptr::NonNull;
+use core::{fmt, mem};
 
 use super::SpecExtend;
 use crate::alloc::{Allocator, Global};
diff --git a/library/alloc/src/collections/linked_list/tests.rs b/library/alloc/src/collections/linked_list/tests.rs
index d3744c5a9d0..9b3c9ac5ce5 100644
--- a/library/alloc/src/collections/linked_list/tests.rs
+++ b/library/alloc/src/collections/linked_list/tests.rs
@@ -1,12 +1,12 @@
-use super::*;
-use crate::testing::crash_test::{CrashTestDummy, Panic};
-use crate::vec::Vec;
-
 use std::panic::{catch_unwind, AssertUnwindSafe};
 use std::thread;
 
 use rand::RngCore;
 
+use super::*;
+use crate::testing::crash_test::{CrashTestDummy, Panic};
+use crate::vec::Vec;
+
 #[test]
 fn test_basic() {
     let mut m = LinkedList::<Box<_>>::new();
@@ -1167,9 +1167,7 @@ fn test_drop_panic() {
 
 #[test]
 fn test_allocator() {
-    use core::alloc::AllocError;
-    use core::alloc::Allocator;
-    use core::alloc::Layout;
+    use core::alloc::{AllocError, Allocator, Layout};
     use core::cell::Cell;
 
     struct A {
diff --git a/library/alloc/src/collections/mod.rs b/library/alloc/src/collections/mod.rs
index 705b81535c2..020cf4d7365 100644
--- a/library/alloc/src/collections/mod.rs
+++ b/library/alloc/src/collections/mod.rs
@@ -27,33 +27,30 @@ pub mod btree_set {
     pub use super::btree::set::*;
 }
 
+use core::fmt::Display;
+
 #[cfg(not(no_global_oom_handling))]
 #[stable(feature = "rust1", since = "1.0.0")]
 #[doc(no_inline)]
 pub use binary_heap::BinaryHeap;
-
 #[cfg(not(no_global_oom_handling))]
 #[stable(feature = "rust1", since = "1.0.0")]
 #[doc(no_inline)]
 pub use btree_map::BTreeMap;
-
 #[cfg(not(no_global_oom_handling))]
 #[stable(feature = "rust1", since = "1.0.0")]
 #[doc(no_inline)]
 pub use btree_set::BTreeSet;
-
 #[cfg(not(no_global_oom_handling))]
 #[stable(feature = "rust1", since = "1.0.0")]
 #[doc(no_inline)]
 pub use linked_list::LinkedList;
-
 #[cfg(not(no_global_oom_handling))]
 #[stable(feature = "rust1", since = "1.0.0")]
 #[doc(no_inline)]
 pub use vec_deque::VecDeque;
 
 use crate::alloc::{Layout, LayoutError};
-use core::fmt::Display;
 
 /// The error type for `try_reserve` methods.
 #[derive(Clone, PartialEq, Eq, Debug)]
diff --git a/library/alloc/src/collections/vec_deque/drain.rs b/library/alloc/src/collections/vec_deque/drain.rs
index 1373e601492..44fcef4ed7d 100644
--- a/library/alloc/src/collections/vec_deque/drain.rs
+++ b/library/alloc/src/collections/vec_deque/drain.rs
@@ -4,9 +4,8 @@ use core::mem::{self, SizedTypeProperties};
 use core::ptr::NonNull;
 use core::{fmt, ptr};
 
-use crate::alloc::{Allocator, Global};
-
 use super::VecDeque;
+use crate::alloc::{Allocator, Global};
 
 /// A draining iterator over the elements of a `VecDeque`.
 ///
diff --git a/library/alloc/src/collections/vec_deque/into_iter.rs b/library/alloc/src/collections/vec_deque/into_iter.rs
index 4747517393c..2d283dac9a9 100644
--- a/library/alloc/src/collections/vec_deque/into_iter.rs
+++ b/library/alloc/src/collections/vec_deque/into_iter.rs
@@ -1,10 +1,11 @@
 use core::iter::{FusedIterator, TrustedLen};
+use core::mem::MaybeUninit;
 use core::num::NonZero;
-use core::{array, fmt, mem::MaybeUninit, ops::Try, ptr};
-
-use crate::alloc::{Allocator, Global};
+use core::ops::Try;
+use core::{array, fmt, ptr};
 
 use super::VecDeque;
+use crate::alloc::{Allocator, Global};
 
 /// An owning iterator over the elements of a `VecDeque`.
 ///
diff --git a/library/alloc/src/collections/vec_deque/mod.rs b/library/alloc/src/collections/vec_deque/mod.rs
index a07f250d7d8..dc725ec0f56 100644
--- a/library/alloc/src/collections/vec_deque/mod.rs
+++ b/library/alloc/src/collections/vec_deque/mod.rs
@@ -8,23 +8,19 @@
 #![stable(feature = "rust1", since = "1.0.0")]
 
 use core::cmp::{self, Ordering};
-use core::fmt;
 use core::hash::{Hash, Hasher};
 use core::iter::{repeat_n, repeat_with, ByRefSized};
-use core::mem::{ManuallyDrop, SizedTypeProperties};
-use core::ops::{Index, IndexMut, Range, RangeBounds};
-use core::ptr;
-use core::slice;
-
 // This is used in a bunch of intra-doc links.
 // FIXME: For some reason, `#[cfg(doc)]` wasn't sufficient, resulting in
 // failures in linkchecker even though rustdoc built the docs just fine.
 #[allow(unused_imports)]
 use core::mem;
+use core::mem::{ManuallyDrop, SizedTypeProperties};
+use core::ops::{Index, IndexMut, Range, RangeBounds};
+use core::{fmt, ptr, slice};
 
 use crate::alloc::{Allocator, Global};
-use crate::collections::TryReserveError;
-use crate::collections::TryReserveErrorKind;
+use crate::collections::{TryReserveError, TryReserveErrorKind};
 use crate::raw_vec::RawVec;
 use crate::vec::Vec;
 
diff --git a/library/alloc/src/collections/vec_deque/spec_extend.rs b/library/alloc/src/collections/vec_deque/spec_extend.rs
index 6a89abc3ef9..a9b0fd073b5 100644
--- a/library/alloc/src/collections/vec_deque/spec_extend.rs
+++ b/library/alloc/src/collections/vec_deque/spec_extend.rs
@@ -1,9 +1,9 @@
-use crate::alloc::Allocator;
-use crate::vec;
 use core::iter::TrustedLen;
 use core::slice;
 
 use super::VecDeque;
+use crate::alloc::Allocator;
+use crate::vec;
 
 // Specialization trait used for VecDeque::extend
 pub(super) trait SpecExtend<T, I> {