diff --git a/src/liballoc/alloc.rs b/src/liballoc/alloc.rs index 096cb51e0d3ef..bb88897323eaf 100644 --- a/src/liballoc/alloc.rs +++ b/src/liballoc/alloc.rs @@ -2,9 +2,11 @@ #![stable(feature = "alloc_module", since = "1.28.0")] -use core::intrinsics::{min_align_of_val, size_of_val}; -use core::ptr::{NonNull, Unique}; -use core::usize; +use core::{ + intrinsics::{min_align_of_val, size_of_val}, + ptr::{NonNull, Unique}, + usize, +}; #[stable(feature = "alloc_module", since = "1.28.0")] #[doc(inline)] @@ -228,8 +230,10 @@ pub fn handle_alloc_error(layout: Layout) -> ! { mod tests { extern crate test; use self::test::Bencher; - use boxed::Box; - use alloc::{Global, Alloc, Layout, handle_alloc_error}; + use crate::{ + boxed::Box, + alloc::{Global, Alloc, Layout, handle_alloc_error}, + }; #[test] fn allocate_zeroed() { diff --git a/src/liballoc/benches/btree/map.rs b/src/liballoc/benches/btree/map.rs index a6f584534d174..3865ec866aeed 100644 --- a/src/liballoc/benches/btree/map.rs +++ b/src/liballoc/benches/btree/map.rs @@ -1,6 +1,8 @@ -use std::iter::Iterator; -use std::vec::Vec; -use std::collections::BTreeMap; +use std::{ + iter::Iterator, + vec::Vec, + collections::BTreeMap, +}; use rand::{Rng, seq::SliceRandom, thread_rng}; use test::{Bencher, black_box}; diff --git a/src/liballoc/benches/slice.rs b/src/liballoc/benches/slice.rs index b9ebd74f7999a..d87b70f2d932c 100644 --- a/src/liballoc/benches/slice.rs +++ b/src/liballoc/benches/slice.rs @@ -1,9 +1,8 @@ -use rand::{thread_rng}; -use std::mem; -use std::ptr; - -use rand::{Rng, SeedableRng}; -use rand::distributions::{Standard, Alphanumeric}; +use std::{mem, ptr}; +use rand::{ + thread_rng, Rng, SeedableRng, + distributions::{Standard, Alphanumeric}, +}; use rand_xorshift::XorShiftRng; use test::{Bencher, black_box}; diff --git a/src/liballoc/borrow.rs b/src/liballoc/borrow.rs index 4c6f150ca1b42..8161d588fbdb8 100644 --- a/src/liballoc/borrow.rs +++ b/src/liballoc/borrow.rs @@ -2,12 +2,13 @@ #![stable(feature = "rust1", since = "1.0.0")] -use core::cmp::Ordering; -use core::hash::{Hash, Hasher}; -use core::ops::{Add, AddAssign, Deref}; +use core::{ + cmp::Ordering, + hash::{Hash, Hasher}, + ops::{Add, AddAssign, Deref}, +}; -use crate::fmt; -use crate::string::String; +use crate::{fmt, string::String}; use self::Cow::*; diff --git a/src/liballoc/boxed.rs b/src/liballoc/boxed.rs index 7b322a5c39692..f590b6488d9da 100644 --- a/src/liballoc/boxed.rs +++ b/src/liballoc/boxed.rs @@ -56,26 +56,28 @@ #![stable(feature = "rust1", since = "1.0.0")] -use core::any::Any; -use core::borrow; -use core::cmp::Ordering; -use core::convert::From; -use core::fmt; -use core::future::Future; -use core::hash::{Hash, Hasher}; -use core::iter::{Iterator, FromIterator, FusedIterator}; -use core::marker::{Unpin, Unsize}; -use core::mem; -use core::pin::Pin; -use core::ops::{ - CoerceUnsized, DispatchFromDyn, Deref, DerefMut, Receiver, Generator, GeneratorState +use core::{ + any::Any, + borrow, + cmp::Ordering, + convert::From, + fmt, + future::Future, + hash::{Hash, Hasher}, + iter::{Iterator, FromIterator, FusedIterator}, + marker::{Unpin, Unsize}, + mem, + pin::Pin, + ops::{CoerceUnsized, DispatchFromDyn, Deref, DerefMut, Receiver, Generator, GeneratorState}, + ptr::{self, NonNull, Unique}, + task::{LocalWaker, Poll}, }; -use core::ptr::{self, NonNull, Unique}; -use core::task::{LocalWaker, Poll}; -use crate::vec::Vec; -use crate::raw_vec::RawVec; -use crate::str::from_boxed_utf8_unchecked; +use crate::{ + vec::Vec, + raw_vec::RawVec, + str::from_boxed_utf8_unchecked, +}; /// A pointer type for heap allocation. /// diff --git a/src/liballoc/boxed_test.rs b/src/liballoc/boxed_test.rs index 654eabd070326..6fb01fbc6a150 100644 --- a/src/liballoc/boxed_test.rs +++ b/src/liballoc/boxed_test.rs @@ -1,11 +1,13 @@ //! Test for `boxed` mod. -use core::any::Any; -use core::ops::Deref; -use core::result::Result::{Err, Ok}; -use core::clone::Clone; -use core::f64; -use core::i64; +use core::{ + any::Any, + ops::Deref, + result::Result::{Err, Ok}, + clone::Clone, + f64, + i64, +}; use std::boxed::Box; diff --git a/src/liballoc/collections/binary_heap.rs b/src/liballoc/collections/binary_heap.rs index 079c6290ebd40..4a38f041636ef 100644 --- a/src/liballoc/collections/binary_heap.rs +++ b/src/liballoc/collections/binary_heap.rs @@ -145,14 +145,18 @@ #![allow(missing_docs)] #![stable(feature = "rust1", since = "1.0.0")] -use core::ops::{Deref, DerefMut}; -use core::iter::{FromIterator, FusedIterator}; -use core::mem::{swap, size_of, ManuallyDrop}; -use core::ptr; -use core::fmt; - -use crate::slice; -use crate::vec::{self, Vec}; +use core::{ + ops::{Deref, DerefMut}, + iter::{FromIterator, FusedIterator}, + mem::{swap, size_of, ManuallyDrop}, + ptr, + fmt, +}; + +use crate::{ + slice, + vec::{self, Vec}, +}; use super::SpecExtend; diff --git a/src/liballoc/collections/btree/map.rs b/src/liballoc/collections/btree/map.rs index efb4b8afdb70a..f81cf6f104719 100644 --- a/src/liballoc/collections/btree/map.rs +++ b/src/liballoc/collections/btree/map.rs @@ -1,23 +1,24 @@ -use core::cmp::Ordering; -use core::fmt::Debug; -use core::hash::{Hash, Hasher}; -use core::iter::{FromIterator, Peekable, FusedIterator}; -use core::marker::PhantomData; -use core::ops::Bound::{Excluded, Included, Unbounded}; -use core::ops::Index; -use core::ops::RangeBounds; -use core::{fmt, intrinsics, mem, ptr}; +use core::{ + cmp::Ordering, + fmt::Debug, + hash::{Hash, Hasher}, + iter::{FromIterator, Peekable, FusedIterator}, + marker::PhantomData, + ops::{ + Bound::{Excluded, Included, Unbounded}, + Index, RangeBounds, + }, + fmt, intrinsics, mem, ptr, +}; use crate::borrow::Borrow; -use super::node::{self, Handle, NodeRef, marker}; -use super::search; +use super::{ + node::{self, Handle, NodeRef, marker, InsertResult::*, ForceResult::*}, + search::{self, SearchResult::*}, +}; -use super::node::InsertResult::*; -use super::node::ForceResult::*; -use super::search::SearchResult::*; -use self::UnderflowResult::*; -use self::Entry::*; +use self::{UnderflowResult::*, Entry::*}; /// A map based on a B-Tree. /// diff --git a/src/liballoc/collections/btree/node.rs b/src/liballoc/collections/btree/node.rs index 92664bad4e4a5..f33a75bc45e02 100644 --- a/src/liballoc/collections/btree/node.rs +++ b/src/liballoc/collections/btree/node.rs @@ -31,13 +31,17 @@ // - A node of length `n` has `n` keys, `n` values, and (in an internal node) `n + 1` edges. // This implies that even an empty internal node has at least one edge. -use core::marker::PhantomData; -use core::mem::{self, MaybeUninit}; -use core::ptr::{self, Unique, NonNull}; -use core::slice; +use core::{ + marker::PhantomData, + mem::{self, MaybeUninit}, + ptr::{self, Unique, NonNull}, + slice, +}; -use crate::alloc::{Global, Alloc, Layout}; -use crate::boxed::Box; +use crate::{ + alloc::{Global, Alloc, Layout}, + boxed::Box, +}; const B: usize = 6; pub const MIN_LEN: usize = B - 1; diff --git a/src/liballoc/collections/btree/search.rs b/src/liballoc/collections/btree/search.rs index 242dc4b94d8ad..a3b56ad17c6b7 100644 --- a/src/liballoc/collections/btree/search.rs +++ b/src/liballoc/collections/btree/search.rs @@ -2,9 +2,8 @@ use core::cmp::Ordering; use crate::borrow::Borrow; -use super::node::{Handle, NodeRef, marker}; +use super::node::{Handle, NodeRef, marker, ForceResult::*}; -use super::node::ForceResult::*; use self::SearchResult::*; pub enum SearchResult { diff --git a/src/liballoc/collections/btree/set.rs b/src/liballoc/collections/btree/set.rs index 01a0562bc2153..298d165a91afa 100644 --- a/src/liballoc/collections/btree/set.rs +++ b/src/liballoc/collections/btree/set.rs @@ -1,15 +1,20 @@ // This is pretty much entirely stolen from TreeSet, since BTreeMap has an identical interface // to TreeMap -use core::cmp::Ordering::{self, Less, Greater, Equal}; -use core::cmp::{min, max}; -use core::fmt::Debug; -use core::fmt; -use core::iter::{Peekable, FromIterator, FusedIterator}; -use core::ops::{BitOr, BitAnd, BitXor, Sub, RangeBounds}; - -use crate::borrow::Borrow; -use crate::collections::btree_map::{self, BTreeMap, Keys}; +use core::{ + cmp::{ + Ordering::{self, Less, Greater, Equal}, + min, max, + }, + fmt::{self, Debug}, + iter::{Peekable, FromIterator, FusedIterator}, + ops::{BitOr, BitAnd, BitXor, Sub, RangeBounds}, +}; + +use crate::{ + borrow::Borrow, + collections::btree_map::{self, BTreeMap, Keys}, +}; use super::Recover; // FIXME(conventions): implement bounded iterators diff --git a/src/liballoc/collections/linked_list.rs b/src/liballoc/collections/linked_list.rs index c666adb41a738..8f72c6babaf35 100644 --- a/src/liballoc/collections/linked_list.rs +++ b/src/liballoc/collections/linked_list.rs @@ -12,13 +12,15 @@ #![stable(feature = "rust1", since = "1.0.0")] -use core::cmp::Ordering; -use core::fmt; -use core::hash::{Hasher, Hash}; -use core::iter::{FromIterator, FusedIterator}; -use core::marker::PhantomData; -use core::mem; -use core::ptr::NonNull; +use core::{ + cmp::Ordering, + fmt, + hash::{Hasher, Hash}, + iter::{FromIterator, FusedIterator}, + marker::PhantomData, + mem, + ptr::NonNull, +}; use crate::boxed::Box; use super::SpecExtend; @@ -1213,11 +1215,8 @@ unsafe impl<'a, T: Sync> Sync for IterMut<'a, T> {} #[cfg(test)] mod tests { - use std::thread; - use std::vec::Vec; - + use std::{thread, vec::Vec}; use rand::{thread_rng, RngCore}; - use super::{LinkedList, Node}; #[cfg(test)] diff --git a/src/liballoc/collections/vec_deque.rs b/src/liballoc/collections/vec_deque.rs index 65d4253d0c67c..de78783983d7c 100644 --- a/src/liballoc/collections/vec_deque.rs +++ b/src/liballoc/collections/vec_deque.rs @@ -7,22 +7,25 @@ #![stable(feature = "rust1", since = "1.0.0")] -use core::cmp::Ordering; -use core::fmt; -use core::iter::{repeat_with, FromIterator, FusedIterator}; -use core::mem; -use core::ops::Bound::{Excluded, Included, Unbounded}; -use core::ops::{Index, IndexMut, RangeBounds, Try}; -use core::ptr; -use core::ptr::NonNull; -use core::slice; - -use core::hash::{Hash, Hasher}; -use core::cmp; - -use crate::collections::CollectionAllocErr; -use crate::raw_vec::RawVec; -use crate::vec::Vec; +use core::{ + cmp::{self, Ordering}, + fmt, + iter::{repeat_with, FromIterator, FusedIterator}, + mem, + ops::{ + Bound::{Excluded, Included, Unbounded}, + Index, IndexMut, RangeBounds, Try, + }, + ptr::{self, NonNull}, + slice, + hash::{Hash, Hasher}, +}; + +use crate::{ + collections::CollectionAllocErr, + raw_vec::RawVec, + vec::Vec, +}; const INITIAL_CAPACITY: usize = 7; // 2^3 - 1 const MINIMUM_CAPACITY: usize = 1; // 2 - 1 @@ -2758,7 +2761,7 @@ impl From> for Vec { #[cfg(test)] mod tests { - use test; + use ::test; use super::VecDeque; @@ -3036,7 +3039,7 @@ mod tests { #[test] fn test_from_vec() { - use vec::Vec; + use crate::vec::Vec; for cap in 0..35 { for len in 0..=cap { let mut vec = Vec::with_capacity(cap); @@ -3052,7 +3055,7 @@ mod tests { #[test] fn test_vec_from_vecdeque() { - use vec::Vec; + use crate::vec::Vec; fn create_vec_and_test_convert(cap: usize, offset: usize, len: usize) { let mut vd = VecDeque::with_capacity(cap); @@ -3114,7 +3117,7 @@ mod tests { #[test] fn issue_53529() { - use boxed::Box; + use crate::boxed::Box; let mut dst = VecDeque::new(); dst.push_front(Box::new(1)); diff --git a/src/liballoc/fmt.rs b/src/liballoc/fmt.rs index 8d12b19a06d12..be35b4487509b 100644 --- a/src/liballoc/fmt.rs +++ b/src/liballoc/fmt.rs @@ -509,21 +509,16 @@ #[unstable(feature = "fmt_internals", issue = "0")] pub use core::fmt::rt; #[stable(feature = "rust1", since = "1.0.0")] -pub use core::fmt::{Formatter, Result, Write}; -#[stable(feature = "rust1", since = "1.0.0")] -pub use core::fmt::{Binary, Octal}; -#[stable(feature = "rust1", since = "1.0.0")] -pub use core::fmt::{Debug, Display}; -#[stable(feature = "rust1", since = "1.0.0")] -pub use core::fmt::{LowerHex, Pointer, UpperHex}; -#[stable(feature = "rust1", since = "1.0.0")] -pub use core::fmt::{LowerExp, UpperExp}; -#[stable(feature = "rust1", since = "1.0.0")] -pub use core::fmt::Error; -#[stable(feature = "rust1", since = "1.0.0")] -pub use core::fmt::{write, ArgumentV1, Arguments}; -#[stable(feature = "rust1", since = "1.0.0")] -pub use core::fmt::{DebugList, DebugMap, DebugSet, DebugStruct, DebugTuple}; +pub use core::fmt::{ + Formatter, Result, Write, + Binary, Octal, + Debug, Display, + LowerHex, Pointer, UpperHex, + LowerExp, UpperExp, + Error, + write, ArgumentV1, Arguments, + DebugList, DebugMap, DebugSet, DebugStruct, DebugTuple +}; #[stable(feature = "fmt_flags_align", since = "1.28.0")] pub use core::fmt::{Alignment}; diff --git a/src/liballoc/prelude.rs b/src/liballoc/prelude.rs index 6767cf89f73ba..3f1d6ded66d35 100644 --- a/src/liballoc/prelude.rs +++ b/src/liballoc/prelude.rs @@ -12,8 +12,11 @@ #![unstable(feature = "alloc", issue = "27783")] -#[unstable(feature = "alloc", issue = "27783")] pub use crate::borrow::ToOwned; -#[unstable(feature = "alloc", issue = "27783")] pub use crate::boxed::Box; -#[unstable(feature = "alloc", issue = "27783")] pub use crate::slice::SliceConcatExt; -#[unstable(feature = "alloc", issue = "27783")] pub use crate::string::{String, ToString}; -#[unstable(feature = "alloc", issue = "27783")] pub use crate::vec::Vec; +#[unstable(feature = "alloc", issue = "27783")] +pub use crate::{ + borrow::ToOwned, + boxed::Box, + slice::SliceConcatExt, + string::{String, ToString}, + vec::Vec, +}; diff --git a/src/liballoc/raw_vec.rs b/src/liballoc/raw_vec.rs index 9f9dd134826f0..92d482b1f052a 100644 --- a/src/liballoc/raw_vec.rs +++ b/src/liballoc/raw_vec.rs @@ -1,16 +1,19 @@ #![unstable(feature = "raw_vec_internals", reason = "implementation detail", issue = "0")] #![doc(hidden)] -use core::cmp; -use core::mem; -use core::ops::Drop; -use core::ptr::{self, NonNull, Unique}; -use core::slice; - -use crate::alloc::{Alloc, Layout, Global, handle_alloc_error}; -use crate::collections::CollectionAllocErr; -use crate::collections::CollectionAllocErr::*; -use crate::boxed::Box; +use core::{ + cmp, + mem, + ops::Drop, + ptr::{self, NonNull, Unique}, + slice, +}; + +use crate::{ + alloc::{Alloc, Layout, Global, handle_alloc_error}, + collections::CollectionAllocErr::{self, *}, + boxed::Box, +}; /// A low-level utility for more ergonomically allocating, reallocating, and deallocating /// a buffer of memory on the heap without having to worry about all the corner cases @@ -753,7 +756,7 @@ mod tests { #[test] fn allocator_param() { - use alloc::AllocErr; + use crate::alloc::AllocErr; // Writing a test of integration between third-party // allocators and RawVec is a little tricky because the RawVec diff --git a/src/liballoc/rc.rs b/src/liballoc/rc.rs index 3c28c6d06fe75..720ac4b630aee 100644 --- a/src/liballoc/rc.rs +++ b/src/liballoc/rc.rs @@ -231,26 +231,28 @@ use crate::boxed::Box; #[cfg(test)] use std::boxed::Box; -use core::any::Any; -use core::borrow; -use core::cell::Cell; -use core::cmp::Ordering; -use core::fmt; -use core::hash::{Hash, Hasher}; -use core::intrinsics::abort; -use core::marker; -use core::marker::{Unpin, Unsize, PhantomData}; -use core::mem::{self, align_of_val, forget, size_of_val}; -use core::ops::{Deref, Receiver}; -use core::ops::{CoerceUnsized, DispatchFromDyn}; -use core::pin::Pin; -use core::ptr::{self, NonNull}; -use core::convert::From; -use core::usize; - -use crate::alloc::{Global, Alloc, Layout, box_free, handle_alloc_error}; -use crate::string::String; -use crate::vec::Vec; +use core::{ + any::Any, + borrow, + cell::Cell, + cmp::Ordering, + fmt, + hash::{Hash, Hasher}, + intrinsics::abort, + marker::{self, Unpin, Unsize, PhantomData}, + mem::{self, align_of_val, forget, size_of_val}, + ops::{Deref, Receiver, CoerceUnsized, DispatchFromDyn}, + pin::Pin, + ptr::{self, NonNull}, + convert::From, + usize, +}; + +use crate::{ + alloc::{Global, Alloc, Layout, box_free, handle_alloc_error}, + string::String, + vec::Vec, +}; struct RcBox { strong: Cell, @@ -1562,14 +1564,15 @@ impl RcBoxPtr for RcBox { #[cfg(test)] mod tests { use super::{Rc, Weak}; - use std::boxed::Box; - use std::cell::RefCell; - use std::option::Option; - use std::option::Option::{None, Some}; - use std::result::Result::{Err, Ok}; - use std::mem::drop; - use std::clone::Clone; - use std::convert::From; + use std::{ + boxed::Box, + cell::RefCell, + option::Option::{self, None, Some}, + result::Result::{Err, Ok}, + mem::drop, + clone::Clone, + convert::From, + }; #[test] fn test_clone() { @@ -1733,8 +1736,7 @@ mod tests { #[test] fn test_into_from_raw_unsized() { - use std::fmt::Display; - use std::string::ToString; + use std::{fmt::Display, string::ToString}; let rc: Rc = Rc::from("foo"); @@ -1942,8 +1944,7 @@ mod tests { #[test] fn test_from_box_trait() { - use std::fmt::Display; - use std::string::ToString; + use std::{fmt::Display, string::ToString}; let b: Box = box 123; let r: Rc = Rc::from(b); diff --git a/src/liballoc/slice.rs b/src/liballoc/slice.rs index 0ed8aa6a2e420..1cee3aa415b8b 100644 --- a/src/liballoc/slice.rs +++ b/src/liballoc/slice.rs @@ -87,15 +87,18 @@ // It's cleaner to just turn off the unused_imports warning than to fix them. #![cfg_attr(test, allow(unused_imports, dead_code))] -use core::cmp::Ordering::{self, Less}; -use core::mem::size_of; -use core::mem; -use core::ptr; -use core::{u8, u16, u32}; - -use crate::borrow::{Borrow, BorrowMut, ToOwned}; -use crate::boxed::Box; -use crate::vec::Vec; +use core::{ + cmp::Ordering::{self, Less}, + mem::{self, size_of}, + ptr, + u8, u16, u32, +}; + +use crate::{ + borrow::{Borrow, BorrowMut, ToOwned}, + boxed::Box, + vec::Vec, +}; #[stable(feature = "rust1", since = "1.0.0")] pub use core::slice::{Chunks, Windows}; diff --git a/src/liballoc/str.rs b/src/liballoc/str.rs index a44838d560a70..85437defd5733 100644 --- a/src/liballoc/str.rs +++ b/src/liballoc/str.rs @@ -28,20 +28,25 @@ // It's cleaner to just turn off the unused_imports warning than to fix them. #![allow(unused_imports)] -use core::fmt; -use core::str as core_str; -use core::str::pattern::Pattern; -use core::str::pattern::{Searcher, ReverseSearcher, DoubleEndedSearcher}; -use core::mem; -use core::ptr; -use core::iter::FusedIterator; -use core::unicode::conversions; - -use crate::borrow::{Borrow, ToOwned}; -use crate::boxed::Box; -use crate::slice::{SliceConcatExt, SliceIndex}; -use crate::string::String; -use crate::vec::Vec; +use core::{ + fmt, + str::{ + self as core_str, + pattern::{Pattern, Searcher, ReverseSearcher, DoubleEndedSearcher}, + }, + mem, + ptr, + iter::FusedIterator, + unicode::conversions, +}; + +use crate::{ + borrow::{Borrow, ToOwned}, + boxed::Box, + slice::{SliceConcatExt, SliceIndex}, + string::String, + vec::Vec, +}; #[stable(feature = "rust1", since = "1.0.0")] pub use core::str::{FromStr, Utf8Error}; diff --git a/src/liballoc/string.rs b/src/liballoc/string.rs index d8f46374ce21b..e9da10b3597f2 100644 --- a/src/liballoc/string.rs +++ b/src/liballoc/string.rs @@ -46,21 +46,30 @@ #![stable(feature = "rust1", since = "1.0.0")] -use core::char::{decode_utf16, REPLACEMENT_CHARACTER}; -use core::fmt; -use core::hash; -use core::iter::{FromIterator, FusedIterator}; -use core::ops::Bound::{Excluded, Included, Unbounded}; -use core::ops::{self, Add, AddAssign, Index, IndexMut, RangeBounds}; -use core::ptr; -use core::str::pattern::Pattern; -use core::str::lossy; - -use crate::collections::CollectionAllocErr; -use crate::borrow::{Cow, ToOwned}; -use crate::boxed::Box; -use crate::str::{self, from_boxed_utf8_unchecked, FromStr, Utf8Error, Chars}; -use crate::vec::Vec; +use core::{ + char::{decode_utf16, REPLACEMENT_CHARACTER}, + fmt, + hash, + iter::{FromIterator, FusedIterator}, + ops::{ + self, + Bound::{Excluded, Included, Unbounded}, + Add, AddAssign, Index, IndexMut, RangeBounds, + }, + ptr, + str::{ + pattern::Pattern, + lossy, + } +}; + +use crate::{ + collections::CollectionAllocErr, + borrow::{Cow, ToOwned}, + boxed::Box, + str::{self, from_boxed_utf8_unchecked, FromStr, Utf8Error, Chars}, + vec::Vec, +}; /// A UTF-8 encoded, growable string. /// diff --git a/src/liballoc/sync.rs b/src/liballoc/sync.rs index b387f07f231e6..2a4b3113bfe75 100644 --- a/src/liballoc/sync.rs +++ b/src/liballoc/sync.rs @@ -6,28 +6,33 @@ //! //! [arc]: struct.Arc.html -use core::any::Any; -use core::sync::atomic; -use core::sync::atomic::Ordering::{Acquire, Relaxed, Release, SeqCst}; -use core::borrow; -use core::fmt; -use core::cmp::{self, Ordering}; -use core::intrinsics::abort; -use core::mem::{self, align_of_val, size_of_val}; -use core::ops::{Deref, Receiver}; -use core::ops::{CoerceUnsized, DispatchFromDyn}; -use core::pin::Pin; -use core::ptr::{self, NonNull}; -use core::marker::{Unpin, Unsize, PhantomData}; -use core::hash::{Hash, Hasher}; -use core::{isize, usize}; -use core::convert::From; - -use crate::alloc::{Global, Alloc, Layout, box_free, handle_alloc_error}; -use crate::boxed::Box; -use crate::rc::is_dangling; -use crate::string::String; -use crate::vec::Vec; +use core::{ + any::Any, + sync::atomic::{ + self, + Ordering::{Acquire, Relaxed, Release, SeqCst} + }, + borrow, + fmt, + cmp::{self, Ordering}, + intrinsics::abort, + mem::{self, align_of_val, size_of_val}, + ops::{Deref, Receiver, CoerceUnsized, DispatchFromDyn}, + pin::Pin, + ptr::{self, NonNull}, + marker::{Unpin, Unsize, PhantomData}, + hash::{Hash, Hasher}, + isize, usize, + convert::From, +}; + +use crate::{ + alloc::{Global, Alloc, Layout, box_free, handle_alloc_error}, + boxed::Box, + rc::is_dangling, + string::String, + vec::Vec, +}; /// A soft limit on the amount of references that may be made to an `Arc`. /// @@ -1650,21 +1655,21 @@ impl From> for Arc<[T]> { #[cfg(test)] mod tests { - use std::boxed::Box; - use std::clone::Clone; - use std::sync::mpsc::channel; - use std::mem::drop; - use std::ops::Drop; - use std::option::Option; - use std::option::Option::{None, Some}; - use std::sync::atomic; - use std::sync::atomic::Ordering::{Acquire, SeqCst}; - use std::thread; - use std::sync::Mutex; - use std::convert::From; + use std::{ + boxed::Box, + clone::Clone, + sync::mpsc::channel, + mem::drop, + ops::Drop, + option::Option::{self, None, Some}, + sync::atomic::{self, Ordering::{Acquire, SeqCst}}, + thread, + sync::Mutex, + convert::From, + }; use super::{Arc, Weak}; - use vec::Vec; + use crate::vec::Vec; struct Canary(*mut atomic::AtomicUsize); @@ -1770,8 +1775,7 @@ mod tests { #[test] fn test_into_from_raw_unsized() { - use std::fmt::Display; - use std::string::ToString; + use std::{fmt::Display, string::ToString}; let arc: Arc = Arc::from("foo"); @@ -2083,8 +2087,7 @@ mod tests { #[test] fn test_from_box_trait() { - use std::fmt::Display; - use std::string::ToString; + use std::{fmt::Display, string::ToString}; let b: Box = box 123; let r: Arc = Arc::from(b); diff --git a/src/liballoc/task.rs b/src/liballoc/task.rs index ba4e0dcda02df..89dc2b10a9294 100644 --- a/src/liballoc/task.rs +++ b/src/liballoc/task.rs @@ -8,9 +8,11 @@ pub use self::if_arc::*; #[cfg(all(target_has_atomic = "ptr", target_has_atomic = "cas"))] mod if_arc { use super::*; - use core::marker::PhantomData; - use core::mem; - use core::ptr::{self, NonNull}; + use core::{ + marker::PhantomData, + mem, + ptr::{self, NonNull}, + }; use crate::sync::Arc; /// A way of waking up a specific task. diff --git a/src/liballoc/tests/arc.rs b/src/liballoc/tests/arc.rs index 2759b1b1cac27..b71cf3bd47795 100644 --- a/src/liballoc/tests/arc.rs +++ b/src/liballoc/tests/arc.rs @@ -1,7 +1,9 @@ -use std::any::Any; -use std::sync::{Arc, Weak}; -use std::cell::RefCell; -use std::cmp::PartialEq; +use std::{ + any::Any, + sync::{Arc, Weak}, + cell::RefCell, + cmp::PartialEq, +}; #[test] fn uninhabited() { diff --git a/src/liballoc/tests/binary_heap.rs b/src/liballoc/tests/binary_heap.rs index 94ae43237d19c..f19d641fe83eb 100644 --- a/src/liballoc/tests/binary_heap.rs +++ b/src/liballoc/tests/binary_heap.rs @@ -1,8 +1,9 @@ -use std::cmp; -use std::collections::BinaryHeap; -use std::collections::binary_heap::{Drain, PeekMut}; -use std::panic::{self, AssertUnwindSafe}; -use std::sync::atomic::{AtomicUsize, Ordering}; +use std::{ + cmp, + collections::{BinaryHeap, binary_heap::{Drain, PeekMut}}, + panic::{self, AssertUnwindSafe}, + sync::atomic::{AtomicUsize, Ordering}, +}; use rand::{thread_rng, seq::SliceRandom}; diff --git a/src/liballoc/tests/btree/map.rs b/src/liballoc/tests/btree/map.rs index 05e0bdffaa86b..33f65980784a1 100644 --- a/src/liballoc/tests/btree/map.rs +++ b/src/liballoc/tests/btree/map.rs @@ -1,9 +1,10 @@ -use std::collections::BTreeMap; -use std::collections::btree_map::Entry::{Occupied, Vacant}; -use std::ops::Bound::{self, Excluded, Included, Unbounded}; -use std::rc::Rc; +use std::{ + collections::{BTreeMap, btree_map::Entry::{Occupied, Vacant}}, + ops::Bound::{self, Excluded, Included, Unbounded}, + rc::Rc, + iter::FromIterator, +}; -use std::iter::FromIterator; use super::DeterministicRng; #[test] diff --git a/src/liballoc/tests/btree/set.rs b/src/liballoc/tests/btree/set.rs index e24c04fd8acb3..b90ecd9e3f136 100644 --- a/src/liballoc/tests/btree/set.rs +++ b/src/liballoc/tests/btree/set.rs @@ -1,6 +1,7 @@ -use std::collections::BTreeSet; - -use std::iter::FromIterator; +use std::{ + collections::BTreeSet, + iter::FromIterator +}; use super::DeterministicRng; #[test] @@ -15,6 +16,8 @@ fn test_clone_eq() { #[test] fn test_hash() { + use crate::hash; + let mut x = BTreeSet::new(); let mut y = BTreeSet::new(); @@ -26,7 +29,7 @@ fn test_hash() { y.insert(2); y.insert(1); - assert!(::hash(&x) == ::hash(&y)); + assert!(hash(&x) == hash(&y)); } fn check(a: &[i32], b: &[i32], expected: &[i32], f: F) diff --git a/src/liballoc/tests/lib.rs b/src/liballoc/tests/lib.rs index a76fd87a1a92d..100b3986370ab 100644 --- a/src/liballoc/tests/lib.rs +++ b/src/liballoc/tests/lib.rs @@ -13,8 +13,10 @@ extern crate core; extern crate rand; -use std::hash::{Hash, Hasher}; -use std::collections::hash_map::DefaultHasher; +use std::{ + hash::{Hash, Hasher}, + collections::hash_map::DefaultHasher, +}; mod arc; mod binary_heap; diff --git a/src/liballoc/tests/linked_list.rs b/src/liballoc/tests/linked_list.rs index 6e775f9650d12..0fbfbdccd4537 100644 --- a/src/liballoc/tests/linked_list.rs +++ b/src/liballoc/tests/linked_list.rs @@ -241,10 +241,12 @@ fn test_eq() { #[test] fn test_hash() { + use crate::hash; + let mut x = LinkedList::new(); let mut y = LinkedList::new(); - assert!(::hash(&x) == ::hash(&y)); + assert!(hash(&x) == hash(&y)); x.push_back(1); x.push_back(2); @@ -254,7 +256,7 @@ fn test_hash() { y.push_front(2); y.push_front(1); - assert!(::hash(&x) == ::hash(&y)); + assert!(hash(&x) == hash(&y)); } #[test] diff --git a/src/liballoc/tests/rc.rs b/src/liballoc/tests/rc.rs index 18f82e8041008..caa3c914fc248 100644 --- a/src/liballoc/tests/rc.rs +++ b/src/liballoc/tests/rc.rs @@ -1,7 +1,9 @@ -use std::any::Any; -use std::rc::{Rc, Weak}; -use std::cell::RefCell; -use std::cmp::PartialEq; +use std::{ + any::Any, + rc::{Rc, Weak}, + cell::RefCell, + cmp::PartialEq, +}; #[test] fn uninhabited() { diff --git a/src/liballoc/tests/slice.rs b/src/liballoc/tests/slice.rs index 0300bd7f3f6d4..d0a8b65ae8be0 100644 --- a/src/liballoc/tests/slice.rs +++ b/src/liballoc/tests/slice.rs @@ -1,15 +1,18 @@ -use std::cell::Cell; -use std::cmp::Ordering::{Equal, Greater, Less}; -use std::cmp::Ordering; -use std::mem; -use std::panic; -use std::rc::Rc; -use std::sync::atomic::Ordering::Relaxed; -use std::sync::atomic::AtomicUsize; -use std::thread; - -use rand::{Rng, RngCore, thread_rng, seq::SliceRandom}; -use rand::distributions::Standard; +use std::{ + cell::Cell, + cmp::Ordering::{self, Equal, Greater, Less}, + mem, + panic, + rc::Rc, + sync::atomic::{Ordering::Relaxed, AtomicUsize}, + thread, +}; + +use rand::{ + Rng, RngCore, thread_rng, + seq::SliceRandom, + distributions::Standard, +}; fn square(n: usize) -> usize { n * n @@ -476,7 +479,7 @@ fn test_sort_stability() { // the second item represents which occurrence of that // number this element is, i.e., the second elements // will occur in sorted order. - let mut orig: Vec<_> = (0..len) + let orig: Vec<_> = (0..len) .map(|_| { let n = thread_rng().gen::() % 10; counts[n] += 1; diff --git a/src/liballoc/tests/str.rs b/src/liballoc/tests/str.rs index 66a1b947a7d3a..583e616bf6d75 100644 --- a/src/liballoc/tests/str.rs +++ b/src/liballoc/tests/str.rs @@ -1,6 +1,8 @@ -use std::borrow::Cow; -use std::cmp::Ordering::{Equal, Greater, Less}; -use std::str::from_utf8; +use std::{ + borrow::Cow, + cmp::Ordering::{Equal, Greater, Less}, + str::from_utf8, +}; #[test] fn test_le() { @@ -1599,9 +1601,10 @@ fn test_repeat() { } mod pattern { - use std::str::pattern::Pattern; - use std::str::pattern::{Searcher, ReverseSearcher}; - use std::str::pattern::SearchStep::{self, Match, Reject, Done}; + use std::str::pattern::{ + Pattern, Searcher, ReverseSearcher, + SearchStep::{self, Match, Reject, Done}, + }; macro_rules! make_test { ($name:ident, $p:expr, $h:expr, [$($e:expr,)*]) => { diff --git a/src/liballoc/tests/string.rs b/src/liballoc/tests/string.rs index 8a5bfca8b7db5..9e4ffb5be9d6e 100644 --- a/src/liballoc/tests/string.rs +++ b/src/liballoc/tests/string.rs @@ -1,7 +1,9 @@ -use std::borrow::Cow; -use std::collections::CollectionAllocErr::*; -use std::mem::size_of; -use std::{usize, isize}; +use std::{ + borrow::Cow, + collections::CollectionAllocErr::*, + mem::size_of, + usize, isize, +}; pub trait IntoCow<'a, B: ?Sized> where B: ToOwned { fn into_cow(self) -> Cow<'a, B>; diff --git a/src/liballoc/tests/vec.rs b/src/liballoc/tests/vec.rs index 0fdcf34c783a8..473d41d483eff 100644 --- a/src/liballoc/tests/vec.rs +++ b/src/liballoc/tests/vec.rs @@ -1,8 +1,10 @@ -use std::borrow::Cow; -use std::mem::size_of; -use std::{usize, isize}; -use std::vec::{Drain, IntoIter}; -use std::collections::CollectionAllocErr::*; +use std::{ + borrow::Cow, + mem::size_of, + usize, isize, + vec::{Drain, IntoIter}, + collections::CollectionAllocErr::*, +}; struct DropCounter<'a> { count: &'a mut u32, diff --git a/src/liballoc/tests/vec_deque.rs b/src/liballoc/tests/vec_deque.rs index c9d16a06b4773..cbc9fefcdff9e 100644 --- a/src/liballoc/tests/vec_deque.rs +++ b/src/liballoc/tests/vec_deque.rs @@ -1,9 +1,14 @@ -use std::collections::VecDeque; -use std::fmt::Debug; -use std::collections::vec_deque::{Drain}; -use std::collections::CollectionAllocErr::*; -use std::mem::size_of; -use std::{usize, isize}; +use std::{ + fmt::Debug, + collections::{ + VecDeque, vec_deque::Drain, + CollectionAllocErr::*, + }, + mem::size_of, + usize, isize, +}; + +use crate::hash; use self::Taggy::*; use self::Taggypar::*; @@ -583,7 +588,7 @@ fn test_hash() { y.push_back(2); y.push_back(3); - assert!(::hash(&x) == ::hash(&y)); + assert!(hash(&x) == hash(&y)); } #[test] @@ -599,7 +604,7 @@ fn test_hash_after_rotation() { *elt -= 1; } ring.push_back(len - 1); - assert_eq!(::hash(&orig), ::hash(&ring)); + assert_eq!(hash(&orig), hash(&ring)); assert_eq!(orig, ring); assert_eq!(ring, orig); } diff --git a/src/liballoc/vec.rs b/src/liballoc/vec.rs index b942bce678b97..69fcd87dae697 100644 --- a/src/liballoc/vec.rs +++ b/src/liballoc/vec.rs @@ -56,25 +56,30 @@ #![stable(feature = "rust1", since = "1.0.0")] -use core::cmp::{self, Ordering}; -use core::fmt; -use core::hash::{self, Hash}; -use core::intrinsics::{arith_offset, assume}; -use core::iter::{FromIterator, FusedIterator, TrustedLen}; -use core::marker::PhantomData; -use core::mem; -use core::ops::Bound::{Excluded, Included, Unbounded}; -use core::ops::{Index, IndexMut, RangeBounds}; -use core::ops; -use core::ptr; -use core::ptr::NonNull; -use core::slice; - -use crate::collections::CollectionAllocErr; -use crate::borrow::ToOwned; -use crate::borrow::Cow; -use crate::boxed::Box; -use crate::raw_vec::RawVec; +use core::{ + cmp::{self, Ordering}, + fmt, + hash::{self, Hash}, + intrinsics::{arith_offset, assume}, + iter::{FromIterator, FusedIterator, TrustedLen}, + marker::PhantomData, + mem, + ops::{ + self, + Bound::{Excluded, Included, Unbounded}, + Index, IndexMut, RangeBounds, + }, + ptr::{self, NonNull}, + slice, +}; + +use crate::{ + collections::CollectionAllocErr, + borrow::ToOwned, + borrow::Cow, + boxed::Box, + raw_vec::RawVec, +}; /// A contiguous growable array type, written `Vec` but pronounced 'vector'. /// @@ -1646,7 +1651,7 @@ impl Clone for Vec { // NB see the slice::hack module in slice.rs for more information #[cfg(test)] fn clone(&self) -> Vec { - ::slice::to_vec(&**self) + crate::slice::to_vec(&**self) } fn clone_from(&mut self, other: &Vec) { @@ -2193,7 +2198,7 @@ impl<'a, T: Clone> From<&'a [T]> for Vec { } #[cfg(test)] fn from(s: &'a [T]) -> Vec { - ::slice::to_vec(s) + crate::slice::to_vec(s) } } @@ -2205,7 +2210,7 @@ impl<'a, T: Clone> From<&'a mut [T]> for Vec { } #[cfg(test)] fn from(s: &'a mut [T]) -> Vec { - ::slice::to_vec(s) + crate::slice::to_vec(s) } }