Skip to content

Commit

Permalink
Reformat use declarations.
Browse files Browse the repository at this point in the history
The previous commit updated `rustfmt.toml` appropriately. This commit is
the outcome of running `x fmt --all` with the new formatting options.
  • Loading branch information
nnethercote committed Jul 28, 2024
1 parent 06a22c9 commit d1d4fb3
Show file tree
Hide file tree
Showing 524 changed files with 1,546 additions and 2,192 deletions.
3 changes: 2 additions & 1 deletion alloc/benches/btree/map.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
use std::collections::BTreeMap;
use std::ops::RangeBounds;

use rand::{seq::SliceRandom, Rng};
use rand::seq::SliceRandom;
use rand::Rng;
use test::{black_box, Bencher};

macro_rules! map_insert_rand_bench {
Expand Down
1 change: 1 addition & 0 deletions alloc/benches/linked_list.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
use std::collections::LinkedList;

use test::Bencher;

#[bench]
Expand Down
1 change: 1 addition & 0 deletions alloc/benches/string.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
use std::iter::repeat;

use test::{black_box, Bencher};

#[bench]
Expand Down
3 changes: 2 additions & 1 deletion alloc/benches/vec.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
use rand::RngCore;
use std::iter::repeat;

use rand::RngCore;
use test::{black_box, Bencher};

#[bench]
Expand Down
7 changes: 3 additions & 4 deletions alloc/benches/vec_deque.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
use std::{
collections::{vec_deque, VecDeque},
mem,
};
use std::collections::{vec_deque, VecDeque};
use std::mem;

use test::{black_box, Bencher};

#[bench]
Expand Down
3 changes: 2 additions & 1 deletion alloc/benches/vec_deque_append.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
use std::{collections::VecDeque, time::Instant};
use std::collections::VecDeque;
use std::time::Instant;

const VECDEQUE_LEN: i32 = 100000;
const WARMUP_N: usize = 100;
Expand Down
8 changes: 3 additions & 5 deletions alloc/src/alloc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,14 @@
#![stable(feature = "alloc_module", since = "1.28.0")]

#[stable(feature = "alloc_module", since = "1.28.0")]
#[doc(inline)]
pub use core::alloc::*;
#[cfg(not(test))]
use core::hint;

#[cfg(not(test))]
use core::ptr::{self, NonNull};

#[stable(feature = "alloc_module", since = "1.28.0")]
#[doc(inline)]
pub use core::alloc::*;

#[cfg(test)]
mod tests;

Expand Down
3 changes: 2 additions & 1 deletion alloc/src/alloc/tests.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
use super::*;

extern crate test;
use crate::boxed::Box;
use test::Bencher;

use crate::boxed::Box;

#[test]
fn allocate_zeroed() {
unsafe {
Expand Down
7 changes: 3 additions & 4 deletions alloc/src/borrow.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,20 @@
#![stable(feature = "rust1", since = "1.0.0")]

#[stable(feature = "rust1", since = "1.0.0")]
pub use core::borrow::{Borrow, BorrowMut};
use core::cmp::Ordering;
use core::hash::{Hash, Hasher};
#[cfg(not(no_global_oom_handling))]
use core::ops::{Add, AddAssign};
use core::ops::{Deref, DerefPure};

#[stable(feature = "rust1", since = "1.0.0")]
pub use core::borrow::{Borrow, BorrowMut};
use Cow::*;

use crate::fmt;
#[cfg(not(no_global_oom_handling))]
use crate::string::String;

use Cow::*;

#[stable(feature = "rust1", since = "1.0.0")]
impl<'a, B: ?Sized> Borrow<B> for Cow<'a, B>
where
Expand Down
17 changes: 7 additions & 10 deletions alloc/src/boxed.rs
Original file line number Diff line number Diff line change
Expand Up @@ -187,26 +187,26 @@

use core::any::Any;
use core::async_iter::AsyncIterator;
use core::borrow;
#[cfg(not(no_global_oom_handling))]
use core::clone::CloneToUninit;
use core::cmp::Ordering;
use core::error::Error;
use core::fmt;
use core::future::Future;
use core::hash::{Hash, Hasher};
use core::iter::FusedIterator;
use core::marker::Tuple;
use core::marker::Unsize;
use core::marker::{Tuple, Unsize};
use core::mem::{self, SizedTypeProperties};
use core::ops::{AsyncFn, AsyncFnMut, AsyncFnOnce};
use core::ops::{
CoerceUnsized, Coroutine, CoroutineState, Deref, DerefMut, DerefPure, DispatchFromDyn, Receiver,
AsyncFn, AsyncFnMut, AsyncFnOnce, CoerceUnsized, Coroutine, CoroutineState, Deref, DerefMut,
DerefPure, DispatchFromDyn, Receiver,
};
use core::pin::Pin;
use core::ptr::{self, addr_of_mut, NonNull, Unique};
use core::slice;
use core::task::{Context, Poll};
use core::{borrow, fmt, slice};

#[unstable(feature = "thin_box", issue = "92791")]
pub use thin::ThinBox;

#[cfg(not(no_global_oom_handling))]
use crate::alloc::handle_alloc_error;
Expand All @@ -222,9 +222,6 @@ use crate::vec;
#[cfg(not(no_global_oom_handling))]
use crate::vec::Vec;

#[unstable(feature = "thin_box", issue = "92791")]
pub use thin::ThinBox;

mod thin;

/// A pointer type that uniquely owns a heap allocation of type `T`.
Expand Down
6 changes: 3 additions & 3 deletions alloc/src/boxed/thin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
//! <https://github.com/matthieu-m/rfc2580/blob/b58d1d3cba0d4b5e859d3617ea2d0943aaa31329/examples/thin.rs>
//! by matthieu-m
use crate::alloc::{self, Layout, LayoutError};
use core::error::Error;
use core::fmt::{self, Debug, Display, Formatter};
#[cfg(not(no_global_oom_handling))]
Expand All @@ -14,8 +13,9 @@ use core::mem;
#[cfg(not(no_global_oom_handling))]
use core::mem::SizedTypeProperties;
use core::ops::{Deref, DerefMut};
use core::ptr::Pointee;
use core::ptr::{self, NonNull};
use core::ptr::{self, NonNull, Pointee};

use crate::alloc::{self, Layout, LayoutError};

/// ThinBox.
///
Expand Down
3 changes: 1 addition & 2 deletions alloc/src/collections/binary_heap/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
6 changes: 4 additions & 2 deletions alloc/src/collections/binary_heap/tests.rs
Original file line number Diff line number Diff line change
@@ -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() {
Expand Down Expand Up @@ -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)]
Expand Down
5 changes: 3 additions & 2 deletions alloc/src/collections/btree/append.rs
Original file line number Diff line number Diff line change
@@ -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
Expand Down
7 changes: 5 additions & 2 deletions alloc/src/collections/btree/fix.rs
Original file line number Diff line number Diff line change
@@ -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,
Expand Down
12 changes: 6 additions & 6 deletions alloc/src/collections/btree/map.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
use crate::vec::Vec;
use core::borrow::Borrow;
use core::cmp::Ordering;
use core::error::Error;
Expand All @@ -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.
Expand Down
5 changes: 2 additions & 3 deletions alloc/src/collections/btree/map/entry.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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.
///
Expand Down
12 changes: 7 additions & 5 deletions alloc/src/collections/btree/map/tests.rs
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -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.
Expand Down
4 changes: 1 addition & 3 deletions alloc/src/collections/btree/mem.rs
Original file line number Diff line number Diff line change
@@ -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.
Expand Down
7 changes: 3 additions & 4 deletions alloc/src/collections/btree/navigate.rs
Original file line number Diff line number Diff line change
@@ -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> {
Expand Down
7 changes: 5 additions & 2 deletions alloc/src/collections/btree/remove.rs
Original file line number Diff line number Diff line change
@@ -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
Expand Down
5 changes: 3 additions & 2 deletions alloc/src/collections/btree/search.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand Down
3 changes: 1 addition & 2 deletions alloc/src/collections/btree/set.rs
Original file line number Diff line number Diff line change
@@ -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};
Expand All @@ -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.
///
Expand Down
5 changes: 3 additions & 2 deletions alloc/src/collections/btree/set/tests.rs
Original file line number Diff line number Diff line change
@@ -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() {
Expand Down
6 changes: 4 additions & 2 deletions alloc/src/collections/btree/split.rs
Original file line number Diff line number Diff line change
@@ -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.
Expand Down
Loading

0 comments on commit d1d4fb3

Please sign in to comment.