From 5594b0d5b8924e57f62d0408acb6d7982e93ad65 Mon Sep 17 00:00:00 2001 From: Mazdak Farrokhzad Date: Sat, 2 Feb 2019 08:36:03 +0100 Subject: [PATCH 01/12] liballoc => edition = 2018. --- src/liballoc/Cargo.toml | 1 + 1 file changed, 1 insertion(+) diff --git a/src/liballoc/Cargo.toml b/src/liballoc/Cargo.toml index 861c7cecb8879..f6d6c1de8f511 100644 --- a/src/liballoc/Cargo.toml +++ b/src/liballoc/Cargo.toml @@ -4,6 +4,7 @@ name = "alloc" version = "0.0.0" autotests = false autobenches = false +edition = "2018" [lib] name = "alloc" From e6e27924e17aa7def20ecaf88abc18ead6d97f93 Mon Sep 17 00:00:00 2001 From: Mazdak Farrokhzad Date: Sat, 2 Feb 2019 08:36:45 +0100 Subject: [PATCH 02/12] liballoc: cargo check passes on 2018 --- src/liballoc/borrow.rs | 4 ++-- src/liballoc/boxed.rs | 6 +++--- src/liballoc/collections/binary_heap.rs | 4 ++-- src/liballoc/collections/btree/map.rs | 2 +- src/liballoc/collections/btree/node.rs | 4 ++-- src/liballoc/collections/btree/search.rs | 2 +- src/liballoc/collections/btree/set.rs | 4 ++-- src/liballoc/collections/linked_list.rs | 2 +- src/liballoc/collections/mod.rs | 2 +- src/liballoc/collections/vec_deque.rs | 6 +++--- src/liballoc/fmt.rs | 2 +- src/liballoc/prelude.rs | 10 +++++----- src/liballoc/raw_vec.rs | 10 +++++----- src/liballoc/rc.rs | 8 ++++---- src/liballoc/slice.rs | 13 +++++++------ src/liballoc/str.rs | 10 +++++----- src/liballoc/string.rs | 10 +++++----- src/liballoc/sync.rs | 10 +++++----- src/liballoc/task.rs | 2 +- src/liballoc/vec.rs | 10 +++++----- 20 files changed, 61 insertions(+), 60 deletions(-) diff --git a/src/liballoc/borrow.rs b/src/liballoc/borrow.rs index b47337e44b2fe..4c6f150ca1b42 100644 --- a/src/liballoc/borrow.rs +++ b/src/liballoc/borrow.rs @@ -6,8 +6,8 @@ use core::cmp::Ordering; use core::hash::{Hash, Hasher}; use core::ops::{Add, AddAssign, Deref}; -use fmt; -use string::String; +use crate::fmt; +use crate::string::String; use self::Cow::*; diff --git a/src/liballoc/boxed.rs b/src/liballoc/boxed.rs index 14a1242e3e569..7b322a5c39692 100644 --- a/src/liballoc/boxed.rs +++ b/src/liballoc/boxed.rs @@ -73,9 +73,9 @@ use core::ops::{ use core::ptr::{self, NonNull, Unique}; use core::task::{LocalWaker, Poll}; -use vec::Vec; -use raw_vec::RawVec; -use str::from_boxed_utf8_unchecked; +use crate::vec::Vec; +use crate::raw_vec::RawVec; +use crate::str::from_boxed_utf8_unchecked; /// A pointer type for heap allocation. /// diff --git a/src/liballoc/collections/binary_heap.rs b/src/liballoc/collections/binary_heap.rs index ad544e6015e4a..079c6290ebd40 100644 --- a/src/liballoc/collections/binary_heap.rs +++ b/src/liballoc/collections/binary_heap.rs @@ -151,8 +151,8 @@ use core::mem::{swap, size_of, ManuallyDrop}; use core::ptr; use core::fmt; -use slice; -use vec::{self, Vec}; +use crate::slice; +use crate::vec::{self, Vec}; use super::SpecExtend; diff --git a/src/liballoc/collections/btree/map.rs b/src/liballoc/collections/btree/map.rs index 717650aca9600..efb4b8afdb70a 100644 --- a/src/liballoc/collections/btree/map.rs +++ b/src/liballoc/collections/btree/map.rs @@ -8,7 +8,7 @@ use core::ops::Index; use core::ops::RangeBounds; use core::{fmt, intrinsics, mem, ptr}; -use borrow::Borrow; +use crate::borrow::Borrow; use super::node::{self, Handle, NodeRef, marker}; use super::search; diff --git a/src/liballoc/collections/btree/node.rs b/src/liballoc/collections/btree/node.rs index e969e119dbe88..92664bad4e4a5 100644 --- a/src/liballoc/collections/btree/node.rs +++ b/src/liballoc/collections/btree/node.rs @@ -36,8 +36,8 @@ use core::mem::{self, MaybeUninit}; use core::ptr::{self, Unique, NonNull}; use core::slice; -use alloc::{Global, Alloc, Layout}; -use boxed::Box; +use crate::alloc::{Global, Alloc, Layout}; +use crate::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 9010de7c16ac3..242dc4b94d8ad 100644 --- a/src/liballoc/collections/btree/search.rs +++ b/src/liballoc/collections/btree/search.rs @@ -1,6 +1,6 @@ use core::cmp::Ordering; -use borrow::Borrow; +use crate::borrow::Borrow; use super::node::{Handle, NodeRef, marker}; diff --git a/src/liballoc/collections/btree/set.rs b/src/liballoc/collections/btree/set.rs index 71fec7da9a5ed..01a0562bc2153 100644 --- a/src/liballoc/collections/btree/set.rs +++ b/src/liballoc/collections/btree/set.rs @@ -8,8 +8,8 @@ use core::fmt; use core::iter::{Peekable, FromIterator, FusedIterator}; use core::ops::{BitOr, BitAnd, BitXor, Sub, RangeBounds}; -use borrow::Borrow; -use collections::btree_map::{self, BTreeMap, Keys}; +use crate::borrow::Borrow; +use crate::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 804a2e9c8873b..c666adb41a738 100644 --- a/src/liballoc/collections/linked_list.rs +++ b/src/liballoc/collections/linked_list.rs @@ -20,7 +20,7 @@ use core::marker::PhantomData; use core::mem; use core::ptr::NonNull; -use boxed::Box; +use crate::boxed::Box; use super::SpecExtend; /// A doubly-linked list with owned nodes. diff --git a/src/liballoc/collections/mod.rs b/src/liballoc/collections/mod.rs index 138f5d79bb008..5f3f849373091 100644 --- a/src/liballoc/collections/mod.rs +++ b/src/liballoc/collections/mod.rs @@ -41,7 +41,7 @@ pub use self::linked_list::LinkedList; #[doc(no_inline)] pub use self::vec_deque::VecDeque; -use alloc::{AllocErr, LayoutErr}; +use crate::alloc::{AllocErr, LayoutErr}; /// Augments `AllocErr` with a CapacityOverflow variant. #[derive(Clone, PartialEq, Eq, Debug)] diff --git a/src/liballoc/collections/vec_deque.rs b/src/liballoc/collections/vec_deque.rs index 579d7de96e6da..65d4253d0c67c 100644 --- a/src/liballoc/collections/vec_deque.rs +++ b/src/liballoc/collections/vec_deque.rs @@ -20,9 +20,9 @@ use core::slice; use core::hash::{Hash, Hasher}; use core::cmp; -use collections::CollectionAllocErr; -use raw_vec::RawVec; -use vec::Vec; +use crate::collections::CollectionAllocErr; +use crate::raw_vec::RawVec; +use crate::vec::Vec; const INITIAL_CAPACITY: usize = 7; // 2^3 - 1 const MINIMUM_CAPACITY: usize = 1; // 2 - 1 diff --git a/src/liballoc/fmt.rs b/src/liballoc/fmt.rs index a1e7533449c69..8d12b19a06d12 100644 --- a/src/liballoc/fmt.rs +++ b/src/liballoc/fmt.rs @@ -527,7 +527,7 @@ pub use core::fmt::{DebugList, DebugMap, DebugSet, DebugStruct, DebugTuple}; #[stable(feature = "fmt_flags_align", since = "1.28.0")] pub use core::fmt::{Alignment}; -use string; +use crate::string; /// The `format` function takes an [`Arguments`] struct and returns the resulting /// formatted string. diff --git a/src/liballoc/prelude.rs b/src/liballoc/prelude.rs index 7cd22095de417..6767cf89f73ba 100644 --- a/src/liballoc/prelude.rs +++ b/src/liballoc/prelude.rs @@ -12,8 +12,8 @@ #![unstable(feature = "alloc", issue = "27783")] -#[unstable(feature = "alloc", issue = "27783")] pub use borrow::ToOwned; -#[unstable(feature = "alloc", issue = "27783")] pub use boxed::Box; -#[unstable(feature = "alloc", issue = "27783")] pub use slice::SliceConcatExt; -#[unstable(feature = "alloc", issue = "27783")] pub use string::{String, ToString}; -#[unstable(feature = "alloc", issue = "27783")] pub use vec::Vec; +#[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; diff --git a/src/liballoc/raw_vec.rs b/src/liballoc/raw_vec.rs index 5e4aac9ce7871..9f9dd134826f0 100644 --- a/src/liballoc/raw_vec.rs +++ b/src/liballoc/raw_vec.rs @@ -7,10 +7,10 @@ use core::ops::Drop; use core::ptr::{self, NonNull, Unique}; use core::slice; -use alloc::{Alloc, Layout, Global, handle_alloc_error}; -use collections::CollectionAllocErr; -use collections::CollectionAllocErr::*; -use boxed::Box; +use crate::alloc::{Alloc, Layout, Global, handle_alloc_error}; +use crate::collections::CollectionAllocErr; +use crate::collections::CollectionAllocErr::*; +use crate::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 @@ -639,7 +639,7 @@ impl RawVec { strategy: ReserveStrategy, ) -> Result<(), CollectionAllocErr> { unsafe { - use alloc::AllocErr; + use crate::alloc::AllocErr; // NOTE: we don't early branch on ZSTs here because we want this // to actually catch "asking for more than usize::MAX" in that case. diff --git a/src/liballoc/rc.rs b/src/liballoc/rc.rs index c1f428658bd05..3c28c6d06fe75 100644 --- a/src/liballoc/rc.rs +++ b/src/liballoc/rc.rs @@ -227,7 +227,7 @@ #![stable(feature = "rust1", since = "1.0.0")] #[cfg(not(test))] -use boxed::Box; +use crate::boxed::Box; #[cfg(test)] use std::boxed::Box; @@ -248,9 +248,9 @@ use core::ptr::{self, NonNull}; use core::convert::From; use core::usize; -use alloc::{Global, Alloc, Layout, box_free, handle_alloc_error}; -use string::String; -use vec::Vec; +use crate::alloc::{Global, Alloc, Layout, box_free, handle_alloc_error}; +use crate::string::String; +use crate::vec::Vec; struct RcBox { strong: Cell, diff --git a/src/liballoc/slice.rs b/src/liballoc/slice.rs index db19f778617f4..0ed8aa6a2e420 100644 --- a/src/liballoc/slice.rs +++ b/src/liballoc/slice.rs @@ -93,9 +93,9 @@ use core::mem; use core::ptr; use core::{u8, u16, u32}; -use borrow::{Borrow, BorrowMut, ToOwned}; -use boxed::Box; -use vec::Vec; +use crate::borrow::{Borrow, BorrowMut, ToOwned}; +use crate::boxed::Box; +use crate::vec::Vec; #[stable(feature = "rust1", since = "1.0.0")] pub use core::slice::{Chunks, Windows}; @@ -137,12 +137,13 @@ pub use self::hack::to_vec; // `core::slice::SliceExt` - we need to supply these functions for the // `test_permutations` test mod hack { - use boxed::Box; use core::mem; + use crate::boxed::Box; #[cfg(test)] - use string::ToString; - use vec::Vec; + use crate::string::ToString; + + use crate::vec::Vec; pub fn into_vec(mut b: Box<[T]>) -> Vec { unsafe { diff --git a/src/liballoc/str.rs b/src/liballoc/str.rs index 60d9f1626138e..a44838d560a70 100644 --- a/src/liballoc/str.rs +++ b/src/liballoc/str.rs @@ -37,11 +37,11 @@ use core::ptr; use core::iter::FusedIterator; use core::unicode::conversions; -use borrow::{Borrow, ToOwned}; -use boxed::Box; -use slice::{SliceConcatExt, SliceIndex}; -use string::String; -use vec::Vec; +use crate::borrow::{Borrow, ToOwned}; +use crate::boxed::Box; +use crate::slice::{SliceConcatExt, SliceIndex}; +use crate::string::String; +use crate::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 fa15e9ad9018e..d8f46374ce21b 100644 --- a/src/liballoc/string.rs +++ b/src/liballoc/string.rs @@ -56,11 +56,11 @@ use core::ptr; use core::str::pattern::Pattern; use core::str::lossy; -use collections::CollectionAllocErr; -use borrow::{Cow, ToOwned}; -use boxed::Box; -use str::{self, from_boxed_utf8_unchecked, FromStr, Utf8Error, Chars}; -use vec::Vec; +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; /// A UTF-8 encoded, growable string. /// diff --git a/src/liballoc/sync.rs b/src/liballoc/sync.rs index f6cafd50dc8c9..b387f07f231e6 100644 --- a/src/liballoc/sync.rs +++ b/src/liballoc/sync.rs @@ -23,11 +23,11 @@ use core::hash::{Hash, Hasher}; use core::{isize, usize}; use core::convert::From; -use alloc::{Global, Alloc, Layout, box_free, handle_alloc_error}; -use boxed::Box; -use rc::is_dangling; -use string::String; -use vec::Vec; +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; /// A soft limit on the amount of references that may be made to an `Arc`. /// diff --git a/src/liballoc/task.rs b/src/liballoc/task.rs index 604c56dd01762..ba4e0dcda02df 100644 --- a/src/liballoc/task.rs +++ b/src/liballoc/task.rs @@ -11,7 +11,7 @@ mod if_arc { use core::marker::PhantomData; use core::mem; use core::ptr::{self, NonNull}; - use sync::Arc; + use crate::sync::Arc; /// A way of waking up a specific task. /// diff --git a/src/liballoc/vec.rs b/src/liballoc/vec.rs index ba3b3dfbfc2e1..b942bce678b97 100644 --- a/src/liballoc/vec.rs +++ b/src/liballoc/vec.rs @@ -70,11 +70,11 @@ use core::ptr; use core::ptr::NonNull; use core::slice; -use collections::CollectionAllocErr; -use borrow::ToOwned; -use borrow::Cow; -use boxed::Box; -use raw_vec::RawVec; +use crate::collections::CollectionAllocErr; +use crate::borrow::ToOwned; +use crate::borrow::Cow; +use crate::boxed::Box; +use crate::raw_vec::RawVec; /// A contiguous growable array type, written `Vec` but pronounced 'vector'. /// From 7693e3e6662c2ae8aa24d69434161f501d855420 Mon Sep 17 00:00:00 2001 From: Mazdak Farrokhzad Date: Sat, 2 Feb 2019 10:14:40 +0100 Subject: [PATCH 03/12] liballoc: refactor & fix some imports. --- src/liballoc/alloc.rs | 14 ++-- src/liballoc/benches/btree/map.rs | 8 ++- src/liballoc/benches/slice.rs | 11 ++-- src/liballoc/borrow.rs | 11 ++-- src/liballoc/boxed.rs | 38 +++++------ src/liballoc/boxed_test.rs | 14 ++-- src/liballoc/collections/binary_heap.rs | 20 +++--- src/liballoc/collections/btree/map.rs | 33 +++++----- src/liballoc/collections/btree/node.rs | 16 +++-- src/liballoc/collections/btree/search.rs | 3 +- src/liballoc/collections/btree/set.rs | 23 ++++--- src/liballoc/collections/linked_list.rs | 21 +++--- src/liballoc/collections/vec_deque.rs | 43 +++++++------ src/liballoc/fmt.rs | 25 +++----- src/liballoc/prelude.rs | 13 ++-- src/liballoc/raw_vec.rs | 25 ++++---- src/liballoc/rc.rs | 65 +++++++++---------- src/liballoc/slice.rs | 21 +++--- src/liballoc/str.rs | 33 ++++++---- src/liballoc/string.rs | 39 +++++++----- src/liballoc/sync.rs | 81 ++++++++++++------------ src/liballoc/task.rs | 8 ++- src/liballoc/tests/arc.rs | 10 +-- src/liballoc/tests/binary_heap.rs | 11 ++-- src/liballoc/tests/btree/map.rs | 11 ++-- src/liballoc/tests/btree/set.rs | 11 ++-- src/liballoc/tests/lib.rs | 6 +- src/liballoc/tests/linked_list.rs | 6 +- src/liballoc/tests/rc.rs | 10 +-- src/liballoc/tests/slice.rs | 29 +++++---- src/liballoc/tests/str.rs | 15 +++-- src/liballoc/tests/string.rs | 10 +-- src/liballoc/tests/vec.rs | 12 ++-- src/liballoc/tests/vec_deque.rs | 21 +++--- src/liballoc/vec.rs | 49 +++++++------- 35 files changed, 424 insertions(+), 342 deletions(-) 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) } } From f09f62f62c401a42bf338a23f8721c7f5a28a800 Mon Sep 17 00:00:00 2001 From: Mazdak Farrokhzad Date: Sat, 2 Feb 2019 10:34:36 +0100 Subject: [PATCH 04/12] liballoc: adjust abolute imports + more import fixes. --- src/liballoc/lib.rs | 2 +- src/liballoc/raw_vec.rs | 2 +- src/liballoc/rc.rs | 3 +-- src/liballoc/slice.rs | 4 +--- src/liballoc/string.rs | 2 +- src/liballoc/sync.rs | 3 +-- src/liballoc/tests/btree/map.rs | 2 +- src/liballoc/tests/str.rs | 4 ++-- src/liballoc/tests/string.rs | 4 ++-- src/liballoc/tests/vec.rs | 2 +- src/liballoc/vec.rs | 12 +++--------- 11 files changed, 15 insertions(+), 25 deletions(-) diff --git a/src/liballoc/lib.rs b/src/liballoc/lib.rs index 5165a7ca5a8f3..5d69b10054719 100644 --- a/src/liballoc/lib.rs +++ b/src/liballoc/lib.rs @@ -165,5 +165,5 @@ pub mod vec; #[cfg(not(test))] mod std { - pub use core::ops; // RangeFull + pub use core::ops; // RangeFull } diff --git a/src/liballoc/raw_vec.rs b/src/liballoc/raw_vec.rs index 92d482b1f052a..016185791edb6 100644 --- a/src/liballoc/raw_vec.rs +++ b/src/liballoc/raw_vec.rs @@ -736,7 +736,7 @@ unsafe impl<#[may_dangle] T, A: Alloc> Drop for RawVec { #[inline] fn alloc_guard(alloc_size: usize) -> Result<(), CollectionAllocErr> { - if mem::size_of::() < 8 && alloc_size > ::core::isize::MAX as usize { + if mem::size_of::() < 8 && alloc_size > core::isize::MAX as usize { Err(CapacityOverflow) } else { Ok(()) diff --git a/src/liballoc/rc.rs b/src/liballoc/rc.rs index 720ac4b630aee..c24e216383974 100644 --- a/src/liballoc/rc.rs +++ b/src/liballoc/rc.rs @@ -244,6 +244,7 @@ use core::{ ops::{Deref, Receiver, CoerceUnsized, DispatchFromDyn}, pin::Pin, ptr::{self, NonNull}, + slice::from_raw_parts_mut, convert::From, usize, }; @@ -768,8 +769,6 @@ impl RcFromSlice for Rc<[T]> { impl Drop for Guard { fn drop(&mut self) { - use core::slice::from_raw_parts_mut; - unsafe { let slice = from_raw_parts_mut(self.elems, self.n_elems); ptr::drop_in_place(slice); diff --git a/src/liballoc/slice.rs b/src/liballoc/slice.rs index 1cee3aa415b8b..771d8f5d3473c 100644 --- a/src/liballoc/slice.rs +++ b/src/liballoc/slice.rs @@ -141,13 +141,11 @@ pub use self::hack::to_vec; // `test_permutations` test mod hack { use core::mem; - use crate::boxed::Box; + use crate::{boxed::Box, vec::Vec}; #[cfg(test)] use crate::string::ToString; - use crate::vec::Vec; - pub fn into_vec(mut b: Box<[T]>) -> Vec { unsafe { let xs = Vec::from_raw_parts(b.as_mut_ptr(), b.len(), b.len()); diff --git a/src/liballoc/string.rs b/src/liballoc/string.rs index e9da10b3597f2..95f6b28a16817 100644 --- a/src/liballoc/string.rs +++ b/src/liballoc/string.rs @@ -2165,7 +2165,7 @@ pub trait ToString { impl ToString for T { #[inline] default fn to_string(&self) -> String { - use core::fmt::Write; + use fmt::Write; let mut buf = String::new(); buf.write_fmt(format_args!("{}", self)) .expect("a Display implementation returned an error unexpectedly"); diff --git a/src/liballoc/sync.rs b/src/liballoc/sync.rs index 2a4b3113bfe75..5e7a26132cb13 100644 --- a/src/liballoc/sync.rs +++ b/src/liballoc/sync.rs @@ -24,6 +24,7 @@ use core::{ hash::{Hash, Hasher}, isize, usize, convert::From, + slice::from_raw_parts_mut, }; use crate::{ @@ -677,8 +678,6 @@ impl ArcFromSlice for Arc<[T]> { impl Drop for Guard { fn drop(&mut self) { - use core::slice::from_raw_parts_mut; - unsafe { let slice = from_raw_parts_mut(self.elems, self.n_elems); ptr::drop_in_place(slice); diff --git a/src/liballoc/tests/btree/map.rs b/src/liballoc/tests/btree/map.rs index 33f65980784a1..6859b0138b5ed 100644 --- a/src/liballoc/tests/btree/map.rs +++ b/src/liballoc/tests/btree/map.rs @@ -200,7 +200,7 @@ fn test_range_inclusive() { #[test] fn test_range_inclusive_max_value() { - let max = ::std::usize::MAX; + let max = std::usize::MAX; let map: BTreeMap<_, _> = vec![(max, 0)].into_iter().collect(); assert_eq!(map.range(max..=max).collect::>(), &[(&max, &0)]); diff --git a/src/liballoc/tests/str.rs b/src/liballoc/tests/str.rs index 583e616bf6d75..28e021c741e7d 100644 --- a/src/liballoc/tests/str.rs +++ b/src/liballoc/tests/str.rs @@ -1070,7 +1070,7 @@ fn test_rev_iterator() { #[test] fn test_chars_decoding() { let mut bytes = [0; 4]; - for c in (0..0x110000).filter_map(::std::char::from_u32) { + for c in (0..0x110000).filter_map(std::char::from_u32) { let s = c.encode_utf8(&mut bytes); if Some(c) != s.chars().next() { panic!("character {:x}={} does not decode correctly", c as u32, c); @@ -1081,7 +1081,7 @@ fn test_chars_decoding() { #[test] fn test_chars_rev_decoding() { let mut bytes = [0; 4]; - for c in (0..0x110000).filter_map(::std::char::from_u32) { + for c in (0..0x110000).filter_map(std::char::from_u32) { let s = c.encode_utf8(&mut bytes); if Some(c) != s.chars().rev().next() { panic!("character {:x}={} does not decode correctly", c as u32, c); diff --git a/src/liballoc/tests/string.rs b/src/liballoc/tests/string.rs index 9e4ffb5be9d6e..14f70fdf3034d 100644 --- a/src/liballoc/tests/string.rs +++ b/src/liballoc/tests/string.rs @@ -23,7 +23,7 @@ impl<'a> IntoCow<'a, str> for &'a str { #[test] fn test_from_str() { - let owned: Option<::std::string::String> = "string".parse().ok(); + let owned: Option = "string".parse().ok(); assert_eq!(owned.as_ref().map(|s| &**s), Some("string")); } @@ -124,7 +124,7 @@ fn test_from_utf16() { let s_as_utf16 = s.encode_utf16().collect::>(); let u_as_string = String::from_utf16(&u).unwrap(); - assert!(::core::char::decode_utf16(u.iter().cloned()).all(|r| r.is_ok())); + assert!(core::char::decode_utf16(u.iter().cloned()).all(|r| r.is_ok())); assert_eq!(s_as_utf16, u); assert_eq!(u_as_string, s); diff --git a/src/liballoc/tests/vec.rs b/src/liballoc/tests/vec.rs index 473d41d483eff..b65c68d51a502 100644 --- a/src/liballoc/tests/vec.rs +++ b/src/liballoc/tests/vec.rs @@ -640,7 +640,7 @@ fn test_splice_unbounded() { fn test_splice_forget() { let mut v = vec![1, 2, 3, 4, 5]; let a = [10, 11, 12]; - ::std::mem::forget(v.splice(2..4, a.iter().cloned())); + std::mem::forget(v.splice(2..4, a.iter().cloned())); assert_eq!(v, &[1, 2]); } diff --git a/src/liballoc/vec.rs b/src/liballoc/vec.rs index 69fcd87dae697..2ef1497ade715 100644 --- a/src/liballoc/vec.rs +++ b/src/liballoc/vec.rs @@ -70,7 +70,7 @@ use core::{ Index, IndexMut, RangeBounds, }, ptr::{self, NonNull}, - slice, + slice::{self, SliceIndex}, }; use crate::{ @@ -1672,10 +1672,7 @@ impl Hash for Vec { message="vector indices are of type `usize` or ranges of `usize`", label="vector indices are of type `usize` or ranges of `usize`", )] -impl Index for Vec -where - I: ::core::slice::SliceIndex<[T]>, -{ +impl> Index for Vec { type Output = I::Output; #[inline] @@ -1689,10 +1686,7 @@ where message="vector indices are of type `usize` or ranges of `usize`", label="vector indices are of type `usize` or ranges of `usize`", )] -impl IndexMut for Vec -where - I: ::core::slice::SliceIndex<[T]>, -{ +impl> IndexMut for Vec { #[inline] fn index_mut(&mut self, index: I) -> &mut Self::Output { IndexMut::index_mut(&mut **self, index) From 3bfa0a35f65b08197fe677731ac8a9a81a7710bd Mon Sep 17 00:00:00 2001 From: Mazdak Farrokhzad Date: Sat, 2 Feb 2019 10:53:27 +0100 Subject: [PATCH 05/12] liballoc: prefer imports of borrow from libcore. --- src/liballoc/collections/btree/map.rs | 3 +-- src/liballoc/collections/btree/search.rs | 7 ++++--- src/liballoc/collections/btree/set.rs | 6 ++---- src/liballoc/slice.rs | 3 ++- src/liballoc/str.rs | 3 ++- src/liballoc/string.rs | 2 +- src/liballoc/vec.rs | 3 +-- 7 files changed, 13 insertions(+), 14 deletions(-) diff --git a/src/liballoc/collections/btree/map.rs b/src/liballoc/collections/btree/map.rs index f81cf6f104719..b1a5fcbe6b6c2 100644 --- a/src/liballoc/collections/btree/map.rs +++ b/src/liballoc/collections/btree/map.rs @@ -1,4 +1,5 @@ use core::{ + borrow::Borrow, cmp::Ordering, fmt::Debug, hash::{Hash, Hasher}, @@ -11,8 +12,6 @@ use core::{ fmt, intrinsics, mem, ptr, }; -use crate::borrow::Borrow; - use super::{ node::{self, Handle, NodeRef, marker, InsertResult::*, ForceResult::*}, search::{self, SearchResult::*}, diff --git a/src/liballoc/collections/btree/search.rs b/src/liballoc/collections/btree/search.rs index a3b56ad17c6b7..23c41b4dd4ceb 100644 --- a/src/liballoc/collections/btree/search.rs +++ b/src/liballoc/collections/btree/search.rs @@ -1,6 +1,7 @@ -use core::cmp::Ordering; - -use crate::borrow::Borrow; +use core::{ + borrow::Borrow, + cmp::Ordering, +}; use super::node::{Handle, NodeRef, marker, ForceResult::*}; diff --git a/src/liballoc/collections/btree/set.rs b/src/liballoc/collections/btree/set.rs index 298d165a91afa..9231d2e67cf81 100644 --- a/src/liballoc/collections/btree/set.rs +++ b/src/liballoc/collections/btree/set.rs @@ -2,6 +2,7 @@ // to TreeMap use core::{ + borrow::Borrow, cmp::{ Ordering::{self, Less, Greater, Equal}, min, max, @@ -11,10 +12,7 @@ use core::{ ops::{BitOr, BitAnd, BitXor, Sub, RangeBounds}, }; -use crate::{ - borrow::Borrow, - collections::btree_map::{self, BTreeMap, Keys}, -}; +use crate::collections::btree_map::{self, BTreeMap, Keys}; use super::Recover; // FIXME(conventions): implement bounded iterators diff --git a/src/liballoc/slice.rs b/src/liballoc/slice.rs index 771d8f5d3473c..5e17396f6d7a9 100644 --- a/src/liballoc/slice.rs +++ b/src/liballoc/slice.rs @@ -88,6 +88,7 @@ #![cfg_attr(test, allow(unused_imports, dead_code))] use core::{ + borrow::{Borrow, BorrowMut}, cmp::Ordering::{self, Less}, mem::{self, size_of}, ptr, @@ -95,7 +96,7 @@ use core::{ }; use crate::{ - borrow::{Borrow, BorrowMut, ToOwned}, + borrow::ToOwned, boxed::Box, vec::Vec, }; diff --git a/src/liballoc/str.rs b/src/liballoc/str.rs index 85437defd5733..9681572d883f5 100644 --- a/src/liballoc/str.rs +++ b/src/liballoc/str.rs @@ -29,6 +29,7 @@ #![allow(unused_imports)] use core::{ + borrow::Borrow, fmt, str::{ self as core_str, @@ -41,7 +42,7 @@ use core::{ }; use crate::{ - borrow::{Borrow, ToOwned}, + borrow::ToOwned, boxed::Box, slice::{SliceConcatExt, SliceIndex}, string::String, diff --git a/src/liballoc/string.rs b/src/liballoc/string.rs index 95f6b28a16817..d74a3f004a305 100644 --- a/src/liballoc/string.rs +++ b/src/liballoc/string.rs @@ -64,8 +64,8 @@ use core::{ }; use crate::{ - collections::CollectionAllocErr, borrow::{Cow, ToOwned}, + collections::CollectionAllocErr, boxed::Box, str::{self, from_boxed_utf8_unchecked, FromStr, Utf8Error, Chars}, vec::Vec, diff --git a/src/liballoc/vec.rs b/src/liballoc/vec.rs index 2ef1497ade715..8e09720688156 100644 --- a/src/liballoc/vec.rs +++ b/src/liballoc/vec.rs @@ -74,9 +74,8 @@ use core::{ }; use crate::{ + borrow::{ToOwned, Cow}, collections::CollectionAllocErr, - borrow::ToOwned, - borrow::Cow, boxed::Box, raw_vec::RawVec, }; From 748970dfa9c12c1a09da4ff3ec724e4dbf7e796d Mon Sep 17 00:00:00 2001 From: Mazdak Farrokhzad Date: Sat, 2 Feb 2019 11:05:20 +0100 Subject: [PATCH 06/12] liballoc: apply uniform_paths. --- src/liballoc/alloc.rs | 2 +- src/liballoc/borrow.rs | 8 ++++---- src/liballoc/collections/btree/map.rs | 3 ++- src/liballoc/collections/btree/search.rs | 2 +- src/liballoc/collections/mod.rs | 10 +++++----- src/liballoc/raw_vec.rs | 4 ++-- src/liballoc/slice.rs | 4 ++-- src/liballoc/task.rs | 2 +- src/liballoc/tests/vec_deque.rs | 4 ++-- 9 files changed, 20 insertions(+), 19 deletions(-) diff --git a/src/liballoc/alloc.rs b/src/liballoc/alloc.rs index bb88897323eaf..515de9852d1a6 100644 --- a/src/liballoc/alloc.rs +++ b/src/liballoc/alloc.rs @@ -229,7 +229,7 @@ pub fn handle_alloc_error(layout: Layout) -> ! { #[cfg(test)] mod tests { extern crate test; - use self::test::Bencher; + use test::Bencher; use crate::{ boxed::Box, alloc::{Global, Alloc, Layout, handle_alloc_error}, diff --git a/src/liballoc/borrow.rs b/src/liballoc/borrow.rs index 8161d588fbdb8..c1696005373a0 100644 --- a/src/liballoc/borrow.rs +++ b/src/liballoc/borrow.rs @@ -8,13 +8,13 @@ use core::{ ops::{Add, AddAssign, Deref}, }; -use crate::{fmt, string::String}; - -use self::Cow::*; - #[stable(feature = "rust1", since = "1.0.0")] pub use core::borrow::{Borrow, BorrowMut}; +use crate::{fmt, string::String}; + +use Cow::*; + #[stable(feature = "rust1", since = "1.0.0")] impl<'a, B: ?Sized> Borrow for Cow<'a, B> where B: ToOwned, diff --git a/src/liballoc/collections/btree/map.rs b/src/liballoc/collections/btree/map.rs index b1a5fcbe6b6c2..d0e35c557a4d0 100644 --- a/src/liballoc/collections/btree/map.rs +++ b/src/liballoc/collections/btree/map.rs @@ -17,7 +17,8 @@ use super::{ search::{self, SearchResult::*}, }; -use self::{UnderflowResult::*, Entry::*}; +use UnderflowResult::*; +use Entry::*; /// A map based on a B-Tree. /// diff --git a/src/liballoc/collections/btree/search.rs b/src/liballoc/collections/btree/search.rs index 23c41b4dd4ceb..1645e48cb5299 100644 --- a/src/liballoc/collections/btree/search.rs +++ b/src/liballoc/collections/btree/search.rs @@ -5,7 +5,7 @@ use core::{ use super::node::{Handle, NodeRef, marker, ForceResult::*}; -use self::SearchResult::*; +use SearchResult::*; pub enum SearchResult { Found(Handle, marker::KV>), diff --git a/src/liballoc/collections/mod.rs b/src/liballoc/collections/mod.rs index 5f3f849373091..5a33ddc14f004 100644 --- a/src/liballoc/collections/mod.rs +++ b/src/liballoc/collections/mod.rs @@ -23,23 +23,23 @@ pub mod btree_set { #[stable(feature = "rust1", since = "1.0.0")] #[doc(no_inline)] -pub use self::binary_heap::BinaryHeap; +pub use binary_heap::BinaryHeap; #[stable(feature = "rust1", since = "1.0.0")] #[doc(no_inline)] -pub use self::btree_map::BTreeMap; +pub use btree_map::BTreeMap; #[stable(feature = "rust1", since = "1.0.0")] #[doc(no_inline)] -pub use self::btree_set::BTreeSet; +pub use btree_set::BTreeSet; #[stable(feature = "rust1", since = "1.0.0")] #[doc(no_inline)] -pub use self::linked_list::LinkedList; +pub use linked_list::LinkedList; #[stable(feature = "rust1", since = "1.0.0")] #[doc(no_inline)] -pub use self::vec_deque::VecDeque; +pub use vec_deque::VecDeque; use crate::alloc::{AllocErr, LayoutErr}; diff --git a/src/liballoc/raw_vec.rs b/src/liballoc/raw_vec.rs index 016185791edb6..f1839f736341c 100644 --- a/src/liballoc/raw_vec.rs +++ b/src/liballoc/raw_vec.rs @@ -624,14 +624,14 @@ enum Fallibility { Infallible, } -use self::Fallibility::*; +use Fallibility::*; enum ReserveStrategy { Exact, Amortized, } -use self::ReserveStrategy::*; +use ReserveStrategy::*; impl RawVec { fn reserve_internal( diff --git a/src/liballoc/slice.rs b/src/liballoc/slice.rs index 5e17396f6d7a9..9d1197117bbda 100644 --- a/src/liballoc/slice.rs +++ b/src/liballoc/slice.rs @@ -129,12 +129,12 @@ pub use core::slice::{RChunks, RChunksMut, RChunksExact, RChunksExactMut}; // HACK(japaric) needed for the implementation of `vec!` macro during testing // NB see the hack module in this file for more details #[cfg(test)] -pub use self::hack::into_vec; +pub use hack::into_vec; // HACK(japaric) needed for the implementation of `Vec::clone` during testing // NB see the hack module in this file for more details #[cfg(test)] -pub use self::hack::to_vec; +pub use hack::to_vec; // HACK(japaric): With cfg(test) `impl [T]` is not available, these three // functions are actually methods that are in `impl [T]` but not in diff --git a/src/liballoc/task.rs b/src/liballoc/task.rs index 89dc2b10a9294..0bf1ff35cc175 100644 --- a/src/liballoc/task.rs +++ b/src/liballoc/task.rs @@ -3,7 +3,7 @@ pub use core::task::*; #[cfg(all(target_has_atomic = "ptr", target_has_atomic = "cas"))] -pub use self::if_arc::*; +pub use if_arc::*; #[cfg(all(target_has_atomic = "ptr", target_has_atomic = "cas"))] mod if_arc { diff --git a/src/liballoc/tests/vec_deque.rs b/src/liballoc/tests/vec_deque.rs index cbc9fefcdff9e..44183956d8fc7 100644 --- a/src/liballoc/tests/vec_deque.rs +++ b/src/liballoc/tests/vec_deque.rs @@ -10,8 +10,8 @@ use std::{ use crate::hash; -use self::Taggy::*; -use self::Taggypar::*; +use Taggy::*; +use Taggypar::*; #[test] fn test_simple() { From e70c2fbd5cbe8bf176f1ed01ba9a53cec7e842a5 Mon Sep 17 00:00:00 2001 From: Mazdak Farrokhzad Date: Sat, 2 Feb 2019 12:23:15 +0100 Subject: [PATCH 07/12] liballoc: elide some lifetimes. --- src/liballoc/borrow.rs | 20 ++++-------- src/liballoc/boxed.rs | 4 +-- src/liballoc/collections/binary_heap.rs | 24 +++++++------- src/liballoc/collections/btree/map.rs | 43 ++++++++++++------------- src/liballoc/collections/btree/set.rs | 32 +++++++++--------- src/liballoc/collections/linked_list.rs | 22 ++++++------- src/liballoc/collections/vec_deque.rs | 42 ++++++++++++------------ src/liballoc/string.rs | 20 ++++++------ src/liballoc/sync.rs | 4 +-- src/liballoc/tests/vec.rs | 2 +- src/liballoc/tests/vec_deque.rs | 2 +- src/liballoc/vec.rs | 30 ++++++++--------- 12 files changed, 119 insertions(+), 126 deletions(-) diff --git a/src/liballoc/borrow.rs b/src/liballoc/borrow.rs index c1696005373a0..816cdbc9ce673 100644 --- a/src/liballoc/borrow.rs +++ b/src/liballoc/borrow.rs @@ -183,9 +183,7 @@ pub enum Cow<'a, B: ?Sized + 'a> } #[stable(feature = "rust1", since = "1.0.0")] -impl<'a, B: ?Sized> Clone for Cow<'a, B> - where B: ToOwned -{ +impl<'a, B: ?Sized + ToOwned> Clone for Cow<'a, B> { fn clone(&self) -> Cow<'a, B> { match *self { Borrowed(b) => Borrowed(b), @@ -208,9 +206,7 @@ impl<'a, B: ?Sized> Clone for Cow<'a, B> } } -impl<'a, B: ?Sized> Cow<'a, B> - where B: ToOwned -{ +impl Cow<'_, B> { /// Acquires a mutable reference to the owned form of the data. /// /// Clones the data if it is not already owned. @@ -286,9 +282,7 @@ impl<'a, B: ?Sized> Cow<'a, B> } #[stable(feature = "rust1", since = "1.0.0")] -impl<'a, B: ?Sized> Deref for Cow<'a, B> - where B: ToOwned -{ +impl Deref for Cow<'_, B> { type Target = B; fn deref(&self) -> &B { @@ -300,7 +294,7 @@ impl<'a, B: ?Sized> Deref for Cow<'a, B> } #[stable(feature = "rust1", since = "1.0.0")] -impl<'a, B: ?Sized> Eq for Cow<'a, B> where B: Eq + ToOwned {} +impl Eq for Cow<'_, B> where B: Eq + ToOwned {} #[stable(feature = "rust1", since = "1.0.0")] impl<'a, B: ?Sized> Ord for Cow<'a, B> @@ -334,7 +328,7 @@ impl<'a, B: ?Sized> PartialOrd for Cow<'a, B> } #[stable(feature = "rust1", since = "1.0.0")] -impl<'a, B: ?Sized> fmt::Debug for Cow<'a, B> +impl fmt::Debug for Cow<'_, B> where B: fmt::Debug + ToOwned, ::Owned: fmt::Debug { @@ -347,7 +341,7 @@ impl<'a, B: ?Sized> fmt::Debug for Cow<'a, B> } #[stable(feature = "rust1", since = "1.0.0")] -impl<'a, B: ?Sized> fmt::Display for Cow<'a, B> +impl fmt::Display for Cow<'_, B> where B: fmt::Display + ToOwned, ::Owned: fmt::Display { @@ -381,7 +375,7 @@ impl<'a, B: ?Sized> Hash for Cow<'a, B> } #[stable(feature = "rust1", since = "1.0.0")] -impl<'a, T: ?Sized + ToOwned> AsRef for Cow<'a, T> { +impl AsRef for Cow<'_, T> { fn as_ref(&self) -> &T { self } diff --git a/src/liballoc/boxed.rs b/src/liballoc/boxed.rs index f590b6488d9da..6f6fff0a657d0 100644 --- a/src/liballoc/boxed.rs +++ b/src/liballoc/boxed.rs @@ -739,7 +739,7 @@ impl FnBox for F #[unstable(feature = "fnbox", reason = "will be deprecated if and when `Box` becomes usable", issue = "28796")] -impl<'a, A, R> FnOnce for Box + 'a> { +impl FnOnce for Box + '_> { type Output = R; extern "rust-call" fn call_once(self, args: A) -> R { @@ -749,7 +749,7 @@ impl<'a, A, R> FnOnce for Box + 'a> { #[unstable(feature = "fnbox", reason = "will be deprecated if and when `Box` becomes usable", issue = "28796")] -impl<'a, A, R> FnOnce for Box + Send + 'a> { +impl FnOnce for Box + Send + '_> { type Output = R; extern "rust-call" fn call_once(self, args: A) -> R { diff --git a/src/liballoc/collections/binary_heap.rs b/src/liballoc/collections/binary_heap.rs index 4a38f041636ef..43416e57591bc 100644 --- a/src/liballoc/collections/binary_heap.rs +++ b/src/liballoc/collections/binary_heap.rs @@ -231,7 +231,7 @@ pub struct PeekMut<'a, T: 'a + Ord> { } #[stable(feature = "collection_debug", since = "1.17.0")] -impl<'a, T: Ord + fmt::Debug> fmt::Debug for PeekMut<'a, T> { +impl fmt::Debug for PeekMut<'_, T> { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { f.debug_tuple("PeekMut") .field(&self.heap.data[0]) @@ -240,7 +240,7 @@ impl<'a, T: Ord + fmt::Debug> fmt::Debug for PeekMut<'a, T> { } #[stable(feature = "binary_heap_peek_mut", since = "1.12.0")] -impl<'a, T: Ord> Drop for PeekMut<'a, T> { +impl Drop for PeekMut<'_, T> { fn drop(&mut self) { if self.sift { self.heap.sift_down(0); @@ -249,7 +249,7 @@ impl<'a, T: Ord> Drop for PeekMut<'a, T> { } #[stable(feature = "binary_heap_peek_mut", since = "1.12.0")] -impl<'a, T: Ord> Deref for PeekMut<'a, T> { +impl Deref for PeekMut<'_, T> { type Target = T; fn deref(&self) -> &T { &self.heap.data[0] @@ -257,7 +257,7 @@ impl<'a, T: Ord> Deref for PeekMut<'a, T> { } #[stable(feature = "binary_heap_peek_mut", since = "1.12.0")] -impl<'a, T: Ord> DerefMut for PeekMut<'a, T> { +impl DerefMut for PeekMut<'_, T> { fn deref_mut(&mut self) -> &mut T { &mut self.heap.data[0] } @@ -912,7 +912,7 @@ impl<'a, T> Hole<'a, T> { } } -impl<'a, T> Drop for Hole<'a, T> { +impl Drop for Hole<'_, T> { #[inline] fn drop(&mut self) { // fill the hole again @@ -936,7 +936,7 @@ pub struct Iter<'a, T: 'a> { } #[stable(feature = "collection_debug", since = "1.17.0")] -impl<'a, T: 'a + fmt::Debug> fmt::Debug for Iter<'a, T> { +impl fmt::Debug for Iter<'_, T> { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { f.debug_tuple("Iter") .field(&self.iter.as_slice()) @@ -976,14 +976,14 @@ impl<'a, T> DoubleEndedIterator for Iter<'a, T> { } #[stable(feature = "rust1", since = "1.0.0")] -impl<'a, T> ExactSizeIterator for Iter<'a, T> { +impl ExactSizeIterator for Iter<'_, T> { fn is_empty(&self) -> bool { self.iter.is_empty() } } #[stable(feature = "fused", since = "1.26.0")] -impl<'a, T> FusedIterator for Iter<'a, T> {} +impl FusedIterator for Iter<'_, T> {} /// An owning iterator over the elements of a `BinaryHeap`. /// @@ -1054,7 +1054,7 @@ pub struct Drain<'a, T: 'a> { } #[stable(feature = "drain", since = "1.6.0")] -impl<'a, T: 'a> Iterator for Drain<'a, T> { +impl Iterator for Drain<'_, T> { type Item = T; #[inline] @@ -1069,7 +1069,7 @@ impl<'a, T: 'a> Iterator for Drain<'a, T> { } #[stable(feature = "drain", since = "1.6.0")] -impl<'a, T: 'a> DoubleEndedIterator for Drain<'a, T> { +impl DoubleEndedIterator for Drain<'_, T> { #[inline] fn next_back(&mut self) -> Option { self.iter.next_back() @@ -1077,14 +1077,14 @@ impl<'a, T: 'a> DoubleEndedIterator for Drain<'a, T> { } #[stable(feature = "drain", since = "1.6.0")] -impl<'a, T: 'a> ExactSizeIterator for Drain<'a, T> { +impl ExactSizeIterator for Drain<'_, T> { fn is_empty(&self) -> bool { self.iter.is_empty() } } #[stable(feature = "fused", since = "1.26.0")] -impl<'a, T: 'a> FusedIterator for Drain<'a, T> {} +impl FusedIterator for Drain<'_, T> {} #[stable(feature = "binary_heap_extras_15", since = "1.5.0")] impl From> for BinaryHeap { diff --git a/src/liballoc/collections/btree/map.rs b/src/liballoc/collections/btree/map.rs index d0e35c557a4d0..27f162b114736 100644 --- a/src/liballoc/collections/btree/map.rs +++ b/src/liballoc/collections/btree/map.rs @@ -279,7 +279,7 @@ pub struct Iter<'a, K: 'a, V: 'a> { } #[stable(feature = "collection_debug", since = "1.17.0")] -impl<'a, K: 'a + fmt::Debug, V: 'a + fmt::Debug> fmt::Debug for Iter<'a, K, V> { +impl fmt::Debug for Iter<'_, K, V> { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { f.debug_list().entries(self.clone()).finish() } @@ -337,7 +337,7 @@ pub struct Keys<'a, K: 'a, V: 'a> { } #[stable(feature = "collection_debug", since = "1.17.0")] -impl<'a, K: 'a + fmt::Debug, V: 'a> fmt::Debug for Keys<'a, K, V> { +impl fmt::Debug for Keys<'_, K, V> { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { f.debug_list().entries(self.clone()).finish() } @@ -356,7 +356,7 @@ pub struct Values<'a, K: 'a, V: 'a> { } #[stable(feature = "collection_debug", since = "1.17.0")] -impl<'a, K: 'a, V: 'a + fmt::Debug> fmt::Debug for Values<'a, K, V> { +impl fmt::Debug for Values<'_, K, V> { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { f.debug_list().entries(self.clone()).finish() } @@ -389,7 +389,7 @@ pub struct Range<'a, K: 'a, V: 'a> { } #[stable(feature = "collection_debug", since = "1.17.0")] -impl<'a, K: 'a + fmt::Debug, V: 'a + fmt::Debug> fmt::Debug for Range<'a, K, V> { +impl fmt::Debug for Range<'_, K, V> { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { f.debug_list().entries(self.clone()).finish() } @@ -412,7 +412,7 @@ pub struct RangeMut<'a, K: 'a, V: 'a> { } #[stable(feature = "collection_debug", since = "1.17.0")] -impl<'a, K: 'a + fmt::Debug, V: 'a + fmt::Debug> fmt::Debug for RangeMut<'a, K, V> { +impl fmt::Debug for RangeMut<'_, K, V> { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { let range = Range { front: self.front.reborrow(), @@ -442,7 +442,7 @@ pub enum Entry<'a, K: 'a, V: 'a> { } #[stable(feature= "debug_btree_map", since = "1.12.0")] -impl<'a, K: 'a + Debug + Ord, V: 'a + Debug> Debug for Entry<'a, K, V> { +impl Debug for Entry<'_, K, V> { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { match *self { Vacant(ref v) => f.debug_tuple("Entry") @@ -470,7 +470,7 @@ pub struct VacantEntry<'a, K: 'a, V: 'a> { } #[stable(feature= "debug_btree_map", since = "1.12.0")] -impl<'a, K: 'a + Debug + Ord, V: 'a> Debug for VacantEntry<'a, K, V> { +impl Debug for VacantEntry<'_, K, V> { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { f.debug_tuple("VacantEntry") .field(self.key()) @@ -493,7 +493,7 @@ pub struct OccupiedEntry<'a, K: 'a, V: 'a> { } #[stable(feature= "debug_btree_map", since = "1.12.0")] -impl<'a, K: 'a + Debug + Ord, V: 'a + Debug> Debug for OccupiedEntry<'a, K, V> { +impl Debug for OccupiedEntry<'_, K, V> { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { f.debug_struct("OccupiedEntry") .field("key", self.key()) @@ -1202,7 +1202,7 @@ impl<'a, K: 'a, V: 'a> Iterator for Iter<'a, K, V> { } #[stable(feature = "fused", since = "1.26.0")] -impl<'a, K, V> FusedIterator for Iter<'a, K, V> {} +impl FusedIterator for Iter<'_, K, V> {} #[stable(feature = "rust1", since = "1.0.0")] impl<'a, K: 'a, V: 'a> DoubleEndedIterator for Iter<'a, K, V> { @@ -1217,7 +1217,7 @@ impl<'a, K: 'a, V: 'a> DoubleEndedIterator for Iter<'a, K, V> { } #[stable(feature = "rust1", since = "1.0.0")] -impl<'a, K: 'a, V: 'a> ExactSizeIterator for Iter<'a, K, V> { +impl ExactSizeIterator for Iter<'_, K, V> { fn len(&self) -> usize { self.length } @@ -1274,14 +1274,14 @@ impl<'a, K: 'a, V: 'a> DoubleEndedIterator for IterMut<'a, K, V> { } #[stable(feature = "rust1", since = "1.0.0")] -impl<'a, K: 'a, V: 'a> ExactSizeIterator for IterMut<'a, K, V> { +impl ExactSizeIterator for IterMut<'_, K, V> { fn len(&self) -> usize { self.length } } #[stable(feature = "fused", since = "1.26.0")] -impl<'a, K, V> FusedIterator for IterMut<'a, K, V> {} +impl FusedIterator for IterMut<'_, K, V> {} #[stable(feature = "rust1", since = "1.0.0")] impl IntoIterator for BTreeMap { @@ -1437,14 +1437,14 @@ impl<'a, K, V> DoubleEndedIterator for Keys<'a, K, V> { } #[stable(feature = "rust1", since = "1.0.0")] -impl<'a, K, V> ExactSizeIterator for Keys<'a, K, V> { +impl ExactSizeIterator for Keys<'_, K, V> { fn len(&self) -> usize { self.inner.len() } } #[stable(feature = "fused", since = "1.26.0")] -impl<'a, K, V> FusedIterator for Keys<'a, K, V> {} +impl FusedIterator for Keys<'_, K, V> {} #[stable(feature = "rust1", since = "1.0.0")] impl<'a, K, V> Clone for Keys<'a, K, V> { @@ -1474,14 +1474,14 @@ impl<'a, K, V> DoubleEndedIterator for Values<'a, K, V> { } #[stable(feature = "rust1", since = "1.0.0")] -impl<'a, K, V> ExactSizeIterator for Values<'a, K, V> { +impl ExactSizeIterator for Values<'_, K, V> { fn len(&self) -> usize { self.inner.len() } } #[stable(feature = "fused", since = "1.26.0")] -impl<'a, K, V> FusedIterator for Values<'a, K, V> {} +impl FusedIterator for Values<'_, K, V> {} #[stable(feature = "rust1", since = "1.0.0")] impl<'a, K, V> Clone for Values<'a, K, V> { @@ -1524,15 +1524,14 @@ impl<'a, K, V> DoubleEndedIterator for ValuesMut<'a, K, V> { } #[stable(feature = "map_values_mut", since = "1.10.0")] -impl<'a, K, V> ExactSizeIterator for ValuesMut<'a, K, V> { +impl ExactSizeIterator for ValuesMut<'_, K, V> { fn len(&self) -> usize { self.inner.len() } } #[stable(feature = "fused", since = "1.26.0")] -impl<'a, K, V> FusedIterator for ValuesMut<'a, K, V> {} - +impl FusedIterator for ValuesMut<'_, K, V> {} impl<'a, K, V> Range<'a, K, V> { unsafe fn next_unchecked(&mut self) -> (&'a K, &'a V) { @@ -1610,7 +1609,7 @@ impl<'a, K, V> Range<'a, K, V> { } #[stable(feature = "fused", since = "1.26.0")] -impl<'a, K, V> FusedIterator for Range<'a, K, V> {} +impl FusedIterator for Range<'_, K, V> {} #[stable(feature = "btree_range", since = "1.17.0")] impl<'a, K, V> Clone for Range<'a, K, V> { @@ -1679,7 +1678,7 @@ impl<'a, K, V> DoubleEndedIterator for RangeMut<'a, K, V> { } #[stable(feature = "fused", since = "1.26.0")] -impl<'a, K, V> FusedIterator for RangeMut<'a, K, V> {} +impl FusedIterator for RangeMut<'_, K, V> {} impl<'a, K, V> RangeMut<'a, K, V> { unsafe fn next_back_unchecked(&mut self) -> (&'a K, &'a mut V) { @@ -1790,7 +1789,7 @@ impl Debug for BTreeMap { } #[stable(feature = "rust1", since = "1.0.0")] -impl<'a, K: Ord, Q: ?Sized, V> Index<&'a Q> for BTreeMap +impl Index<&Q> for BTreeMap where K: Borrow, Q: Ord { diff --git a/src/liballoc/collections/btree/set.rs b/src/liballoc/collections/btree/set.rs index 9231d2e67cf81..9c50bd7e91866 100644 --- a/src/liballoc/collections/btree/set.rs +++ b/src/liballoc/collections/btree/set.rs @@ -79,7 +79,7 @@ pub struct Iter<'a, T: 'a> { } #[stable(feature = "collection_debug", since = "1.17.0")] -impl<'a, T: 'a + fmt::Debug> fmt::Debug for Iter<'a, T> { +impl fmt::Debug for Iter<'_, T> { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { f.debug_tuple("Iter") .field(&self.iter.clone()) @@ -127,7 +127,7 @@ pub struct Difference<'a, T: 'a> { } #[stable(feature = "collection_debug", since = "1.17.0")] -impl<'a, T: 'a + fmt::Debug> fmt::Debug for Difference<'a, T> { +impl fmt::Debug for Difference<'_, T> { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { f.debug_tuple("Difference") .field(&self.a) @@ -150,7 +150,7 @@ pub struct SymmetricDifference<'a, T: 'a> { } #[stable(feature = "collection_debug", since = "1.17.0")] -impl<'a, T: 'a + fmt::Debug> fmt::Debug for SymmetricDifference<'a, T> { +impl fmt::Debug for SymmetricDifference<'_, T> { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { f.debug_tuple("SymmetricDifference") .field(&self.a) @@ -173,7 +173,7 @@ pub struct Intersection<'a, T: 'a> { } #[stable(feature = "collection_debug", since = "1.17.0")] -impl<'a, T: 'a + fmt::Debug> fmt::Debug for Intersection<'a, T> { +impl fmt::Debug for Intersection<'_, T> { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { f.debug_tuple("Intersection") .field(&self.a) @@ -196,7 +196,7 @@ pub struct Union<'a, T: 'a> { } #[stable(feature = "collection_debug", since = "1.17.0")] -impl<'a, T: 'a + fmt::Debug> fmt::Debug for Union<'a, T> { +impl fmt::Debug for Union<'_, T> { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { f.debug_tuple("Union") .field(&self.a) @@ -812,7 +812,7 @@ impl Default for BTreeSet { } #[stable(feature = "rust1", since = "1.0.0")] -impl<'a, 'b, T: Ord + Clone> Sub<&'b BTreeSet> for &'a BTreeSet { +impl Sub<&BTreeSet> for &BTreeSet { type Output = BTreeSet; /// Returns the difference of `self` and `rhs` as a new `BTreeSet`. @@ -835,7 +835,7 @@ impl<'a, 'b, T: Ord + Clone> Sub<&'b BTreeSet> for &'a BTreeSet { } #[stable(feature = "rust1", since = "1.0.0")] -impl<'a, 'b, T: Ord + Clone> BitXor<&'b BTreeSet> for &'a BTreeSet { +impl BitXor<&BTreeSet> for &BTreeSet { type Output = BTreeSet; /// Returns the symmetric difference of `self` and `rhs` as a new `BTreeSet`. @@ -858,7 +858,7 @@ impl<'a, 'b, T: Ord + Clone> BitXor<&'b BTreeSet> for &'a BTreeSet { } #[stable(feature = "rust1", since = "1.0.0")] -impl<'a, 'b, T: Ord + Clone> BitAnd<&'b BTreeSet> for &'a BTreeSet { +impl BitAnd<&BTreeSet> for &BTreeSet { type Output = BTreeSet; /// Returns the intersection of `self` and `rhs` as a new `BTreeSet`. @@ -881,7 +881,7 @@ impl<'a, 'b, T: Ord + Clone> BitAnd<&'b BTreeSet> for &'a BTreeSet { } #[stable(feature = "rust1", since = "1.0.0")] -impl<'a, 'b, T: Ord + Clone> BitOr<&'b BTreeSet> for &'a BTreeSet { +impl BitOr<&BTreeSet> for &BTreeSet { type Output = BTreeSet; /// Returns the union of `self` and `rhs` as a new `BTreeSet`. @@ -934,12 +934,12 @@ impl<'a, T> DoubleEndedIterator for Iter<'a, T> { } } #[stable(feature = "rust1", since = "1.0.0")] -impl<'a, T> ExactSizeIterator for Iter<'a, T> { +impl ExactSizeIterator for Iter<'_, T> { fn len(&self) -> usize { self.iter.len() } } #[stable(feature = "fused", since = "1.26.0")] -impl<'a, T> FusedIterator for Iter<'a, T> {} +impl FusedIterator for Iter<'_, T> {} #[stable(feature = "rust1", since = "1.0.0")] impl Iterator for IntoIter { @@ -990,7 +990,7 @@ impl<'a, T> DoubleEndedIterator for Range<'a, T> { } #[stable(feature = "fused", since = "1.26.0")] -impl<'a, T> FusedIterator for Range<'a, T> {} +impl FusedIterator for Range<'_, T> {} /// Compare `x` and `y`, but return `short` if x is None and `long` if y is None fn cmp_opt(x: Option<&T>, y: Option<&T>, short: Ordering, long: Ordering) -> Ordering { @@ -1037,7 +1037,7 @@ impl<'a, T: Ord> Iterator for Difference<'a, T> { } #[stable(feature = "fused", since = "1.26.0")] -impl<'a, T: Ord> FusedIterator for Difference<'a, T> {} +impl FusedIterator for Difference<'_, T> {} #[stable(feature = "rust1", since = "1.0.0")] impl<'a, T> Clone for SymmetricDifference<'a, T> { @@ -1071,7 +1071,7 @@ impl<'a, T: Ord> Iterator for SymmetricDifference<'a, T> { } #[stable(feature = "fused", since = "1.26.0")] -impl<'a, T: Ord> FusedIterator for SymmetricDifference<'a, T> {} +impl FusedIterator for SymmetricDifference<'_, T> {} #[stable(feature = "rust1", since = "1.0.0")] impl<'a, T> Clone for Intersection<'a, T> { @@ -1109,7 +1109,7 @@ impl<'a, T: Ord> Iterator for Intersection<'a, T> { } #[stable(feature = "fused", since = "1.26.0")] -impl<'a, T: Ord> FusedIterator for Intersection<'a, T> {} +impl FusedIterator for Intersection<'_, T> {} #[stable(feature = "rust1", since = "1.0.0")] impl<'a, T> Clone for Union<'a, T> { @@ -1143,4 +1143,4 @@ impl<'a, T: Ord> Iterator for Union<'a, T> { } #[stable(feature = "fused", since = "1.26.0")] -impl<'a, T: Ord> FusedIterator for Union<'a, T> {} +impl FusedIterator for Union<'_, T> {} diff --git a/src/liballoc/collections/linked_list.rs b/src/liballoc/collections/linked_list.rs index 8f72c6babaf35..e2da0041b4a8d 100644 --- a/src/liballoc/collections/linked_list.rs +++ b/src/liballoc/collections/linked_list.rs @@ -63,7 +63,7 @@ pub struct Iter<'a, T: 'a> { } #[stable(feature = "collection_debug", since = "1.17.0")] -impl<'a, T: 'a + fmt::Debug> fmt::Debug for Iter<'a, T> { +impl fmt::Debug for Iter<'_, T> { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { f.debug_tuple("Iter") .field(&self.len) @@ -73,7 +73,7 @@ impl<'a, T: 'a + fmt::Debug> fmt::Debug for Iter<'a, T> { // FIXME(#26925) Remove in favor of `#[derive(Clone)]` #[stable(feature = "rust1", since = "1.0.0")] -impl<'a, T> Clone for Iter<'a, T> { +impl Clone for Iter<'_, T> { fn clone(&self) -> Self { Iter { ..*self } } @@ -95,7 +95,7 @@ pub struct IterMut<'a, T: 'a> { } #[stable(feature = "collection_debug", since = "1.17.0")] -impl<'a, T: 'a + fmt::Debug> fmt::Debug for IterMut<'a, T> { +impl fmt::Debug for IterMut<'_, T> { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { f.debug_tuple("IterMut") .field(&self.list) @@ -834,10 +834,10 @@ impl<'a, T> DoubleEndedIterator for Iter<'a, T> { } #[stable(feature = "rust1", since = "1.0.0")] -impl<'a, T> ExactSizeIterator for Iter<'a, T> {} +impl ExactSizeIterator for Iter<'_, T> {} #[stable(feature = "fused", since = "1.26.0")] -impl<'a, T> FusedIterator for Iter<'a, T> {} +impl FusedIterator for Iter<'_, T> {} #[stable(feature = "rust1", since = "1.0.0")] impl<'a, T> Iterator for IterMut<'a, T> { @@ -883,12 +883,12 @@ impl<'a, T> DoubleEndedIterator for IterMut<'a, T> { } #[stable(feature = "rust1", since = "1.0.0")] -impl<'a, T> ExactSizeIterator for IterMut<'a, T> {} +impl ExactSizeIterator for IterMut<'_, T> {} #[stable(feature = "fused", since = "1.26.0")] -impl<'a, T> FusedIterator for IterMut<'a, T> {} +impl FusedIterator for IterMut<'_, T> {} -impl<'a, T> IterMut<'a, T> { +impl IterMut<'_, T> { /// Inserts the given element just after the element most recently returned by `.next()`. /// The inserted element does not appear in the iteration. /// @@ -984,7 +984,7 @@ pub struct DrainFilter<'a, T: 'a, F: 'a> } #[unstable(feature = "drain_filter", reason = "recently added", issue = "43244")] -impl<'a, T, F> Iterator for DrainFilter<'a, T, F> +impl Iterator for DrainFilter<'_, T, F> where F: FnMut(&mut T) -> bool, { type Item = T; @@ -1011,7 +1011,7 @@ impl<'a, T, F> Iterator for DrainFilter<'a, T, F> } #[unstable(feature = "drain_filter", reason = "recently added", issue = "43244")] -impl<'a, T, F> Drop for DrainFilter<'a, T, F> +impl Drop for DrainFilter<'_, T, F> where F: FnMut(&mut T) -> bool, { fn drop(&mut self) { @@ -1020,7 +1020,7 @@ impl<'a, T, F> Drop for DrainFilter<'a, T, F> } #[unstable(feature = "drain_filter", reason = "recently added", issue = "43244")] -impl<'a, T: 'a + fmt::Debug, F> fmt::Debug for DrainFilter<'a, T, F> +impl fmt::Debug for DrainFilter<'_, T, F> where F: FnMut(&mut T) -> bool { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { diff --git a/src/liballoc/collections/vec_deque.rs b/src/liballoc/collections/vec_deque.rs index de78783983d7c..abfb83d4139e1 100644 --- a/src/liballoc/collections/vec_deque.rs +++ b/src/liballoc/collections/vec_deque.rs @@ -2086,7 +2086,7 @@ trait RingSlices: Sized { } } -impl<'a, T> RingSlices for &'a [T] { +impl RingSlices for &[T] { fn slice(self, from: usize, to: usize) -> Self { &self[from..to] } @@ -2095,7 +2095,7 @@ impl<'a, T> RingSlices for &'a [T] { } } -impl<'a, T> RingSlices for &'a mut [T] { +impl RingSlices for &mut [T] { fn slice(self, from: usize, to: usize) -> Self { &mut self[from..to] } @@ -2126,7 +2126,7 @@ pub struct Iter<'a, T: 'a> { } #[stable(feature = "collection_debug", since = "1.17.0")] -impl<'a, T: 'a + fmt::Debug> fmt::Debug for Iter<'a, T> { +impl fmt::Debug for Iter<'_, T> { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { let (front, back) = RingSlices::ring_slices(self.ring, self.head, self.tail); f.debug_tuple("Iter") @@ -2206,14 +2206,14 @@ impl<'a, T> DoubleEndedIterator for Iter<'a, T> { } #[stable(feature = "rust1", since = "1.0.0")] -impl<'a, T> ExactSizeIterator for Iter<'a, T> { +impl ExactSizeIterator for Iter<'_, T> { fn is_empty(&self) -> bool { self.head == self.tail } } #[stable(feature = "fused", since = "1.26.0")] -impl<'a, T> FusedIterator for Iter<'a, T> {} +impl FusedIterator for Iter<'_, T> {} /// A mutable iterator over the elements of a `VecDeque`. @@ -2231,7 +2231,7 @@ pub struct IterMut<'a, T: 'a> { } #[stable(feature = "collection_debug", since = "1.17.0")] -impl<'a, T: 'a + fmt::Debug> fmt::Debug for IterMut<'a, T> { +impl<'a, T: fmt::Debug> fmt::Debug for IterMut<'_, T> { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { let (front, back) = RingSlices::ring_slices(&*self.ring, self.head, self.tail); f.debug_tuple("IterMut") @@ -2299,14 +2299,14 @@ impl<'a, T> DoubleEndedIterator for IterMut<'a, T> { } #[stable(feature = "rust1", since = "1.0.0")] -impl<'a, T> ExactSizeIterator for IterMut<'a, T> { +impl ExactSizeIterator for IterMut<'_, T> { fn is_empty(&self) -> bool { self.head == self.tail } } #[stable(feature = "fused", since = "1.26.0")] -impl<'a, T> FusedIterator for IterMut<'a, T> {} +impl FusedIterator for IterMut<'_, T> {} /// An owning iterator over the elements of a `VecDeque`. /// @@ -2380,7 +2380,7 @@ pub struct Drain<'a, T: 'a> { } #[stable(feature = "collection_debug", since = "1.17.0")] -impl<'a, T: 'a + fmt::Debug> fmt::Debug for Drain<'a, T> { +impl fmt::Debug for Drain<'_, T> { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { f.debug_tuple("Drain") .field(&self.after_tail) @@ -2391,12 +2391,12 @@ impl<'a, T: 'a + fmt::Debug> fmt::Debug for Drain<'a, T> { } #[stable(feature = "drain", since = "1.6.0")] -unsafe impl<'a, T: Sync> Sync for Drain<'a, T> {} +unsafe impl Sync for Drain<'_, T> {} #[stable(feature = "drain", since = "1.6.0")] -unsafe impl<'a, T: Send> Send for Drain<'a, T> {} +unsafe impl Send for Drain<'_, T> {} #[stable(feature = "drain", since = "1.6.0")] -impl<'a, T: 'a> Drop for Drain<'a, T> { +impl Drop for Drain<'_, T> { fn drop(&mut self) { self.for_each(drop); @@ -2443,7 +2443,7 @@ impl<'a, T: 'a> Drop for Drain<'a, T> { } #[stable(feature = "drain", since = "1.6.0")] -impl<'a, T: 'a> Iterator for Drain<'a, T> { +impl Iterator for Drain<'_, T> { type Item = T; #[inline] @@ -2458,7 +2458,7 @@ impl<'a, T: 'a> Iterator for Drain<'a, T> { } #[stable(feature = "drain", since = "1.6.0")] -impl<'a, T: 'a> DoubleEndedIterator for Drain<'a, T> { +impl DoubleEndedIterator for Drain<'_, T> { #[inline] fn next_back(&mut self) -> Option { self.iter.next_back().map(|elt| unsafe { ptr::read(elt) }) @@ -2466,10 +2466,10 @@ impl<'a, T: 'a> DoubleEndedIterator for Drain<'a, T> { } #[stable(feature = "drain", since = "1.6.0")] -impl<'a, T: 'a> ExactSizeIterator for Drain<'a, T> {} +impl ExactSizeIterator for Drain<'_, T> {} #[stable(feature = "fused", since = "1.26.0")] -impl<'a, T: 'a> FusedIterator for Drain<'a, T> {} +impl FusedIterator for Drain<'_, T> {} #[stable(feature = "rust1", since = "1.0.0")] impl PartialEq for VecDeque { @@ -2519,7 +2519,7 @@ macro_rules! __impl_slice_eq1 { }; ($Lhs: ty, $Rhs: ty, $Bound: ident) => { #[stable(feature = "vec_deque_partial_eq_slice", since = "1.17.0")] - impl<'a, 'b, A: $Bound, B> PartialEq<$Rhs> for $Lhs where A: PartialEq { + impl PartialEq<$Rhs> for $Lhs where A: PartialEq { fn eq(&self, other: &$Rhs) -> bool { if self.len() != other.len() { return false; @@ -2533,15 +2533,15 @@ macro_rules! __impl_slice_eq1 { } __impl_slice_eq1! { VecDeque, Vec } -__impl_slice_eq1! { VecDeque, &'b [B] } -__impl_slice_eq1! { VecDeque, &'b mut [B] } +__impl_slice_eq1! { VecDeque, &[B] } +__impl_slice_eq1! { VecDeque, &mut [B] } macro_rules! array_impls { ($($N: expr)+) => { $( __impl_slice_eq1! { VecDeque, [B; $N] } - __impl_slice_eq1! { VecDeque, &'b [B; $N] } - __impl_slice_eq1! { VecDeque, &'b mut [B; $N] } + __impl_slice_eq1! { VecDeque, &[B; $N] } + __impl_slice_eq1! { VecDeque, &mut [B; $N] } )+ } } diff --git a/src/liballoc/string.rs b/src/liballoc/string.rs index d74a3f004a305..92d3e52d60c73 100644 --- a/src/liballoc/string.rs +++ b/src/liballoc/string.rs @@ -1935,7 +1935,7 @@ impl hash::Hash for String { /// let c = a.to_string() + b; /// ``` #[stable(feature = "rust1", since = "1.0.0")] -impl<'a> Add<&'a str> for String { +impl Add<&str> for String { type Output = String; #[inline] @@ -1949,7 +1949,7 @@ impl<'a> Add<&'a str> for String { /// /// This has the same behavior as the [`push_str`][String::push_str] method. #[stable(feature = "stringaddassign", since = "1.12.0")] -impl<'a> AddAssign<&'a str> for String { +impl AddAssign<&str> for String { #[inline] fn add_assign(&mut self, other: &str) { self.push_str(other); @@ -2183,7 +2183,7 @@ impl ToString for str { } #[stable(feature = "cow_str_to_string_specialization", since = "1.17.0")] -impl<'a> ToString for Cow<'a, str> { +impl ToString for Cow<'_, str> { #[inline] fn to_string(&self) -> String { self[..].to_owned() @@ -2373,19 +2373,19 @@ pub struct Drain<'a> { } #[stable(feature = "collection_debug", since = "1.17.0")] -impl<'a> fmt::Debug for Drain<'a> { +impl fmt::Debug for Drain<'_> { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { f.pad("Drain { .. }") } } #[stable(feature = "drain", since = "1.6.0")] -unsafe impl<'a> Sync for Drain<'a> {} +unsafe impl Sync for Drain<'_> {} #[stable(feature = "drain", since = "1.6.0")] -unsafe impl<'a> Send for Drain<'a> {} +unsafe impl Send for Drain<'_> {} #[stable(feature = "drain", since = "1.6.0")] -impl<'a> Drop for Drain<'a> { +impl Drop for Drain<'_> { fn drop(&mut self) { unsafe { // Use Vec::drain. "Reaffirm" the bounds checks to avoid @@ -2399,7 +2399,7 @@ impl<'a> Drop for Drain<'a> { } #[stable(feature = "drain", since = "1.6.0")] -impl<'a> Iterator for Drain<'a> { +impl Iterator for Drain<'_> { type Item = char; #[inline] @@ -2413,7 +2413,7 @@ impl<'a> Iterator for Drain<'a> { } #[stable(feature = "drain", since = "1.6.0")] -impl<'a> DoubleEndedIterator for Drain<'a> { +impl DoubleEndedIterator for Drain<'_> { #[inline] fn next_back(&mut self) -> Option { self.iter.next_back() @@ -2421,4 +2421,4 @@ impl<'a> DoubleEndedIterator for Drain<'a> { } #[stable(feature = "fused", since = "1.26.0")] -impl<'a> FusedIterator for Drain<'a> {} +impl FusedIterator for Drain<'_> {} diff --git a/src/liballoc/sync.rs b/src/liballoc/sync.rs index 5e7a26132cb13..2512e27e316b7 100644 --- a/src/liballoc/sync.rs +++ b/src/liballoc/sync.rs @@ -1605,7 +1605,7 @@ impl From for Arc { } #[stable(feature = "shared_from_slice", since = "1.21.0")] -impl<'a, T: Clone> From<&'a [T]> for Arc<[T]> { +impl From<&[T]> for Arc<[T]> { #[inline] fn from(v: &[T]) -> Arc<[T]> { >::from_slice(v) @@ -1613,7 +1613,7 @@ impl<'a, T: Clone> From<&'a [T]> for Arc<[T]> { } #[stable(feature = "shared_from_slice", since = "1.21.0")] -impl<'a> From<&'a str> for Arc { +impl From<&str> for Arc { #[inline] fn from(v: &str) -> Arc { let arc = Arc::<[u8]>::from(v.as_bytes()); diff --git a/src/liballoc/tests/vec.rs b/src/liballoc/tests/vec.rs index b65c68d51a502..e8fea287e1cb4 100644 --- a/src/liballoc/tests/vec.rs +++ b/src/liballoc/tests/vec.rs @@ -10,7 +10,7 @@ struct DropCounter<'a> { count: &'a mut u32, } -impl<'a> Drop for DropCounter<'a> { +impl Drop for DropCounter<'_> { fn drop(&mut self) { *self.count += 1; } diff --git a/src/liballoc/tests/vec_deque.rs b/src/liballoc/tests/vec_deque.rs index 44183956d8fc7..313aa55a2b28e 100644 --- a/src/liballoc/tests/vec_deque.rs +++ b/src/liballoc/tests/vec_deque.rs @@ -1003,7 +1003,7 @@ struct DropCounter<'a> { count: &'a mut u32, } -impl<'a> Drop for DropCounter<'a> { +impl Drop for DropCounter<'_> { fn drop(&mut self) { *self.count += 1; } diff --git a/src/liballoc/vec.rs b/src/liballoc/vec.rs index 8e09720688156..b43ba6cb57cad 100644 --- a/src/liballoc/vec.rs +++ b/src/liballoc/vec.rs @@ -1481,7 +1481,7 @@ impl<'a> SetLenOnDrop<'a> { } } -impl<'a> Drop for SetLenOnDrop<'a> { +impl Drop for SetLenOnDrop<'_> { #[inline] fn drop(&mut self) { *self.len = self.local_len; @@ -2471,12 +2471,12 @@ impl<'a, T: 'a + fmt::Debug> fmt::Debug for Drain<'a, T> { } #[stable(feature = "drain", since = "1.6.0")] -unsafe impl<'a, T: Sync> Sync for Drain<'a, T> {} +unsafe impl Sync for Drain<'_, T> {} #[stable(feature = "drain", since = "1.6.0")] -unsafe impl<'a, T: Send> Send for Drain<'a, T> {} +unsafe impl Send for Drain<'_, T> {} #[stable(feature = "drain", since = "1.6.0")] -impl<'a, T> Iterator for Drain<'a, T> { +impl Iterator for Drain<'_, T> { type Item = T; #[inline] @@ -2490,7 +2490,7 @@ impl<'a, T> Iterator for Drain<'a, T> { } #[stable(feature = "drain", since = "1.6.0")] -impl<'a, T> DoubleEndedIterator for Drain<'a, T> { +impl DoubleEndedIterator for Drain<'_, T> { #[inline] fn next_back(&mut self) -> Option { self.iter.next_back().map(|elt| unsafe { ptr::read(elt as *const _) }) @@ -2498,7 +2498,7 @@ impl<'a, T> DoubleEndedIterator for Drain<'a, T> { } #[stable(feature = "drain", since = "1.6.0")] -impl<'a, T> Drop for Drain<'a, T> { +impl Drop for Drain<'_, T> { fn drop(&mut self) { // exhaust self first self.for_each(drop); @@ -2522,14 +2522,14 @@ impl<'a, T> Drop for Drain<'a, T> { #[stable(feature = "drain", since = "1.6.0")] -impl<'a, T> ExactSizeIterator for Drain<'a, T> { +impl ExactSizeIterator for Drain<'_, T> { fn is_empty(&self) -> bool { self.iter.is_empty() } } #[stable(feature = "fused", since = "1.26.0")] -impl<'a, T> FusedIterator for Drain<'a, T> {} +impl FusedIterator for Drain<'_, T> {} /// A splicing iterator for `Vec`. /// @@ -2546,7 +2546,7 @@ pub struct Splice<'a, I: Iterator + 'a> { } #[stable(feature = "vec_splice", since = "1.21.0")] -impl<'a, I: Iterator> Iterator for Splice<'a, I> { +impl Iterator for Splice<'_, I> { type Item = I::Item; fn next(&mut self) -> Option { @@ -2559,18 +2559,18 @@ impl<'a, I: Iterator> Iterator for Splice<'a, I> { } #[stable(feature = "vec_splice", since = "1.21.0")] -impl<'a, I: Iterator> DoubleEndedIterator for Splice<'a, I> { +impl DoubleEndedIterator for Splice<'_, I> { fn next_back(&mut self) -> Option { self.drain.next_back() } } #[stable(feature = "vec_splice", since = "1.21.0")] -impl<'a, I: Iterator> ExactSizeIterator for Splice<'a, I> {} +impl ExactSizeIterator for Splice<'_, I> {} #[stable(feature = "vec_splice", since = "1.21.0")] -impl<'a, I: Iterator> Drop for Splice<'a, I> { +impl Drop for Splice<'_, I> { fn drop(&mut self) { self.drain.by_ref().for_each(drop); @@ -2611,7 +2611,7 @@ impl<'a, I: Iterator> Drop for Splice<'a, I> { } /// Private helper methods for `Splice::drop` -impl<'a, T> Drain<'a, T> { +impl Drain<'_, T> { /// The range from `self.vec.len` to `self.tail_start` contains elements /// that have been moved out. /// Fill that range as much as possible with new elements from the `replace_with` iterator. @@ -2663,7 +2663,7 @@ pub struct DrainFilter<'a, T: 'a, F> } #[unstable(feature = "drain_filter", reason = "recently added", issue = "43244")] -impl<'a, T, F> Iterator for DrainFilter<'a, T, F> +impl Iterator for DrainFilter<'_, T, F> where F: FnMut(&mut T) -> bool, { type Item = T; @@ -2697,7 +2697,7 @@ impl<'a, T, F> Iterator for DrainFilter<'a, T, F> } #[unstable(feature = "drain_filter", reason = "recently added", issue = "43244")] -impl<'a, T, F> Drop for DrainFilter<'a, T, F> +impl Drop for DrainFilter<'_, T, F> where F: FnMut(&mut T) -> bool, { fn drop(&mut self) { From 95a95189570001e37712661f46a496cdedce62b3 Mon Sep 17 00:00:00 2001 From: Mazdak Farrokhzad Date: Sat, 2 Feb 2019 12:27:41 +0100 Subject: [PATCH 08/12] liballoc: elide &'static. --- src/liballoc/tests/str.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/liballoc/tests/str.rs b/src/liballoc/tests/str.rs index 28e021c741e7d..b1586558713e7 100644 --- a/src/liballoc/tests/str.rs +++ b/src/liballoc/tests/str.rs @@ -586,7 +586,7 @@ mod slice_index { } mod boundary { - const DATA: &'static str = "abcαβγ"; + const DATA: &str = "abcαβγ"; const BAD_START: usize = 4; const GOOD_START: usize = 3; @@ -650,7 +650,7 @@ mod slice_index { } } - const LOREM_PARAGRAPH: &'static str = "\ + const LOREM_PARAGRAPH: &str = "\ Lorem ipsum dolor sit amet, consectetur adipiscing elit. Suspendisse quis lorem \ sit amet dolor ultricies condimentum. Praesent iaculis purus elit, ac malesuada \ quam malesuada in. Duis sed orci eros. Suspendisse sit amet magna mollis, mollis \ From 857530cef1f1419e296e5d9ad623b153c06cb3e6 Mon Sep 17 00:00:00 2001 From: Mazdak Farrokhzad Date: Sat, 2 Feb 2019 12:48:12 +0100 Subject: [PATCH 09/12] liballoc: fix some idiom lints. --- src/liballoc/borrow.rs | 4 +-- src/liballoc/boxed.rs | 6 ++--- src/liballoc/collections/binary_heap.rs | 14 +++++----- src/liballoc/collections/btree/map.rs | 34 ++++++++++++------------- src/liballoc/collections/btree/node.rs | 20 +++++++-------- src/liballoc/collections/btree/set.rs | 16 ++++++------ src/liballoc/collections/linked_list.rs | 16 ++++++------ src/liballoc/collections/vec_deque.rs | 16 ++++++------ src/liballoc/fmt.rs | 2 +- src/liballoc/lib.rs | 3 +++ src/liballoc/rc.rs | 8 +++--- src/liballoc/string.rs | 16 ++++++------ src/liballoc/sync.rs | 8 +++--- src/liballoc/vec.rs | 14 +++++----- 14 files changed, 90 insertions(+), 87 deletions(-) diff --git a/src/liballoc/borrow.rs b/src/liballoc/borrow.rs index 816cdbc9ce673..1fda36778f486 100644 --- a/src/liballoc/borrow.rs +++ b/src/liballoc/borrow.rs @@ -332,7 +332,7 @@ impl fmt::Debug for Cow<'_, B> where B: fmt::Debug + ToOwned, ::Owned: fmt::Debug { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { match *self { Borrowed(ref b) => fmt::Debug::fmt(b, f), Owned(ref o) => fmt::Debug::fmt(o, f), @@ -345,7 +345,7 @@ impl fmt::Display for Cow<'_, B> where B: fmt::Display + ToOwned, ::Owned: fmt::Display { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { match *self { Borrowed(ref b) => fmt::Display::fmt(b, f), Owned(ref o) => fmt::Display::fmt(o, f), diff --git a/src/liballoc/boxed.rs b/src/liballoc/boxed.rs index 6f6fff0a657d0..40b091b92c1a5 100644 --- a/src/liballoc/boxed.rs +++ b/src/liballoc/boxed.rs @@ -605,21 +605,21 @@ impl Box { #[stable(feature = "rust1", since = "1.0.0")] impl fmt::Display for Box { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { fmt::Display::fmt(&**self, f) } } #[stable(feature = "rust1", since = "1.0.0")] impl fmt::Debug for Box { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { fmt::Debug::fmt(&**self, f) } } #[stable(feature = "rust1", since = "1.0.0")] impl fmt::Pointer for Box { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { // It's not possible to extract the inner Uniq directly from the Box, // instead we cast it to a *const which aliases the Unique let ptr: *const T = &**self; diff --git a/src/liballoc/collections/binary_heap.rs b/src/liballoc/collections/binary_heap.rs index 43416e57591bc..5f0386400d707 100644 --- a/src/liballoc/collections/binary_heap.rs +++ b/src/liballoc/collections/binary_heap.rs @@ -232,7 +232,7 @@ pub struct PeekMut<'a, T: 'a + Ord> { #[stable(feature = "collection_debug", since = "1.17.0")] impl fmt::Debug for PeekMut<'_, T> { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { f.debug_tuple("PeekMut") .field(&self.heap.data[0]) .finish() @@ -295,7 +295,7 @@ impl Default for BinaryHeap { #[stable(feature = "binaryheap_debug", since = "1.4.0")] impl fmt::Debug for BinaryHeap { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { f.debug_list().entries(self.iter()).finish() } } @@ -353,7 +353,7 @@ impl BinaryHeap { /// } /// ``` #[stable(feature = "rust1", since = "1.0.0")] - pub fn iter(&self) -> Iter { + pub fn iter(&self) -> Iter<'_, T> { Iter { iter: self.data.iter() } } @@ -404,7 +404,7 @@ impl BinaryHeap { /// assert_eq!(heap.peek(), Some(&2)); /// ``` #[stable(feature = "binary_heap_peek_mut", since = "1.12.0")] - pub fn peek_mut(&mut self) -> Option> { + pub fn peek_mut(&mut self) -> Option> { if self.is_empty() { None } else { @@ -765,7 +765,7 @@ impl BinaryHeap { /// ``` #[inline] #[stable(feature = "drain", since = "1.6.0")] - pub fn drain(&mut self) -> Drain { + pub fn drain(&mut self) -> Drain<'_, T> { Drain { iter: self.data.drain(..) } } @@ -937,7 +937,7 @@ pub struct Iter<'a, T: 'a> { #[stable(feature = "collection_debug", since = "1.17.0")] impl fmt::Debug for Iter<'_, T> { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { f.debug_tuple("Iter") .field(&self.iter.as_slice()) .finish() @@ -1000,7 +1000,7 @@ pub struct IntoIter { #[stable(feature = "collection_debug", since = "1.17.0")] impl fmt::Debug for IntoIter { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { f.debug_tuple("IntoIter") .field(&self.iter.as_slice()) .finish() diff --git a/src/liballoc/collections/btree/map.rs b/src/liballoc/collections/btree/map.rs index 27f162b114736..fe6b5fef210e1 100644 --- a/src/liballoc/collections/btree/map.rs +++ b/src/liballoc/collections/btree/map.rs @@ -249,7 +249,7 @@ impl super::Recover for BTreeMap fn replace(&mut self, key: K) -> Option { self.ensure_root_is_owned(); - match search::search_tree::(self.root.as_mut(), &key) { + match search::search_tree::, K, (), K>(self.root.as_mut(), &key) { Found(handle) => Some(mem::replace(handle.into_kv_mut().0, key)), GoDown(handle) => { VacantEntry { @@ -280,7 +280,7 @@ pub struct Iter<'a, K: 'a, V: 'a> { #[stable(feature = "collection_debug", since = "1.17.0")] impl fmt::Debug for Iter<'_, K, V> { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { f.debug_list().entries(self.clone()).finish() } } @@ -315,7 +315,7 @@ pub struct IntoIter { #[stable(feature = "collection_debug", since = "1.17.0")] impl fmt::Debug for IntoIter { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { let range = Range { front: self.front.reborrow(), back: self.back.reborrow(), @@ -338,7 +338,7 @@ pub struct Keys<'a, K: 'a, V: 'a> { #[stable(feature = "collection_debug", since = "1.17.0")] impl fmt::Debug for Keys<'_, K, V> { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { f.debug_list().entries(self.clone()).finish() } } @@ -357,7 +357,7 @@ pub struct Values<'a, K: 'a, V: 'a> { #[stable(feature = "collection_debug", since = "1.17.0")] impl fmt::Debug for Values<'_, K, V> { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { f.debug_list().entries(self.clone()).finish() } } @@ -390,7 +390,7 @@ pub struct Range<'a, K: 'a, V: 'a> { #[stable(feature = "collection_debug", since = "1.17.0")] impl fmt::Debug for Range<'_, K, V> { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { f.debug_list().entries(self.clone()).finish() } } @@ -413,7 +413,7 @@ pub struct RangeMut<'a, K: 'a, V: 'a> { #[stable(feature = "collection_debug", since = "1.17.0")] impl fmt::Debug for RangeMut<'_, K, V> { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { let range = Range { front: self.front.reborrow(), back: self.back.reborrow(), @@ -443,7 +443,7 @@ pub enum Entry<'a, K: 'a, V: 'a> { #[stable(feature= "debug_btree_map", since = "1.12.0")] impl Debug for Entry<'_, K, V> { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { match *self { Vacant(ref v) => f.debug_tuple("Entry") .field(v) @@ -471,7 +471,7 @@ pub struct VacantEntry<'a, K: 'a, V: 'a> { #[stable(feature= "debug_btree_map", since = "1.12.0")] impl Debug for VacantEntry<'_, K, V> { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { f.debug_tuple("VacantEntry") .field(self.key()) .finish() @@ -494,7 +494,7 @@ pub struct OccupiedEntry<'a, K: 'a, V: 'a> { #[stable(feature= "debug_btree_map", since = "1.12.0")] impl Debug for OccupiedEntry<'_, K, V> { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { f.debug_struct("OccupiedEntry") .field("key", self.key()) .field("value", self.get()) @@ -818,7 +818,7 @@ impl BTreeMap { /// assert_eq!(Some((&5, &"b")), map.range(4..).next()); /// ``` #[stable(feature = "btree_range", since = "1.17.0")] - pub fn range(&self, range: R) -> Range + pub fn range(&self, range: R) -> Range<'_, K, V> where T: Ord, K: Borrow, R: RangeBounds { let root1 = self.root.as_ref(); @@ -859,7 +859,7 @@ impl BTreeMap { /// } /// ``` #[stable(feature = "btree_range", since = "1.17.0")] - pub fn range_mut(&mut self, range: R) -> RangeMut + pub fn range_mut(&mut self, range: R) -> RangeMut<'_, K, V> where T: Ord, K: Borrow, R: RangeBounds { let root1 = self.root.as_mut(); @@ -892,7 +892,7 @@ impl BTreeMap { /// assert_eq!(count["a"], 3); /// ``` #[stable(feature = "rust1", since = "1.0.0")] - pub fn entry(&mut self, key: K) -> Entry { + pub fn entry(&mut self, key: K) -> Entry<'_, K, V> { // FIXME(@porglezomp) Avoid allocating if we don't insert self.ensure_root_is_owned(); match search::search_tree(self.root.as_mut(), &key) { @@ -1783,7 +1783,7 @@ impl Ord for BTreeMap { #[stable(feature = "rust1", since = "1.0.0")] impl Debug for BTreeMap { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { f.debug_map().entries(self.iter()).finish() } } @@ -1940,7 +1940,7 @@ impl BTreeMap { /// assert_eq!((*first_key, *first_value), (1, "a")); /// ``` #[stable(feature = "rust1", since = "1.0.0")] - pub fn iter(&self) -> Iter { + pub fn iter(&self) -> Iter<'_, K, V> { Iter { range: Range { front: first_leaf_edge(self.root.as_ref()), @@ -1972,7 +1972,7 @@ impl BTreeMap { /// } /// ``` #[stable(feature = "rust1", since = "1.0.0")] - pub fn iter_mut(&mut self) -> IterMut { + pub fn iter_mut(&mut self) -> IterMut<'_, K, V> { let root1 = self.root.as_mut(); let root2 = unsafe { ptr::read(&root1) }; IterMut { @@ -2049,7 +2049,7 @@ impl BTreeMap { /// String::from("goodbye!")]); /// ``` #[stable(feature = "map_values_mut", since = "1.10.0")] - pub fn values_mut(&mut self) -> ValuesMut { + pub fn values_mut(&mut self) -> ValuesMut<'_, K, V> { ValuesMut { inner: self.iter_mut() } } diff --git a/src/liballoc/collections/btree/node.rs b/src/liballoc/collections/btree/node.rs index f33a75bc45e02..a5f90aa8974b6 100644 --- a/src/liballoc/collections/btree/node.rs +++ b/src/liballoc/collections/btree/node.rs @@ -230,7 +230,7 @@ impl Root { } pub fn as_ref(&self) - -> NodeRef { + -> NodeRef, K, V, marker::LeafOrInternal> { NodeRef { height: self.height, node: self.node.as_ptr(), @@ -240,7 +240,7 @@ impl Root { } pub fn as_mut(&mut self) - -> NodeRef { + -> NodeRef, K, V, marker::LeafOrInternal> { NodeRef { height: self.height, node: self.node.as_ptr(), @@ -262,7 +262,7 @@ impl Root { /// Adds a new internal node with a single edge, pointing to the previous root, and make that /// new node the root. This increases the height by 1 and is the opposite of `pop_level`. pub fn push_level(&mut self) - -> NodeRef { + -> NodeRef, K, V, marker::Internal> { debug_assert!(!self.is_shared_root()); let mut new_node = Box::new(unsafe { InternalNode::new() }); new_node.edges[0].set(unsafe { BoxedNode::from_ptr(self.node.as_ptr()) }); @@ -535,7 +535,7 @@ impl<'a, K, V, Type> NodeRef, K, V, Type> { /// Unsafely asserts to the compiler some static information about whether this /// node is a `Leaf`. unsafe fn cast_unchecked(&mut self) - -> NodeRef { + -> NodeRef, K, V, NewType> { NodeRef { height: self.height, @@ -555,7 +555,7 @@ impl<'a, K, V, Type> NodeRef, K, V, Type> { /// of a reborrowed handle, out of bounds. // FIXME(@gereeter) consider adding yet another type parameter to `NodeRef` that restricts // the use of `ascend` and `into_root_mut` on reborrowed pointers, preventing this unsafety. - unsafe fn reborrow_mut(&mut self) -> NodeRef { + unsafe fn reborrow_mut(&mut self) -> NodeRef, K, V, Type> { NodeRef { height: self.height, node: self.node, @@ -932,7 +932,7 @@ impl /// Temporarily takes out another, immutable handle on the same location. pub fn reborrow(&self) - -> Handle, HandleType> { + -> Handle, K, V, NodeType>, HandleType> { // We can't use Handle::new_kv or Handle::new_edge because we don't know our type Handle { @@ -957,7 +957,7 @@ impl<'a, K, V, NodeType, HandleType> // FIXME(@gereeter) consider adding yet another type parameter to `NodeRef` that restricts // the use of `ascend` and `into_root_mut` on reborrowed pointers, preventing this unsafety. pub unsafe fn reborrow_mut(&mut self) - -> Handle, HandleType> { + -> Handle, K, V, NodeType>, HandleType> { // We can't use Handle::new_kv or Handle::new_edge because we don't know our type Handle { @@ -1072,7 +1072,7 @@ impl<'a, K, V> Handle, K, V, marker::Internal>, marker:: /// Unsafely asserts to the compiler some static information about whether the underlying /// node of this handle is a `Leaf`. unsafe fn cast_unchecked(&mut self) - -> Handle, marker::Edge> { + -> Handle, K, V, NewType>, marker::Edge> { Handle::new_edge(self.node.cast_unchecked(), self.idx) } @@ -1562,8 +1562,8 @@ unsafe fn move_kv( // Source and destination must have the same height. unsafe fn move_edges( - mut source: NodeRef, source_offset: usize, - mut dest: NodeRef, dest_offset: usize, + mut source: NodeRef, K, V, marker::Internal>, source_offset: usize, + mut dest: NodeRef, K, V, marker::Internal>, dest_offset: usize, count: usize) { let source_ptr = source.as_internal_mut().edges.as_mut_ptr(); diff --git a/src/liballoc/collections/btree/set.rs b/src/liballoc/collections/btree/set.rs index 9c50bd7e91866..ba3b3ed76c82f 100644 --- a/src/liballoc/collections/btree/set.rs +++ b/src/liballoc/collections/btree/set.rs @@ -80,7 +80,7 @@ pub struct Iter<'a, T: 'a> { #[stable(feature = "collection_debug", since = "1.17.0")] impl fmt::Debug for Iter<'_, T> { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { f.debug_tuple("Iter") .field(&self.iter.clone()) .finish() @@ -128,7 +128,7 @@ pub struct Difference<'a, T: 'a> { #[stable(feature = "collection_debug", since = "1.17.0")] impl fmt::Debug for Difference<'_, T> { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { f.debug_tuple("Difference") .field(&self.a) .field(&self.b) @@ -151,7 +151,7 @@ pub struct SymmetricDifference<'a, T: 'a> { #[stable(feature = "collection_debug", since = "1.17.0")] impl fmt::Debug for SymmetricDifference<'_, T> { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { f.debug_tuple("SymmetricDifference") .field(&self.a) .field(&self.b) @@ -174,7 +174,7 @@ pub struct Intersection<'a, T: 'a> { #[stable(feature = "collection_debug", since = "1.17.0")] impl fmt::Debug for Intersection<'_, T> { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { f.debug_tuple("Intersection") .field(&self.a) .field(&self.b) @@ -197,7 +197,7 @@ pub struct Union<'a, T: 'a> { #[stable(feature = "collection_debug", since = "1.17.0")] impl fmt::Debug for Union<'_, T> { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { f.debug_tuple("Union") .field(&self.a) .field(&self.b) @@ -244,7 +244,7 @@ impl BTreeSet { /// assert_eq!(Some(&5), set.range(4..).next()); /// ``` #[stable(feature = "btree_range", since = "1.17.0")] - pub fn range(&self, range: R) -> Range + pub fn range(&self, range: R) -> Range<'_, T> where K: Ord, T: Borrow, R: RangeBounds { Range { iter: self.map.range(range) } @@ -706,7 +706,7 @@ impl BTreeSet { /// assert_eq!(set_iter.next(), None); /// ``` #[stable(feature = "rust1", since = "1.0.0")] - pub fn iter(&self) -> Iter { + pub fn iter(&self) -> Iter<'_, T> { Iter { iter: self.map.keys() } } @@ -905,7 +905,7 @@ impl BitOr<&BTreeSet> for &BTreeSet { #[stable(feature = "rust1", since = "1.0.0")] impl Debug for BTreeSet { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { f.debug_set().entries(self.iter()).finish() } } diff --git a/src/liballoc/collections/linked_list.rs b/src/liballoc/collections/linked_list.rs index e2da0041b4a8d..f601fa2c8d190 100644 --- a/src/liballoc/collections/linked_list.rs +++ b/src/liballoc/collections/linked_list.rs @@ -64,7 +64,7 @@ pub struct Iter<'a, T: 'a> { #[stable(feature = "collection_debug", since = "1.17.0")] impl fmt::Debug for Iter<'_, T> { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { f.debug_tuple("Iter") .field(&self.len) .finish() @@ -96,7 +96,7 @@ pub struct IterMut<'a, T: 'a> { #[stable(feature = "collection_debug", since = "1.17.0")] impl fmt::Debug for IterMut<'_, T> { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { f.debug_tuple("IterMut") .field(&self.list) .field(&self.len) @@ -119,7 +119,7 @@ pub struct IntoIter { #[stable(feature = "collection_debug", since = "1.17.0")] impl fmt::Debug for IntoIter { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { f.debug_tuple("IntoIter") .field(&self.list) .finish() @@ -333,7 +333,7 @@ impl LinkedList { /// ``` #[inline] #[stable(feature = "rust1", since = "1.0.0")] - pub fn iter(&self) -> Iter { + pub fn iter(&self) -> Iter<'_, T> { Iter { head: self.head, tail: self.tail, @@ -367,7 +367,7 @@ impl LinkedList { /// ``` #[inline] #[stable(feature = "rust1", since = "1.0.0")] - pub fn iter_mut(&mut self) -> IterMut { + pub fn iter_mut(&mut self) -> IterMut<'_, T> { IterMut { head: self.head, tail: self.tail, @@ -766,7 +766,7 @@ impl LinkedList { /// assert_eq!(odds.into_iter().collect::>(), vec![1, 3, 5, 9, 11, 13, 15]); /// ``` #[unstable(feature = "drain_filter", reason = "recently added", issue = "43244")] - pub fn drain_filter(&mut self, filter: F) -> DrainFilter + pub fn drain_filter(&mut self, filter: F) -> DrainFilter<'_, T, F> where F: FnMut(&mut T) -> bool { // avoid borrow issues. @@ -1023,7 +1023,7 @@ impl Drop for DrainFilter<'_, T, F> impl fmt::Debug for DrainFilter<'_, T, F> where F: FnMut(&mut T) -> bool { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { f.debug_tuple("DrainFilter") .field(&self.list) .finish() @@ -1166,7 +1166,7 @@ impl Clone for LinkedList { #[stable(feature = "rust1", since = "1.0.0")] impl fmt::Debug for LinkedList { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { f.debug_list().entries(self).finish() } } diff --git a/src/liballoc/collections/vec_deque.rs b/src/liballoc/collections/vec_deque.rs index abfb83d4139e1..f92c7ed04f4e3 100644 --- a/src/liballoc/collections/vec_deque.rs +++ b/src/liballoc/collections/vec_deque.rs @@ -801,7 +801,7 @@ impl VecDeque { /// assert_eq!(&c[..], b); /// ``` #[stable(feature = "rust1", since = "1.0.0")] - pub fn iter(&self) -> Iter { + pub fn iter(&self) -> Iter<'_, T> { Iter { tail: self.tail, head: self.head, @@ -827,7 +827,7 @@ impl VecDeque { /// assert_eq!(&buf.iter_mut().collect::>()[..], b); /// ``` #[stable(feature = "rust1", since = "1.0.0")] - pub fn iter_mut(&mut self) -> IterMut { + pub fn iter_mut(&mut self) -> IterMut<'_, T> { IterMut { tail: self.tail, head: self.head, @@ -961,7 +961,7 @@ impl VecDeque { /// ``` #[inline] #[stable(feature = "drain", since = "1.6.0")] - pub fn drain(&mut self, range: R) -> Drain + pub fn drain(&mut self, range: R) -> Drain<'_, T> where R: RangeBounds { // Memory safety @@ -2127,7 +2127,7 @@ pub struct Iter<'a, T: 'a> { #[stable(feature = "collection_debug", since = "1.17.0")] impl fmt::Debug for Iter<'_, T> { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { let (front, back) = RingSlices::ring_slices(self.ring, self.head, self.tail); f.debug_tuple("Iter") .field(&front) @@ -2232,7 +2232,7 @@ pub struct IterMut<'a, T: 'a> { #[stable(feature = "collection_debug", since = "1.17.0")] impl<'a, T: fmt::Debug> fmt::Debug for IterMut<'_, T> { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { let (front, back) = RingSlices::ring_slices(&*self.ring, self.head, self.tail); f.debug_tuple("IterMut") .field(&front) @@ -2323,7 +2323,7 @@ pub struct IntoIter { #[stable(feature = "collection_debug", since = "1.17.0")] impl fmt::Debug for IntoIter { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { f.debug_tuple("IntoIter") .field(&self.inner) .finish() @@ -2381,7 +2381,7 @@ pub struct Drain<'a, T: 'a> { #[stable(feature = "collection_debug", since = "1.17.0")] impl fmt::Debug for Drain<'_, T> { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { f.debug_tuple("Drain") .field(&self.after_tail) .field(&self.after_head) @@ -2657,7 +2657,7 @@ impl<'a, T: 'a + Copy> Extend<&'a T> for VecDeque { #[stable(feature = "rust1", since = "1.0.0")] impl fmt::Debug for VecDeque { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { f.debug_list().entries(self).finish() } } diff --git a/src/liballoc/fmt.rs b/src/liballoc/fmt.rs index be35b4487509b..a8a99c7e7a3d3 100644 --- a/src/liballoc/fmt.rs +++ b/src/liballoc/fmt.rs @@ -552,7 +552,7 @@ use crate::string; /// [`format_args!`]: ../../std/macro.format_args.html /// [`format!`]: ../../std/macro.format.html #[stable(feature = "rust1", since = "1.0.0")] -pub fn format(args: Arguments) -> string::String { +pub fn format(args: Arguments<'_>) -> string::String { let capacity = args.estimated_capacity(); let mut output = string::String::with_capacity(capacity); output diff --git a/src/liballoc/lib.rs b/src/liballoc/lib.rs index 5d69b10054719..ab0ade7e5547c 100644 --- a/src/liballoc/lib.rs +++ b/src/liballoc/lib.rs @@ -63,6 +63,9 @@ #![no_std] #![needs_allocator] +#![deny(rust_2018_idioms)] +#![allow(explicit_outlives_requirements)] + #![warn(deprecated_in_future)] #![warn(intra_doc_link_resolution_failure)] #![warn(missing_debug_implementations)] diff --git a/src/liballoc/rc.rs b/src/liballoc/rc.rs index c24e216383974..01a26b6f42337 100644 --- a/src/liballoc/rc.rs +++ b/src/liballoc/rc.rs @@ -1122,21 +1122,21 @@ impl Hash for Rc { #[stable(feature = "rust1", since = "1.0.0")] impl fmt::Display for Rc { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { fmt::Display::fmt(&**self, f) } } #[stable(feature = "rust1", since = "1.0.0")] impl fmt::Debug for Rc { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { fmt::Debug::fmt(&**self, f) } } #[stable(feature = "rust1", since = "1.0.0")] impl fmt::Pointer for Rc { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { fmt::Pointer::fmt(&(&**self as *const T), f) } } @@ -1460,7 +1460,7 @@ impl Clone for Weak { #[stable(feature = "rc_weak", since = "1.4.0")] impl fmt::Debug for Weak { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { write!(f, "(Weak)") } } diff --git a/src/liballoc/string.rs b/src/liballoc/string.rs index 92d3e52d60c73..cb497f5bde212 100644 --- a/src/liballoc/string.rs +++ b/src/liballoc/string.rs @@ -1494,7 +1494,7 @@ impl String { /// assert_eq!(s, ""); /// ``` #[stable(feature = "drain", since = "1.6.0")] - pub fn drain(&mut self, range: R) -> Drain + pub fn drain(&mut self, range: R) -> Drain<'_> where R: RangeBounds { // Memory safety @@ -1678,14 +1678,14 @@ impl FromUtf8Error { #[stable(feature = "rust1", since = "1.0.0")] impl fmt::Display for FromUtf8Error { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { fmt::Display::fmt(&self.error, f) } } #[stable(feature = "rust1", since = "1.0.0")] impl fmt::Display for FromUtf16Error { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { fmt::Display::fmt("invalid utf-16: lone surrogate found", f) } } @@ -1876,7 +1876,7 @@ impl Default for String { #[stable(feature = "rust1", since = "1.0.0")] impl fmt::Display for String { #[inline] - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { fmt::Display::fmt(&**self, f) } } @@ -1884,7 +1884,7 @@ impl fmt::Display for String { #[stable(feature = "rust1", since = "1.0.0")] impl fmt::Debug for String { #[inline] - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { fmt::Debug::fmt(&**self, f) } } @@ -2106,14 +2106,14 @@ impl Clone for ParseError { #[stable(feature = "str_parse_error", since = "1.5.0")] impl fmt::Debug for ParseError { - fn fmt(&self, _: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, _: &mut fmt::Formatter<'_>) -> fmt::Result { match *self {} } } #[stable(feature = "str_parse_error2", since = "1.8.0")] impl fmt::Display for ParseError { - fn fmt(&self, _: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, _: &mut fmt::Formatter<'_>) -> fmt::Result { match *self {} } } @@ -2374,7 +2374,7 @@ pub struct Drain<'a> { #[stable(feature = "collection_debug", since = "1.17.0")] impl fmt::Debug for Drain<'_> { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { f.pad("Drain { .. }") } } diff --git a/src/liballoc/sync.rs b/src/liballoc/sync.rs index 2512e27e316b7..52f8879d1844b 100644 --- a/src/liballoc/sync.rs +++ b/src/liballoc/sync.rs @@ -257,7 +257,7 @@ impl, U: ?Sized> DispatchFromDyn> for Weak {} #[stable(feature = "arc_weak", since = "1.4.0")] impl fmt::Debug for Weak { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { write!(f, "(Weak)") } } @@ -1554,21 +1554,21 @@ impl Eq for Arc {} #[stable(feature = "rust1", since = "1.0.0")] impl fmt::Display for Arc { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { fmt::Display::fmt(&**self, f) } } #[stable(feature = "rust1", since = "1.0.0")] impl fmt::Debug for Arc { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { fmt::Debug::fmt(&**self, f) } } #[stable(feature = "rust1", since = "1.0.0")] impl fmt::Pointer for Arc { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { fmt::Pointer::fmt(&(&**self as *const T), f) } } diff --git a/src/liballoc/vec.rs b/src/liballoc/vec.rs index b43ba6cb57cad..66a73e7579951 100644 --- a/src/liballoc/vec.rs +++ b/src/liballoc/vec.rs @@ -1122,7 +1122,7 @@ impl Vec { /// assert_eq!(v, &[]); /// ``` #[stable(feature = "drain", since = "1.6.0")] - pub fn drain(&mut self, range: R) -> Drain + pub fn drain(&mut self, range: R) -> Drain<'_, T> where R: RangeBounds { // Memory safety @@ -1979,7 +1979,7 @@ impl Vec { /// ``` #[inline] #[stable(feature = "vec_splice", since = "1.21.0")] - pub fn splice(&mut self, range: R, replace_with: I) -> Splice + pub fn splice(&mut self, range: R, replace_with: I) -> Splice<'_, I::IntoIter> where R: RangeBounds, I: IntoIterator { Splice { @@ -2034,7 +2034,7 @@ impl Vec { /// assert_eq!(odds, vec![1, 3, 5, 9, 11, 13, 15]); /// ``` #[unstable(feature = "drain_filter", reason = "recently added", issue = "43244")] - pub fn drain_filter(&mut self, filter: F) -> DrainFilter + pub fn drain_filter(&mut self, filter: F) -> DrainFilter<'_, T, F> where F: FnMut(&mut T) -> bool, { let old_len = self.len(); @@ -2150,7 +2150,7 @@ impl Default for Vec { #[stable(feature = "rust1", since = "1.0.0")] impl fmt::Debug for Vec { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { fmt::Debug::fmt(&**self, f) } } @@ -2293,7 +2293,7 @@ pub struct IntoIter { #[stable(feature = "vec_intoiter_debug", since = "1.13.0")] impl fmt::Debug for IntoIter { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { f.debug_tuple("IntoIter") .field(&self.as_slice()) .finish() @@ -2463,7 +2463,7 @@ pub struct Drain<'a, T: 'a> { #[stable(feature = "collection_debug", since = "1.17.0")] impl<'a, T: 'a + fmt::Debug> fmt::Debug for Drain<'a, T> { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { f.debug_tuple("Drain") .field(&self.iter.as_slice()) .finish() @@ -2652,7 +2652,7 @@ impl Drain<'_, T> { /// An iterator produced by calling `drain_filter` on Vec. #[unstable(feature = "drain_filter", reason = "recently added", issue = "43244")] #[derive(Debug)] -pub struct DrainFilter<'a, T: 'a, F> +pub struct DrainFilter<'a, T, F> where F: FnMut(&mut T) -> bool, { vec: &'a mut Vec, From 017cf53798f8d5a98089d3fc37b739c98e9f75b7 Mon Sep 17 00:00:00 2001 From: Mazdak Farrokhzad Date: Sat, 2 Feb 2019 17:43:55 +0100 Subject: [PATCH 10/12] liballoc: remove redundant extern crate. --- src/liballoc/lib.rs | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/liballoc/lib.rs b/src/liballoc/lib.rs index ab0ade7e5547c..bd2adee15c9fe 100644 --- a/src/liballoc/lib.rs +++ b/src/liballoc/lib.rs @@ -125,8 +125,6 @@ extern crate std; #[cfg(test)] extern crate test; -#[cfg(test)] -extern crate rand; // Module with internal macros used by other modules (needs to be included before other modules). #[macro_use] From 285106a40e70cd5b240625749e4eac8fce96fcf9 Mon Sep 17 00:00:00 2001 From: Mazdak Farrokhzad Date: Sun, 3 Feb 2019 04:37:50 +0100 Subject: [PATCH 11/12] liballoc: alloc-extern-crates test needs --edition=2018 --- src/test/run-make-fulldeps/alloc-extern-crates/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/test/run-make-fulldeps/alloc-extern-crates/Makefile b/src/test/run-make-fulldeps/alloc-extern-crates/Makefile index 7197f4e17e3cc..338caa5614ee5 100644 --- a/src/test/run-make-fulldeps/alloc-extern-crates/Makefile +++ b/src/test/run-make-fulldeps/alloc-extern-crates/Makefile @@ -2,4 +2,4 @@ all: $(RUSTC) fakealloc.rs - $(RUSTC) --crate-type=rlib ../../../liballoc/lib.rs --cfg feature=\"external_crate\" --extern external=$(TMPDIR)/$(shell $(RUSTC) --print file-names fakealloc.rs) + $(RUSTC) --edition=2018 --crate-type=rlib ../../../liballoc/lib.rs --cfg feature=\"external_crate\" --extern external=$(TMPDIR)/$(shell $(RUSTC) --print file-names fakealloc.rs) From 2396780cdaedf097dd6a8f3927749bcaf5b1238b Mon Sep 17 00:00:00 2001 From: Mazdak Farrokhzad Date: Sun, 3 Feb 2019 08:27:44 +0100 Subject: [PATCH 12/12] liballoc: revert nested imports style changes. --- src/liballoc/alloc.rs | 14 ++--- src/liballoc/benches/btree/map.rs | 9 ++- src/liballoc/benches/slice.rs | 7 +-- src/liballoc/borrow.rs | 11 ++-- src/liballoc/boxed.rs | 38 ++++++------ src/liballoc/boxed_test.rs | 14 ++--- src/liballoc/collections/binary_heap.rs | 20 +++--- src/liballoc/collections/btree/map.rs | 30 ++++----- src/liballoc/collections/btree/node.rs | 16 ++--- src/liballoc/collections/btree/search.rs | 6 +- src/liballoc/collections/btree/set.rs | 16 ++--- src/liballoc/collections/linked_list.rs | 21 ++++--- src/liballoc/collections/vec_deque.rs | 32 ++++------ src/liballoc/fmt.rs | 25 +++++--- src/liballoc/prelude.rs | 13 ++-- src/liballoc/raw_vec.rs | 22 +++---- src/liballoc/rc.rs | 64 +++++++++---------- src/liballoc/slice.rs | 25 ++++---- src/liballoc/str.rs | 34 +++++------ src/liballoc/string.rs | 38 +++++------- src/liballoc/sync.rs | 78 +++++++++++------------- src/liballoc/task.rs | 8 +-- src/liballoc/tests/arc.rs | 10 ++- src/liballoc/tests/binary_heap.rs | 11 ++-- src/liballoc/tests/btree/map.rs | 11 ++-- src/liballoc/tests/btree/set.rs | 7 +-- src/liballoc/tests/lib.rs | 6 +- src/liballoc/tests/rc.rs | 10 ++- src/liballoc/tests/slice.rs | 26 ++++---- src/liballoc/tests/str.rs | 14 ++--- src/liballoc/tests/string.rs | 10 ++- src/liballoc/tests/vec.rs | 12 ++-- src/liballoc/tests/vec_deque.rs | 14 ++--- src/liballoc/vec.rs | 39 +++++------- 34 files changed, 305 insertions(+), 406 deletions(-) diff --git a/src/liballoc/alloc.rs b/src/liballoc/alloc.rs index 515de9852d1a6..ec652df3b37a4 100644 --- a/src/liballoc/alloc.rs +++ b/src/liballoc/alloc.rs @@ -2,11 +2,9 @@ #![stable(feature = "alloc_module", since = "1.28.0")] -use core::{ - intrinsics::{min_align_of_val, size_of_val}, - ptr::{NonNull, Unique}, - usize, -}; +use core::intrinsics::{min_align_of_val, size_of_val}; +use core::ptr::{NonNull, Unique}; +use core::usize; #[stable(feature = "alloc_module", since = "1.28.0")] #[doc(inline)] @@ -230,10 +228,8 @@ pub fn handle_alloc_error(layout: Layout) -> ! { mod tests { extern crate test; use test::Bencher; - use crate::{ - boxed::Box, - alloc::{Global, Alloc, Layout, handle_alloc_error}, - }; + use crate::boxed::Box; + use crate::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 3865ec866aeed..4c17bdc3e9e9d 100644 --- a/src/liballoc/benches/btree/map.rs +++ b/src/liballoc/benches/btree/map.rs @@ -1,8 +1,7 @@ -use std::{ - iter::Iterator, - vec::Vec, - collections::BTreeMap, -}; +use std::iter::Iterator; +use std::vec::Vec; +use std::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 d87b70f2d932c..f17fb8212ce19 100644 --- a/src/liballoc/benches/slice.rs +++ b/src/liballoc/benches/slice.rs @@ -1,8 +1,7 @@ use std::{mem, ptr}; -use rand::{ - thread_rng, Rng, SeedableRng, - distributions::{Standard, Alphanumeric}, -}; + +use rand::{thread_rng, Rng, SeedableRng}; +use rand::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 1fda36778f486..270f48e80835a 100644 --- a/src/liballoc/borrow.rs +++ b/src/liballoc/borrow.rs @@ -2,16 +2,15 @@ #![stable(feature = "rust1", since = "1.0.0")] -use core::{ - cmp::Ordering, - hash::{Hash, Hasher}, - ops::{Add, AddAssign, Deref}, -}; +use core::cmp::Ordering; +use core::hash::{Hash, Hasher}; +use core::ops::{Add, AddAssign, Deref}; #[stable(feature = "rust1", since = "1.0.0")] pub use core::borrow::{Borrow, BorrowMut}; -use crate::{fmt, string::String}; +use crate::fmt; +use crate::string::String; use Cow::*; diff --git a/src/liballoc/boxed.rs b/src/liballoc/boxed.rs index 40b091b92c1a5..8e01e12e0b8de 100644 --- a/src/liballoc/boxed.rs +++ b/src/liballoc/boxed.rs @@ -56,28 +56,26 @@ #![stable(feature = "rust1", since = "1.0.0")] -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::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::ptr::{self, NonNull, Unique}; +use core::task::{LocalWaker, Poll}; -use crate::{ - vec::Vec, - raw_vec::RawVec, - str::from_boxed_utf8_unchecked, -}; +use crate::vec::Vec; +use crate::raw_vec::RawVec; +use crate::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 6fb01fbc6a150..654eabd070326 100644 --- a/src/liballoc/boxed_test.rs +++ b/src/liballoc/boxed_test.rs @@ -1,13 +1,11 @@ //! Test for `boxed` mod. -use core::{ - any::Any, - ops::Deref, - result::Result::{Err, Ok}, - clone::Clone, - f64, - i64, -}; +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 std::boxed::Box; diff --git a/src/liballoc/collections/binary_heap.rs b/src/liballoc/collections/binary_heap.rs index 5f0386400d707..f97522140a8a1 100644 --- a/src/liballoc/collections/binary_heap.rs +++ b/src/liballoc/collections/binary_heap.rs @@ -145,18 +145,14 @@ #![allow(missing_docs)] #![stable(feature = "rust1", since = "1.0.0")] -use core::{ - ops::{Deref, DerefMut}, - iter::{FromIterator, FusedIterator}, - mem::{swap, size_of, ManuallyDrop}, - ptr, - fmt, -}; - -use crate::{ - slice, - vec::{self, Vec}, -}; +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 super::SpecExtend; diff --git a/src/liballoc/collections/btree/map.rs b/src/liballoc/collections/btree/map.rs index fe6b5fef210e1..aaaa419dcb849 100644 --- a/src/liballoc/collections/btree/map.rs +++ b/src/liballoc/collections/btree/map.rs @@ -1,21 +1,15 @@ -use core::{ - borrow::Borrow, - 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 super::{ - node::{self, Handle, NodeRef, marker, InsertResult::*, ForceResult::*}, - search::{self, SearchResult::*}, -}; +use core::borrow::Borrow; +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, RangeBounds}; +use core::{fmt, intrinsics, mem, ptr}; + +use super::node::{self, Handle, NodeRef, marker, InsertResult::*, ForceResult::*}; +use super::search::{self, SearchResult::*}; use UnderflowResult::*; use Entry::*; diff --git a/src/liballoc/collections/btree/node.rs b/src/liballoc/collections/btree/node.rs index a5f90aa8974b6..c4f39430533dc 100644 --- a/src/liballoc/collections/btree/node.rs +++ b/src/liballoc/collections/btree/node.rs @@ -31,17 +31,13 @@ // - 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, - mem::{self, MaybeUninit}, - ptr::{self, Unique, NonNull}, - slice, -}; +use core::marker::PhantomData; +use core::mem::{self, MaybeUninit}; +use core::ptr::{self, Unique, NonNull}; +use core::slice; -use crate::{ - alloc::{Global, Alloc, Layout}, - boxed::Box, -}; +use crate::alloc::{Global, Alloc, Layout}; +use crate::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 1645e48cb5299..dfb67d2ea5756 100644 --- a/src/liballoc/collections/btree/search.rs +++ b/src/liballoc/collections/btree/search.rs @@ -1,7 +1,5 @@ -use core::{ - borrow::Borrow, - cmp::Ordering, -}; +use core::borrow::Borrow; +use core::cmp::Ordering; use super::node::{Handle, NodeRef, marker, ForceResult::*}; diff --git a/src/liballoc/collections/btree/set.rs b/src/liballoc/collections/btree/set.rs index ba3b3ed76c82f..78cd21dd4118d 100644 --- a/src/liballoc/collections/btree/set.rs +++ b/src/liballoc/collections/btree/set.rs @@ -1,16 +1,12 @@ // This is pretty much entirely stolen from TreeSet, since BTreeMap has an identical interface // to TreeMap -use core::{ - borrow::Borrow, - cmp::{ - Ordering::{self, Less, Greater, Equal}, - min, max, - }, - fmt::{self, Debug}, - iter::{Peekable, FromIterator, FusedIterator}, - ops::{BitOr, BitAnd, BitXor, Sub, RangeBounds}, -}; +use core::borrow::Borrow; +use core::cmp::Ordering::{self, Less, Greater, Equal}; +use core::cmp::{min, max}; +use core::fmt::{self, Debug}; +use core::iter::{Peekable, FromIterator, FusedIterator}; +use core::ops::{BitOr, BitAnd, BitXor, Sub, RangeBounds}; use crate::collections::btree_map::{self, BTreeMap, Keys}; use super::Recover; diff --git a/src/liballoc/collections/linked_list.rs b/src/liballoc/collections/linked_list.rs index f601fa2c8d190..afd8078cdd753 100644 --- a/src/liballoc/collections/linked_list.rs +++ b/src/liballoc/collections/linked_list.rs @@ -12,15 +12,13 @@ #![stable(feature = "rust1", since = "1.0.0")] -use core::{ - cmp::Ordering, - fmt, - hash::{Hasher, Hash}, - iter::{FromIterator, FusedIterator}, - marker::PhantomData, - mem, - ptr::NonNull, -}; +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 crate::boxed::Box; use super::SpecExtend; @@ -1215,8 +1213,11 @@ unsafe impl<'a, T: Sync> Sync for IterMut<'a, T> {} #[cfg(test)] mod tests { - use std::{thread, vec::Vec}; + use std::thread; + use std::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 f92c7ed04f4e3..99fa54acb0836 100644 --- a/src/liballoc/collections/vec_deque.rs +++ b/src/liballoc/collections/vec_deque.rs @@ -7,25 +7,19 @@ #![stable(feature = "rust1", since = "1.0.0")] -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, -}; +use core::cmp::{self, 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::{self, NonNull}; +use core::slice; +use core::hash::{Hash, Hasher}; + +use crate::collections::CollectionAllocErr; +use crate::raw_vec::RawVec; +use crate::vec::Vec; const INITIAL_CAPACITY: usize = 7; // 2^3 - 1 const MINIMUM_CAPACITY: usize = 1; // 2 - 1 diff --git a/src/liballoc/fmt.rs b/src/liballoc/fmt.rs index a8a99c7e7a3d3..9bda7034a621b 100644 --- a/src/liballoc/fmt.rs +++ b/src/liballoc/fmt.rs @@ -509,16 +509,21 @@ #[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, - Binary, Octal, - Debug, Display, - LowerHex, Pointer, UpperHex, - LowerExp, UpperExp, - Error, - write, ArgumentV1, Arguments, - DebugList, DebugMap, DebugSet, DebugStruct, DebugTuple -}; +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}; #[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 3f1d6ded66d35..6767cf89f73ba 100644 --- a/src/liballoc/prelude.rs +++ b/src/liballoc/prelude.rs @@ -12,11 +12,8 @@ #![unstable(feature = "alloc", issue = "27783")] -#[unstable(feature = "alloc", issue = "27783")] -pub use crate::{ - borrow::ToOwned, - boxed::Box, - slice::SliceConcatExt, - string::{String, ToString}, - vec::Vec, -}; +#[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; diff --git a/src/liballoc/raw_vec.rs b/src/liballoc/raw_vec.rs index f1839f736341c..dcecf9bc76d88 100644 --- a/src/liballoc/raw_vec.rs +++ b/src/liballoc/raw_vec.rs @@ -1,19 +1,15 @@ #![unstable(feature = "raw_vec_internals", reason = "implementation detail", issue = "0")] #![doc(hidden)] -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, -}; +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::{self, *}; +use crate::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 diff --git a/src/liballoc/rc.rs b/src/liballoc/rc.rs index 01a26b6f42337..d78869270d563 100644 --- a/src/liballoc/rc.rs +++ b/src/liballoc/rc.rs @@ -231,29 +231,25 @@ use crate::boxed::Box; #[cfg(test)] use std::boxed::Box; -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}, - slice::from_raw_parts_mut, - convert::From, - usize, -}; - -use crate::{ - alloc::{Global, Alloc, Layout, box_free, handle_alloc_error}, - string::String, - vec::Vec, -}; +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::{self, Unpin, Unsize, PhantomData}; +use core::mem::{self, align_of_val, forget, size_of_val}; +use core::ops::{Deref, Receiver, CoerceUnsized, DispatchFromDyn}; +use core::pin::Pin; +use core::ptr::{self, NonNull}; +use core::slice::from_raw_parts_mut; +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; struct RcBox { strong: Cell, @@ -1563,15 +1559,13 @@ impl RcBoxPtr for RcBox { #[cfg(test)] mod tests { use super::{Rc, Weak}; - use std::{ - boxed::Box, - cell::RefCell, - option::Option::{self, None, Some}, - result::Result::{Err, Ok}, - mem::drop, - clone::Clone, - convert::From, - }; + use std::boxed::Box; + use std::cell::RefCell; + use std::option::Option::{self, None, Some}; + use std::result::Result::{Err, Ok}; + use std::mem::drop; + use std::clone::Clone; + use std::convert::From; #[test] fn test_clone() { @@ -1735,7 +1729,8 @@ mod tests { #[test] fn test_into_from_raw_unsized() { - use std::{fmt::Display, string::ToString}; + use std::fmt::Display; + use std::string::ToString; let rc: Rc = Rc::from("foo"); @@ -1943,7 +1938,8 @@ mod tests { #[test] fn test_from_box_trait() { - use std::{fmt::Display, string::ToString}; + use std::fmt::Display; + use std::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 9d1197117bbda..479959deeb1a7 100644 --- a/src/liballoc/slice.rs +++ b/src/liballoc/slice.rs @@ -87,19 +87,15 @@ // 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::{ - borrow::{Borrow, BorrowMut}, - cmp::Ordering::{self, Less}, - mem::{self, size_of}, - ptr, - u8, u16, u32, -}; - -use crate::{ - borrow::ToOwned, - boxed::Box, - vec::Vec, -}; +use core::borrow::{Borrow, BorrowMut}; +use core::cmp::Ordering::{self, Less}; +use core::mem::{self, size_of}; +use core::ptr; +use core::{u8, u16, u32}; + +use crate::borrow::ToOwned; +use crate::boxed::Box; +use crate::vec::Vec; #[stable(feature = "rust1", since = "1.0.0")] pub use core::slice::{Chunks, Windows}; @@ -142,8 +138,9 @@ pub use hack::to_vec; // `test_permutations` test mod hack { use core::mem; - use crate::{boxed::Box, vec::Vec}; + use crate::boxed::Box; + use crate::vec::Vec; #[cfg(test)] use crate::string::ToString; diff --git a/src/liballoc/str.rs b/src/liballoc/str.rs index 9681572d883f5..211e75bd91504 100644 --- a/src/liballoc/str.rs +++ b/src/liballoc/str.rs @@ -28,26 +28,20 @@ // It's cleaner to just turn off the unused_imports warning than to fix them. #![allow(unused_imports)] -use core::{ - borrow::Borrow, - fmt, - str::{ - self as core_str, - pattern::{Pattern, Searcher, ReverseSearcher, DoubleEndedSearcher}, - }, - mem, - ptr, - iter::FusedIterator, - unicode::conversions, -}; - -use crate::{ - borrow::ToOwned, - boxed::Box, - slice::{SliceConcatExt, SliceIndex}, - string::String, - vec::Vec, -}; +use core::borrow::Borrow; +use core::fmt; +use core::str as core_str; +use core::str::pattern::{Pattern, Searcher, ReverseSearcher, DoubleEndedSearcher}; +use core::mem; +use core::ptr; +use core::iter::FusedIterator; +use core::unicode::conversions; + +use crate::borrow::ToOwned; +use crate::boxed::Box; +use crate::slice::{SliceConcatExt, SliceIndex}; +use crate::string::String; +use crate::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 cb497f5bde212..73f67e98f364e 100644 --- a/src/liballoc/string.rs +++ b/src/liballoc/string.rs @@ -46,30 +46,20 @@ #![stable(feature = "rust1", since = "1.0.0")] -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::{ - borrow::{Cow, ToOwned}, - collections::CollectionAllocErr, - boxed::Box, - str::{self, from_boxed_utf8_unchecked, FromStr, Utf8Error, Chars}, - vec::Vec, -}; +use core::char::{decode_utf16, REPLACEMENT_CHARACTER}; +use core::fmt; +use core::hash; +use core::iter::{FromIterator, FusedIterator}; +use core::ops::{self, Add, AddAssign, Index, IndexMut, RangeBounds}; +use core::ops::Bound::{Excluded, Included, Unbounded}; +use core::ptr; +use core::str::{pattern::Pattern, lossy}; + +use crate::borrow::{Cow, ToOwned}; +use crate::collections::CollectionAllocErr; +use crate::boxed::Box; +use crate::str::{self, from_boxed_utf8_unchecked, FromStr, Utf8Error, Chars}; +use crate::vec::Vec; /// A UTF-8 encoded, growable string. /// diff --git a/src/liballoc/sync.rs b/src/liballoc/sync.rs index 52f8879d1844b..5bdb3616ed232 100644 --- a/src/liballoc/sync.rs +++ b/src/liballoc/sync.rs @@ -6,34 +6,28 @@ //! //! [arc]: struct.Arc.html -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, - slice::from_raw_parts_mut, -}; - -use crate::{ - alloc::{Global, Alloc, Layout, box_free, handle_alloc_error}, - boxed::Box, - rc::is_dangling, - string::String, - vec::Vec, -}; +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, 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 core::slice::from_raw_parts_mut; + +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; /// A soft limit on the amount of references that may be made to an `Arc`. /// @@ -1654,18 +1648,16 @@ impl From> for Arc<[T]> { #[cfg(test)] mod tests { - 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 std::boxed::Box; + use std::clone::Clone; + use std::sync::mpsc::channel; + use std::mem::drop; + use std::ops::Drop; + use std::option::Option::{self, None, Some}; + use std::sync::atomic::{self, Ordering::{Acquire, SeqCst}}; + use std::thread; + use std::sync::Mutex; + use std::convert::From; use super::{Arc, Weak}; use crate::vec::Vec; @@ -1774,7 +1766,8 @@ mod tests { #[test] fn test_into_from_raw_unsized() { - use std::{fmt::Display, string::ToString}; + use std::fmt::Display; + use std::string::ToString; let arc: Arc = Arc::from("foo"); @@ -2086,7 +2079,8 @@ mod tests { #[test] fn test_from_box_trait() { - use std::{fmt::Display, string::ToString}; + use std::fmt::Display; + use std::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 0bf1ff35cc175..2261dabe2779a 100644 --- a/src/liballoc/task.rs +++ b/src/liballoc/task.rs @@ -8,11 +8,9 @@ pub use if_arc::*; #[cfg(all(target_has_atomic = "ptr", target_has_atomic = "cas"))] mod if_arc { use super::*; - use core::{ - marker::PhantomData, - mem, - ptr::{self, NonNull}, - }; + use core::marker::PhantomData; + use core::mem; + use core::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 b71cf3bd47795..2759b1b1cac27 100644 --- a/src/liballoc/tests/arc.rs +++ b/src/liballoc/tests/arc.rs @@ -1,9 +1,7 @@ -use std::{ - any::Any, - sync::{Arc, Weak}, - cell::RefCell, - cmp::PartialEq, -}; +use std::any::Any; +use std::sync::{Arc, Weak}; +use std::cell::RefCell; +use std::cmp::PartialEq; #[test] fn uninhabited() { diff --git a/src/liballoc/tests/binary_heap.rs b/src/liballoc/tests/binary_heap.rs index f19d641fe83eb..94ae43237d19c 100644 --- a/src/liballoc/tests/binary_heap.rs +++ b/src/liballoc/tests/binary_heap.rs @@ -1,9 +1,8 @@ -use std::{ - cmp, - collections::{BinaryHeap, binary_heap::{Drain, PeekMut}}, - panic::{self, AssertUnwindSafe}, - sync::atomic::{AtomicUsize, Ordering}, -}; +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 rand::{thread_rng, seq::SliceRandom}; diff --git a/src/liballoc/tests/btree/map.rs b/src/liballoc/tests/btree/map.rs index 6859b0138b5ed..aaf504073285d 100644 --- a/src/liballoc/tests/btree/map.rs +++ b/src/liballoc/tests/btree/map.rs @@ -1,9 +1,8 @@ -use std::{ - collections::{BTreeMap, btree_map::Entry::{Occupied, Vacant}}, - ops::Bound::{self, Excluded, Included, Unbounded}, - rc::Rc, - iter::FromIterator, -}; +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::iter::FromIterator; use super::DeterministicRng; diff --git a/src/liballoc/tests/btree/set.rs b/src/liballoc/tests/btree/set.rs index b90ecd9e3f136..4f5168f1ce572 100644 --- a/src/liballoc/tests/btree/set.rs +++ b/src/liballoc/tests/btree/set.rs @@ -1,7 +1,6 @@ -use std::{ - collections::BTreeSet, - iter::FromIterator -}; +use std::collections::BTreeSet; +use std::iter::FromIterator; + use super::DeterministicRng; #[test] diff --git a/src/liballoc/tests/lib.rs b/src/liballoc/tests/lib.rs index 100b3986370ab..a76fd87a1a92d 100644 --- a/src/liballoc/tests/lib.rs +++ b/src/liballoc/tests/lib.rs @@ -13,10 +13,8 @@ extern crate core; extern crate rand; -use std::{ - hash::{Hash, Hasher}, - collections::hash_map::DefaultHasher, -}; +use std::hash::{Hash, Hasher}; +use std::collections::hash_map::DefaultHasher; mod arc; mod binary_heap; diff --git a/src/liballoc/tests/rc.rs b/src/liballoc/tests/rc.rs index caa3c914fc248..18f82e8041008 100644 --- a/src/liballoc/tests/rc.rs +++ b/src/liballoc/tests/rc.rs @@ -1,9 +1,7 @@ -use std::{ - any::Any, - rc::{Rc, Weak}, - cell::RefCell, - cmp::PartialEq, -}; +use std::any::Any; +use std::rc::{Rc, Weak}; +use std::cell::RefCell; +use std::cmp::PartialEq; #[test] fn uninhabited() { diff --git a/src/liballoc/tests/slice.rs b/src/liballoc/tests/slice.rs index d0a8b65ae8be0..334466dfb25f5 100644 --- a/src/liballoc/tests/slice.rs +++ b/src/liballoc/tests/slice.rs @@ -1,18 +1,14 @@ -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, -}; +use std::cell::Cell; +use std::cmp::Ordering::{self, Equal, Greater, Less}; +use std::mem; +use std::panic; +use std::rc::Rc; +use std::sync::atomic::{Ordering::Relaxed, AtomicUsize}; +use std::thread; + +use rand::{Rng, RngCore, thread_rng}; +use rand::seq::SliceRandom; +use rand::distributions::Standard; fn square(n: usize) -> usize { n * n diff --git a/src/liballoc/tests/str.rs b/src/liballoc/tests/str.rs index b1586558713e7..1bc1bd8d78c57 100644 --- a/src/liballoc/tests/str.rs +++ b/src/liballoc/tests/str.rs @@ -1,8 +1,6 @@ -use std::{ - borrow::Cow, - cmp::Ordering::{Equal, Greater, Less}, - str::from_utf8, -}; +use std::borrow::Cow; +use std::cmp::Ordering::{Equal, Greater, Less}; +use std::str::from_utf8; #[test] fn test_le() { @@ -1601,10 +1599,8 @@ fn test_repeat() { } mod pattern { - use std::str::pattern::{ - Pattern, Searcher, ReverseSearcher, - SearchStep::{self, Match, Reject, Done}, - }; + use std::str::pattern::{Pattern, Searcher, ReverseSearcher}; + use std::str::pattern::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 14f70fdf3034d..e5ce51a36ee22 100644 --- a/src/liballoc/tests/string.rs +++ b/src/liballoc/tests/string.rs @@ -1,9 +1,7 @@ -use std::{ - borrow::Cow, - collections::CollectionAllocErr::*, - mem::size_of, - usize, isize, -}; +use std::borrow::Cow; +use std::collections::CollectionAllocErr::*; +use std::mem::size_of; +use std::{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 e8fea287e1cb4..89f2e0a046d91 100644 --- a/src/liballoc/tests/vec.rs +++ b/src/liballoc/tests/vec.rs @@ -1,10 +1,8 @@ -use std::{ - borrow::Cow, - mem::size_of, - usize, isize, - vec::{Drain, IntoIter}, - collections::CollectionAllocErr::*, -}; +use std::borrow::Cow; +use std::mem::size_of; +use std::{usize, isize}; +use std::vec::{Drain, IntoIter}; +use std::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 313aa55a2b28e..aa49bdb009086 100644 --- a/src/liballoc/tests/vec_deque.rs +++ b/src/liballoc/tests/vec_deque.rs @@ -1,12 +1,8 @@ -use std::{ - fmt::Debug, - collections::{ - VecDeque, vec_deque::Drain, - CollectionAllocErr::*, - }, - mem::size_of, - usize, isize, -}; +use std::fmt::Debug; +use std::collections::{VecDeque, vec_deque::Drain}; +use std::collections::CollectionAllocErr::*; +use std::mem::size_of; +use std::{usize, isize}; use crate::hash; diff --git a/src/liballoc/vec.rs b/src/liballoc/vec.rs index 66a73e7579951..57e10498b92db 100644 --- a/src/liballoc/vec.rs +++ b/src/liballoc/vec.rs @@ -56,29 +56,22 @@ #![stable(feature = "rust1", since = "1.0.0")] -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::{self, SliceIndex}, -}; - -use crate::{ - borrow::{ToOwned, Cow}, - collections::CollectionAllocErr, - boxed::Box, - raw_vec::RawVec, -}; +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::{self, Index, IndexMut, RangeBounds}; +use core::ops::Bound::{Excluded, Included, Unbounded}; +use core::ptr::{self, NonNull}; +use core::slice::{self, SliceIndex}; + +use crate::borrow::{ToOwned, Cow}; +use crate::collections::CollectionAllocErr; +use crate::boxed::Box; +use crate::raw_vec::RawVec; /// A contiguous growable array type, written `Vec` but pronounced 'vector'. ///