Skip to content

Commit

Permalink
liballoc: revert nested imports style changes.
Browse files Browse the repository at this point in the history
  • Loading branch information
Centril committed Feb 3, 2019
1 parent 285106a commit 2396780
Show file tree
Hide file tree
Showing 34 changed files with 305 additions and 406 deletions.
14 changes: 5 additions & 9 deletions src/liballoc/alloc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)]
Expand Down Expand Up @@ -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() {
Expand Down
9 changes: 4 additions & 5 deletions src/liballoc/benches/btree/map.rs
Original file line number Diff line number Diff line change
@@ -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};

Expand Down
7 changes: 3 additions & 4 deletions src/liballoc/benches/slice.rs
Original file line number Diff line number Diff line change
@@ -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};

Expand Down
11 changes: 5 additions & 6 deletions src/liballoc/borrow.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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::*;

Expand Down
38 changes: 18 additions & 20 deletions src/liballoc/boxed.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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.
///
Expand Down
14 changes: 6 additions & 8 deletions src/liballoc/boxed_test.rs
Original file line number Diff line number Diff line change
@@ -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;

Expand Down
20 changes: 8 additions & 12 deletions src/liballoc/collections/binary_heap.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
30 changes: 12 additions & 18 deletions src/liballoc/collections/btree/map.rs
Original file line number Diff line number Diff line change
@@ -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::*;
Expand Down
16 changes: 6 additions & 10 deletions src/liballoc/collections/btree/node.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
6 changes: 2 additions & 4 deletions src/liballoc/collections/btree/search.rs
Original file line number Diff line number Diff line change
@@ -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::*};

Expand Down
16 changes: 6 additions & 10 deletions src/liballoc/collections/btree/set.rs
Original file line number Diff line number Diff line change
@@ -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;
Expand Down
21 changes: 11 additions & 10 deletions src/liballoc/collections/linked_list.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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)]
Expand Down
32 changes: 13 additions & 19 deletions src/liballoc/collections/vec_deque.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
25 changes: 15 additions & 10 deletions src/liballoc/fmt.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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};

Expand Down
13 changes: 5 additions & 8 deletions src/liballoc/prelude.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Loading

0 comments on commit 2396780

Please sign in to comment.