diff --git a/src/libcollections/bench.rs b/src/libcollections/bench.rs index 3346e55158a..fbaebd0125d 100644 --- a/src/libcollections/bench.rs +++ b/src/libcollections/bench.rs @@ -8,7 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -use std::prelude::*; +use prelude::*; use std::rand; use std::rand::Rng; use test::Bencher; diff --git a/src/libcollections/binary_heap.rs b/src/libcollections/binary_heap.rs index be99c4c0bc7..e1c06736b36 100644 --- a/src/libcollections/binary_heap.rs +++ b/src/libcollections/binary_heap.rs @@ -617,10 +617,9 @@ impl Extend for BinaryHeap { #[cfg(test)] mod tests { - use std::prelude::*; + use prelude::*; use super::BinaryHeap; - use vec::Vec; #[test] fn test_iterator() { diff --git a/src/libcollections/bit.rs b/src/libcollections/bit.rs index 7f78d56607e..f59fb1c5d3d 100644 --- a/src/libcollections/bit.rs +++ b/src/libcollections/bit.rs @@ -1686,16 +1686,15 @@ impl<'a> Iterator for TwoBitPositions<'a> { #[cfg(test)] mod tests { - use std::prelude::*; - use std::iter::range_step; + use prelude::*; + use core::iter::range_step; + use core::u32; use std::rand; use std::rand::Rng; - use std::u32; use test::{Bencher, black_box}; use super::{Bitv, BitvSet, from_fn, from_bytes}; use bitv; - use vec::Vec; static BENCH_BITS : uint = 1 << 14; @@ -2038,7 +2037,7 @@ mod tests { #[test] fn test_from_bytes() { let bitv = from_bytes(&[0b10110110, 0b00000000, 0b11111111]); - let str = format!("{}{}{}", "10110110", "00000000", "11111111"); + let str = concat!("10110110", "00000000", "11111111"); assert_eq!(bitv.to_string(), str); } diff --git a/src/libcollections/btree/map.rs b/src/libcollections/btree/map.rs index c7cbb5a1c29..01096c1fd4e 100644 --- a/src/libcollections/btree/map.rs +++ b/src/libcollections/btree/map.rs @@ -131,12 +131,12 @@ pub enum Entry<'a, K:'a, V:'a> { /// A vacant Entry. pub struct VacantEntry<'a, K:'a, V:'a> { key: K, - stack: stack::SearchStack<'a, K, V, node::Edge, node::Leaf>, + stack: stack::SearchStack<'a, K, V, node::handle::Edge, node::handle::Leaf>, } /// An occupied Entry. pub struct OccupiedEntry<'a, K:'a, V:'a> { - stack: stack::SearchStack<'a, K, V, node::KV, node::LeafOrInternal>, + stack: stack::SearchStack<'a, K, V, node::handle::KV, node::handle::LeafOrInternal>, } impl BTreeMap { @@ -496,7 +496,8 @@ mod stack { use core::kinds::marker; use core::mem; use super::BTreeMap; - use super::super::node::{mod, Node, Fit, Split, KV, Edge, Internal, Leaf, LeafOrInternal}; + use super::super::node::{mod, Node, Fit, Split, Internal, Leaf}; + use super::super::node::handle; use vec::Vec; /// A generic mutable reference, identical to `&mut` except for the fact that its lifetime @@ -520,7 +521,7 @@ mod stack { } } - type StackItem = node::Handle<*mut Node, Edge, Internal>; + type StackItem = node::Handle<*mut Node, handle::Edge, handle::Internal>; type Stack = Vec>; /// A `PartialSearchStack` handles the construction of a search stack. @@ -595,7 +596,9 @@ mod stack { /// Pushes the requested child of the stack's current top on top of the stack. If the child /// exists, then a new PartialSearchStack is yielded. Otherwise, a VacantSearchStack is /// yielded. - pub fn push(mut self, mut edge: node::Handle>, Edge, Internal>) + pub fn push(mut self, mut edge: node::Handle>, + handle::Edge, + handle::Internal>) -> PartialSearchStack<'a, K, V> { self.stack.push(edge.as_raw()); PartialSearchStack { @@ -617,7 +620,7 @@ mod stack { } } - impl<'a, K, V, NodeType> SearchStack<'a, K, V, KV, NodeType> { + impl<'a, K, V, NodeType> SearchStack<'a, K, V, handle::KV, NodeType> { /// Gets a reference to the value the stack points to. pub fn peek(&self) -> &V { unsafe { self.top.from_raw().into_kv().1 } @@ -640,7 +643,7 @@ mod stack { } } - impl<'a, K, V> SearchStack<'a, K, V, KV, Leaf> { + impl<'a, K, V> SearchStack<'a, K, V, handle::KV, handle::Leaf> { /// Removes the key and value in the top element of the stack, then handles underflows as /// described in BTree's pop function. fn remove_leaf(mut self) -> V { @@ -686,7 +689,7 @@ mod stack { } } - impl<'a, K, V> SearchStack<'a, K, V, KV, LeafOrInternal> { + impl<'a, K, V> SearchStack<'a, K, V, handle::KV, handle::LeafOrInternal> { /// Removes the key and value in the top element of the stack, then handles underflows as /// described in BTree's pop function. pub fn remove(self) -> V { @@ -703,7 +706,7 @@ mod stack { /// leaves the tree in an inconsistent state that must be repaired by the caller by /// removing the entry in question. Specifically the key-value pair and its successor will /// become swapped. - fn into_leaf(mut self) -> SearchStack<'a, K, V, KV, Leaf> { + fn into_leaf(mut self) -> SearchStack<'a, K, V, handle::KV, handle::Leaf> { unsafe { let mut top_raw = self.top; let mut top = top_raw.from_raw_mut(); @@ -757,7 +760,7 @@ mod stack { } } - impl<'a, K, V> SearchStack<'a, K, V, Edge, Leaf> { + impl<'a, K, V> SearchStack<'a, K, V, handle::Edge, handle::Leaf> { /// Inserts the key and value into the top element in the stack, and if that node has to /// split recursively inserts the split contents into the next element stack until /// splits stop. @@ -1332,7 +1335,7 @@ impl BTreeMap { #[cfg(test)] mod test { - use std::prelude::*; + use prelude::*; use super::{BTreeMap, Occupied, Vacant}; @@ -1534,7 +1537,7 @@ mod test { #[cfg(test)] mod bench { - use std::prelude::*; + use prelude::*; use std::rand::{weak_rng, Rng}; use test::{Bencher, black_box}; diff --git a/src/libcollections/btree/node.rs b/src/libcollections/btree/node.rs index 9698b06c7fa..1666f42d82b 100644 --- a/src/libcollections/btree/node.rs +++ b/src/libcollections/btree/node.rs @@ -34,9 +34,9 @@ pub enum InsertionResult { /// Represents the result of a search for a key in a single node pub enum SearchResult { /// The element was found at the given index - Found(Handle), + Found(Handle), /// The element wasn't found, but if it's anywhere, it must be beyond this edge - GoDown(Handle), + GoDown(Handle), } /// A B-Tree Node. We keep keys/edges/values separate to optimize searching for keys. @@ -494,12 +494,16 @@ pub struct Handle { index: uint } -pub enum KV {} -pub enum Edge {} +pub mod handle { + // Handle types. + pub enum KV {} + pub enum Edge {} -pub enum LeafOrInternal {} -pub enum Leaf {} -pub enum Internal {} + // Handle node types. + pub enum LeafOrInternal {} + pub enum Leaf {} + pub enum Internal {} +} impl Node { /// Searches for the given key in the node. If it finds an exact match, @@ -625,7 +629,7 @@ impl Handle<*mut Node, Type, NodeType> { } } -impl<'a, K: 'a, V: 'a> Handle<&'a Node, Edge, Internal> { +impl<'a, K: 'a, V: 'a> Handle<&'a Node, handle::Edge, handle::Internal> { /// Turns the handle into a reference to the edge it points at. This is necessary because the /// returned pointer has a larger lifetime than what would be returned by `edge` or `edge_mut`, /// making it more suitable for moving down a chain of nodes. @@ -636,7 +640,7 @@ impl<'a, K: 'a, V: 'a> Handle<&'a Node, Edge, Internal> { } } -impl<'a, K: 'a, V: 'a> Handle<&'a mut Node, Edge, Internal> { +impl<'a, K: 'a, V: 'a> Handle<&'a mut Node, handle::Edge, handle::Internal> { /// Turns the handle into a mutable reference to the edge it points at. This is necessary /// because the returned pointer has a larger lifetime than what would be returned by /// `edge_mut`, making it more suitable for moving down a chain of nodes. @@ -647,7 +651,7 @@ impl<'a, K: 'a, V: 'a> Handle<&'a mut Node, Edge, Internal> { } } -impl>> Handle { +impl>> Handle { // This doesn't exist because there are no uses for it, // but is fine to add, analagous to edge_mut. // @@ -657,11 +661,11 @@ impl>> Handle { } pub enum ForceResult { - Leaf(Handle), - Internal(Handle) + Leaf(Handle), + Internal(Handle) } -impl>, Type> Handle { +impl>, Type> Handle { /// Figure out whether this handle is pointing to something in a leaf node or to something in /// an internal node, clarifying the type according to the result. pub fn force(self) -> ForceResult { @@ -679,7 +683,7 @@ impl>, Type> Handle>> Handle { +impl>> Handle { /// Tries to insert this key-value pair at the given index in this leaf node /// If the node is full, we have to split it. /// @@ -711,7 +715,7 @@ impl>> Handle { } } -impl>> Handle { +impl>> Handle { /// Returns a mutable reference to the edge pointed-to by this handle. This should not be /// confused with `node`, which references the parent node of what is returned here. pub fn edge_mut(&mut self) -> &mut Node { @@ -794,11 +798,11 @@ impl>> Handle { } } -impl>, NodeType> Handle { +impl>, NodeType> Handle { /// Gets the handle pointing to the key/value pair just to the left of the pointed-to edge. /// This is unsafe because the handle might point to the first edge in the node, which has no /// pair to its left. - unsafe fn left_kv<'a>(&'a mut self) -> Handle<&'a mut Node, KV, NodeType> { + unsafe fn left_kv<'a>(&'a mut self) -> Handle<&'a mut Node, handle::KV, NodeType> { Handle { node: &mut *self.node, index: self.index - 1 @@ -808,7 +812,7 @@ impl>, NodeType> Handle(&'a mut self) -> Handle<&'a mut Node, KV, NodeType> { + unsafe fn right_kv<'a>(&'a mut self) -> Handle<&'a mut Node, handle::KV, NodeType> { Handle { node: &mut *self.node, index: self.index @@ -816,7 +820,7 @@ impl>, NodeType> Handle Handle<&'a Node, KV, NodeType> { +impl<'a, K: 'a, V: 'a, NodeType> Handle<&'a Node, handle::KV, NodeType> { /// Turns the handle into references to the key and value it points at. This is necessary /// because the returned pointers have larger lifetimes than what would be returned by `key` /// or `val`. @@ -831,7 +835,7 @@ impl<'a, K: 'a, V: 'a, NodeType> Handle<&'a Node, KV, NodeType> { } } -impl<'a, K: 'a, V: 'a, NodeType> Handle<&'a mut Node, KV, NodeType> { +impl<'a, K: 'a, V: 'a, NodeType> Handle<&'a mut Node, handle::KV, NodeType> { /// Turns the handle into mutable references to the key and value it points at. This is /// necessary because the returned pointers have larger lifetimes than what would be returned /// by `key_mut` or `val_mut`. @@ -848,7 +852,7 @@ impl<'a, K: 'a, V: 'a, NodeType> Handle<&'a mut Node, KV, NodeType> { /// Convert this handle into one pointing at the edge immediately to the left of the key/value /// pair pointed-to by this handle. This is useful because it returns a reference with larger /// lifetime than `left_edge`. - pub fn into_left_edge(self) -> Handle<&'a mut Node, Edge, NodeType> { + pub fn into_left_edge(self) -> Handle<&'a mut Node, handle::Edge, NodeType> { Handle { node: &mut *self.node, index: self.index @@ -856,7 +860,8 @@ impl<'a, K: 'a, V: 'a, NodeType> Handle<&'a mut Node, KV, NodeType> { } } -impl<'a, K: 'a, V: 'a, NodeRef: Deref> + 'a, NodeType> Handle { +impl<'a, K: 'a, V: 'a, NodeRef: Deref> + 'a, NodeType> Handle { // These are fine to include, but are currently unneeded. // // /// Returns a reference to the key pointed-to by this handle. This doesn't return a @@ -874,7 +879,8 @@ impl<'a, K: 'a, V: 'a, NodeRef: Deref> + 'a, NodeType> Handle> + 'a, NodeType> Handle { +impl<'a, K: 'a, V: 'a, NodeRef: DerefMut> + 'a, NodeType> Handle { /// Returns a mutable reference to the key pointed-to by this handle. This doesn't return a /// reference with a lifetime as large as `into_kv_mut`, but it also does not consume the /// handle. @@ -890,10 +896,10 @@ impl<'a, K: 'a, V: 'a, NodeRef: DerefMut> + 'a, NodeType> Handle>, NodeType> Handle { +impl>, NodeType> Handle { /// Gets the handle pointing to the edge immediately to the left of the key/value pair pointed /// to by this handle. - pub fn left_edge<'a>(&'a mut self) -> Handle<&'a mut Node, Edge, NodeType> { + pub fn left_edge<'a>(&'a mut self) -> Handle<&'a mut Node, handle::Edge, NodeType> { Handle { node: &mut *self.node, index: self.index @@ -902,7 +908,7 @@ impl>, NodeType> Handle(&'a mut self) -> Handle<&'a mut Node, Edge, NodeType> { + pub fn right_edge<'a>(&'a mut self) -> Handle<&'a mut Node, handle::Edge, NodeType> { Handle { node: &mut *self.node, index: self.index + 1 @@ -910,7 +916,7 @@ impl>, NodeType> Handle>> Handle { +impl>> Handle { /// Removes the key/value pair at the handle's location. /// /// # Panics (in debug build) @@ -921,7 +927,7 @@ impl>> Handle { } } -impl>> Handle { +impl>> Handle { /// Steal! Stealing is roughly analogous to a binary tree rotation. /// In this case, we're "rotating" right. unsafe fn steal_rightward(&mut self) { @@ -1004,7 +1010,8 @@ impl Node { /// # Panics (in debug build) /// /// Panics if the given index is out of bounds. - pub fn kv_handle(&mut self, index: uint) -> Handle<&mut Node, KV, LeafOrInternal> { + pub fn kv_handle(&mut self, index: uint) -> Handle<&mut Node, handle::KV, + handle::LeafOrInternal> { // Necessary for correctness, but in a private module debug_assert!(index < self.len(), "kv_handle index out of bounds"); Handle { diff --git a/src/libcollections/btree/set.rs b/src/libcollections/btree/set.rs index 4ef2e681992..890d9be39f9 100644 --- a/src/libcollections/btree/set.rs +++ b/src/libcollections/btree/set.rs @@ -726,7 +726,7 @@ impl<'a, T: Ord> Iterator<&'a T> for UnionItems<'a, T> { #[cfg(test)] mod test { - use std::prelude::*; + use prelude::*; use super::BTreeSet; use std::hash; diff --git a/src/libcollections/dlist.rs b/src/libcollections/dlist.rs index e7454aef51e..4d7ce92b549 100644 --- a/src/libcollections/dlist.rs +++ b/src/libcollections/dlist.rs @@ -788,14 +788,14 @@ impl> Hash for DList { #[cfg(test)] mod tests { - use std::prelude::*; + use prelude::*; use std::rand; use std::hash; + use std::task::spawn; use test::Bencher; use test; use super::{DList, Node, ListInsertion}; - use vec::Vec; pub fn check_links(list: &DList) { let mut len = 0u; diff --git a/src/libcollections/enum_set.rs b/src/libcollections/enum_set.rs index caa2051c3f9..ed7516fec16 100644 --- a/src/libcollections/enum_set.rs +++ b/src/libcollections/enum_set.rs @@ -295,9 +295,9 @@ impl Extend for EnumSet { #[cfg(test)] mod test { - use std::prelude::*; use self::Foo::*; - use std::mem; + use prelude::*; + use core::mem; use super::{EnumSet, CLike}; diff --git a/src/libcollections/lib.rs b/src/libcollections/lib.rs index a8eb10e5163..75d179319f7 100644 --- a/src/libcollections/lib.rs +++ b/src/libcollections/lib.rs @@ -23,7 +23,7 @@ #![allow(unknown_features)] #![feature(macro_rules, default_type_params, phase, globs)] -#![feature(unsafe_destructor, import_shadowing, slicing_syntax)] +#![feature(unsafe_destructor, slicing_syntax)] #![feature(unboxed_closures)] #![no_std] @@ -95,3 +95,41 @@ mod std { pub use core::kinds; // deriving(Copy) pub use core::hash; // deriving(Hash) } + +#[cfg(test)] +mod prelude { + // from core. + pub use core::borrow::IntoCow; + pub use core::char::Char; + pub use core::clone::Clone; + pub use core::cmp::{PartialEq, Eq, Equiv, PartialOrd, Ord}; + pub use core::cmp::Ordering::{Less, Equal, Greater}; + pub use core::iter::range; + pub use core::iter::{FromIterator, Extend, IteratorExt}; + pub use core::iter::{Iterator, DoubleEndedIterator, RandomAccessIterator}; + pub use core::iter::{IteratorCloneExt, CloneIteratorExt, DoubleEndedIteratorExt}; + pub use core::iter::{IteratorOrdExt, MutableDoubleEndedIterator, ExactSizeIterator}; + pub use core::kinds::{Copy, Send, Sized, Sync}; + pub use core::mem::drop; + pub use core::ops::{Drop, Fn, FnMut, FnOnce}; + pub use core::option::Option; + pub use core::option::Option::{Some, None}; + pub use core::ptr::RawPtr; + pub use core::result::Result; + pub use core::result::Result::{Ok, Err}; + + // in core and collections (may differ). + pub use slice::{PartialEqSliceExt, OrdSliceExt}; + pub use slice::{AsSlice, SliceExt}; + pub use str::{from_str, Str, StrPrelude}; + + // from other crates. + pub use alloc::boxed::Box; + pub use unicode::char::UnicodeChar; + + // from collections. + pub use slice::{CloneSliceExt, VectorVector}; + pub use str::{IntoMaybeOwned, UnicodeStrPrelude, StrAllocating, StrVector}; + pub use string::{String, ToString}; + pub use vec::Vec; +} diff --git a/src/libcollections/ring_buf.rs b/src/libcollections/ring_buf.rs index cdb92d302e9..b0228593923 100644 --- a/src/libcollections/ring_buf.rs +++ b/src/libcollections/ring_buf.rs @@ -1260,18 +1260,17 @@ impl fmt::Show for RingBuf { #[cfg(test)] mod tests { - use core::iter; use self::Taggy::*; use self::Taggypar::*; - use std::cmp; + use prelude::*; + use core::cmp; + use core::iter; use std::fmt::Show; - use std::prelude::*; use std::hash; use test::Bencher; use test; use super::RingBuf; - use vec::Vec; #[test] #[allow(deprecated)] @@ -1791,7 +1790,7 @@ mod tests { #[test] fn test_from_iter() { - use std::iter; + use core::iter; let v = vec!(1i,2,3,4,5,6,7); let deq: RingBuf = v.iter().map(|&x| x).collect(); let u: Vec = deq.iter().map(|&x| x).collect(); diff --git a/src/libcollections/slice.rs b/src/libcollections/slice.rs index 3bf10192e59..16adf6fa224 100644 --- a/src/libcollections/slice.rs +++ b/src/libcollections/slice.rs @@ -1343,16 +1343,13 @@ pub mod raw { #[cfg(test)] mod tests { use std::boxed::Box; - use std::cell::Cell; - use std::default::Default; - use std::mem; - use std::prelude::*; + use prelude::*; + use core::cell::Cell; + use core::default::Default; + use core::mem; use std::rand::{Rng, task_rng}; use std::rc::Rc; - use std::rt; - use slice::*; - - use vec::Vec; + use super::ElementSwaps; fn square(n: uint) -> uint { n * n } @@ -2764,14 +2761,12 @@ mod tests { #[cfg(test)] mod bench { - use std::prelude::*; + use prelude::*; + use core::mem; + use core::ptr; use std::rand::{weak_rng, Rng}; - use std::mem; - use std::ptr; use test::{Bencher, black_box}; - use vec::Vec; - #[bench] fn iterator(b: &mut Bencher) { // peculiar numbers to stop LLVM from optimising the summation diff --git a/src/libcollections/str.rs b/src/libcollections/str.rs index 9ac5f04efe5..feec2a216c7 100644 --- a/src/libcollections/str.rs +++ b/src/libcollections/str.rs @@ -51,18 +51,21 @@ #![doc(primitive = "str")] -use core::prelude::*; - pub use self::MaybeOwned::*; use self::RecompositionState::*; use self::DecompositionType::*; use core::borrow::{BorrowFrom, Cow, ToOwned}; +use core::clone::Clone; use core::default::Default; use core::fmt; use core::hash; -use core::cmp; -use core::iter::AdditiveIterator; +use core::char::Char; +use core::cmp::{mod, Eq, Equiv, Ord, Ordering, PartialEq, PartialOrd}; +use core::iter::{range, AdditiveIterator, Iterator, IteratorExt}; +use core::kinds::Sized; +use core::option::Option::{mod, Some, None}; +use core::slice::{AsSlice, SliceExt}; use ring_buf::RingBuf; use string::String; @@ -834,25 +837,12 @@ impl<'a> StrAllocating for &'a str { #[cfg(test)] mod tests { - use std::iter::AdditiveIterator; - use std::iter::range; - use std::default::Default; - use std::char::Char; - use std::clone::Clone; - use std::cmp::{Ord, PartialOrd, Equiv}; - use std::cmp::Ordering::{Equal, Greater, Less}; - use std::option::Option; - use std::option::Option::{Some, None}; - use std::ptr::RawPtr; - use std::iter::{Iterator, IteratorExt, DoubleEndedIteratorExt}; - - use super::*; - use std::slice::{AsSlice, SliceExt}; - use string::String; - use vec::Vec; - use slice::CloneSliceExt; - - use unicode::char::UnicodeChar; + use prelude::*; + use core::default::Default; + use core::iter::AdditiveIterator; + use super::{eq_slice, from_utf8, is_utf8, is_utf16, raw}; + use super::truncate_utf16_at_nul; + use super::{Owned, Slice}; #[test] fn test_eq_slice() { @@ -1826,7 +1816,7 @@ mod tests { #[test] fn test_lev_distance() { - use std::char::{ from_u32, MAX }; + use core::char::{ from_u32, MAX }; // Test bytelength agnosticity for c in range(0u32, MAX as u32) .filter_map(|i| from_u32(i)) @@ -1936,7 +1926,7 @@ mod tests { #[test] fn test_graphemes() { - use std::iter::order; + use core::iter::order; // official Unicode test data // from http://www.unicode.org/Public/UCD/latest/ucd/auxiliary/GraphemeBreakTest.txt let test_same: [(_, &[_]), .. 325] = [ @@ -2367,7 +2357,7 @@ mod tests { #[test] fn test_str_default() { - use std::default::Default; + use core::default::Default; fn t() { let s: S = Default::default(); assert_eq!(s.as_slice(), ""); @@ -2467,12 +2457,10 @@ mod tests { #[cfg(test)] mod bench { + use prelude::*; use test::Bencher; use test::black_box; use super::*; - use std::iter::{IteratorExt, DoubleEndedIteratorExt}; - use std::str::StrPrelude; - use std::slice::SliceExt; #[bench] fn char_iterator(b: &mut Bencher) { diff --git a/src/libcollections/string.rs b/src/libcollections/string.rs index 38ebd686ddb..bcd1e3b3680 100644 --- a/src/libcollections/string.rs +++ b/src/libcollections/string.rs @@ -1040,14 +1040,11 @@ pub mod raw { #[cfg(test)] mod tests { - use std::prelude::*; + use prelude::*; use test::Bencher; - use slice::CloneSliceExt; - use str::{Str, StrPrelude}; use str; - use super::{as_string, String, ToString}; - use vec::Vec; + use super::as_string; #[test] fn test_as_string() { diff --git a/src/libcollections/vec.rs b/src/libcollections/vec.rs index e986b204430..e0745a86d71 100644 --- a/src/libcollections/vec.rs +++ b/src/libcollections/vec.rs @@ -54,7 +54,6 @@ use core::default::Default; use core::fmt; use core::hash::{mod, Hash}; use core::kinds::marker::{ContravariantLifetime, InvariantType}; -use core::kinds::Sized; use core::mem; use core::num::{Int, UnsignedInt}; use core::ops; @@ -1806,12 +1805,10 @@ impl<'a> fmt::FormatWriter for Vec { #[cfg(test)] mod tests { - extern crate test; - - use std::prelude::*; - use std::mem::size_of; + use prelude::*; + use core::mem::size_of; use test::Bencher; - use super::{as_vec, unzip, raw, Vec}; + use super::{as_vec, unzip, raw}; struct DropCounter<'a> { count: &'a mut int diff --git a/src/libcollections/vec_map.rs b/src/libcollections/vec_map.rs index 8faa9c1c522..1babde6066d 100644 --- a/src/libcollections/vec_map.rs +++ b/src/libcollections/vec_map.rs @@ -21,7 +21,6 @@ use core::hash::{Hash, Writer}; use core::iter; use core::iter::{Enumerate, FilterMap, Map}; use core::mem::replace; -use core::ops::FnOnce; use {vec, slice}; use vec::Vec; @@ -673,8 +672,7 @@ impl DoubleEndedIterator<(uint, V)> for MoveItems { #[cfg(test)] mod test_map { - use std::prelude::*; - use vec::Vec; + use prelude::*; use core::hash::hash; use super::VecMap; @@ -1047,8 +1045,7 @@ mod test_map { #[cfg(test)] mod bench { - extern crate test; - use self::test::Bencher; + use test::Bencher; use super::VecMap; use bench::{insert_rand_n, insert_seq_n, find_rand_n, find_seq_n}; diff --git a/src/libcore/hash/sip.rs b/src/libcore/hash/sip.rs index e10f5a9fed1..bdc210f0d8e 100644 --- a/src/libcore/hash/sip.rs +++ b/src/libcore/hash/sip.rs @@ -271,14 +271,9 @@ pub fn hash_with_keys>(k0: u64, k1: u64, value: &T) -> #[cfg(test)] mod tests { use test::Bencher; - use std::prelude::*; + use prelude::*; use std::fmt; - use str::Str; - use string::String; - use slice::{AsSlice, SliceExt}; - use vec::Vec; - use super::super::{Hash, Writer}; use super::{SipState, hash, hash_with_keys}; diff --git a/src/libfmt_macros/lib.rs b/src/libfmt_macros/lib.rs index 3099bf559e4..106e467c169 100644 --- a/src/libfmt_macros/lib.rs +++ b/src/libfmt_macros/lib.rs @@ -23,7 +23,7 @@ html_root_url = "http://doc.rust-lang.org/nightly/", html_playground_url = "http://play.rust-lang.org/")] -#![feature(macro_rules, globs, import_shadowing)] +#![feature(macro_rules, globs)] pub use self::Piece::*; pub use self::Position::*; pub use self::Alignment::*; diff --git a/src/libgetopts/lib.rs b/src/libgetopts/lib.rs index b45d0c9b01e..e362c67cc50 100644 --- a/src/libgetopts/lib.rs +++ b/src/libgetopts/lib.rs @@ -86,7 +86,6 @@ html_root_url = "http://doc.rust-lang.org/nightly/", html_playground_url = "http://play.rust-lang.org/")] #![feature(globs, phase)] -#![feature(import_shadowing)] #![feature(unboxed_closures)] #![deny(missing_docs)] diff --git a/src/librustc/lib.rs b/src/librustc/lib.rs index 669a5144970..463dcddaf94 100644 --- a/src/librustc/lib.rs +++ b/src/librustc/lib.rs @@ -22,7 +22,7 @@ html_favicon_url = "http://www.rust-lang.org/favicon.ico", html_root_url = "http://doc.rust-lang.org/nightly/")] -#![feature(default_type_params, globs, import_shadowing, macro_rules, phase, quote)] +#![feature(default_type_params, globs, macro_rules, phase, quote)] #![feature(slicing_syntax, unsafe_destructor)] #![feature(rustc_diagnostic_macros)] #![feature(unboxed_closures)] diff --git a/src/librustc/middle/check_match.rs b/src/librustc/middle/check_match.rs index 79e776c3308..2dc0d87c546 100644 --- a/src/librustc/middle/check_match.rs +++ b/src/librustc/middle/check_match.rs @@ -22,7 +22,7 @@ use middle::expr_use_visitor as euv; use middle::mem_categorization::cmt; use middle::pat_util::*; use middle::ty::*; -use middle::ty::{mod, Ty}; +use middle::ty; use std::fmt; use std::iter::AdditiveIterator; use std::iter::range_inclusive; diff --git a/src/librustc_borrowck/borrowck/move_data.rs b/src/librustc_borrowck/borrowck/move_data.rs index d033fd808aa..5d2faa52f1a 100644 --- a/src/librustc_borrowck/borrowck/move_data.rs +++ b/src/librustc_borrowck/borrowck/move_data.rs @@ -14,8 +14,6 @@ pub use self::MoveKind::*; use borrowck::*; -use borrowck::LoanPathKind::{LpVar, LpUpvar, LpDowncast, LpExtend}; -use borrowck::LoanPathElem::{LpInterior}; use rustc::middle::cfg; use rustc::middle::dataflow::DataFlowContext; use rustc::middle::dataflow::BitwiseOperator; diff --git a/src/librustc_borrowck/lib.rs b/src/librustc_borrowck/lib.rs index ffc5a3919b6..e71e9e5dfea 100644 --- a/src/librustc_borrowck/lib.rs +++ b/src/librustc_borrowck/lib.rs @@ -16,7 +16,7 @@ html_favicon_url = "http://www.rust-lang.org/favicon.ico", html_root_url = "http://doc.rust-lang.org/nightly/")] -#![feature(default_type_params, globs, import_shadowing, macro_rules, phase, quote)] +#![feature(default_type_params, globs, macro_rules, phase, quote)] #![feature(slicing_syntax, unsafe_destructor)] #![feature(rustc_diagnostic_macros)] #![feature(unboxed_closures)] diff --git a/src/librustc_driver/lib.rs b/src/librustc_driver/lib.rs index 34d9fd6bcad..7c8ed7335f1 100644 --- a/src/librustc_driver/lib.rs +++ b/src/librustc_driver/lib.rs @@ -22,7 +22,7 @@ html_favicon_url = "http://www.rust-lang.org/favicon.ico", html_root_url = "http://doc.rust-lang.org/nightly/")] -#![feature(default_type_params, globs, import_shadowing, macro_rules, phase, quote)] +#![feature(default_type_params, globs, macro_rules, phase, quote)] #![feature(slicing_syntax, unsafe_destructor)] #![feature(rustc_diagnostic_macros)] #![feature(unboxed_closures)] diff --git a/src/librustc_trans/lib.rs b/src/librustc_trans/lib.rs index 05b1a86b72b..784002287b7 100644 --- a/src/librustc_trans/lib.rs +++ b/src/librustc_trans/lib.rs @@ -22,7 +22,7 @@ html_favicon_url = "http://www.rust-lang.org/favicon.ico", html_root_url = "http://doc.rust-lang.org/nightly/")] -#![feature(default_type_params, globs, import_shadowing, macro_rules, phase, quote)] +#![feature(default_type_params, globs, macro_rules, phase, quote)] #![feature(slicing_syntax, unsafe_destructor)] #![feature(rustc_diagnostic_macros)] #![feature(unboxed_closures)] diff --git a/src/librustc_trans/trans/callee.rs b/src/librustc_trans/trans/callee.rs index 3376479b7a4..1a753901f7e 100644 --- a/src/librustc_trans/trans/callee.rs +++ b/src/librustc_trans/trans/callee.rs @@ -487,7 +487,7 @@ pub fn trans_fn_ref_with_substs<'blk, 'tcx>( let opt_ref_id = match node { ExprId(id) => if id != 0 { Some(id) } else { None }, - MethodCall(_) => None, + MethodCallKey(_) => None, }; let (val, must_cast) = @@ -498,7 +498,7 @@ pub fn trans_fn_ref_with_substs<'blk, 'tcx>( // are subst'd) let ref_ty = match node { ExprId(id) => node_id_type(bcx, id), - MethodCall(method_call) => { + MethodCallKey(method_call) => { let t = (*bcx.tcx().method_map.borrow())[method_call].ty; monomorphize_type(bcx, t) } diff --git a/src/librustc_trans/trans/common.rs b/src/librustc_trans/trans/common.rs index 4dd4e27c9c0..09a4bdcefc5 100644 --- a/src/librustc_trans/trans/common.rs +++ b/src/librustc_trans/trans/common.rs @@ -867,7 +867,7 @@ pub enum ExprOrMethodCall { ExprId(ast::NodeId), // Type parameters for a method call like `a.foo::()` - MethodCall(ty::MethodCall) + MethodCallKey(ty::MethodCall) } pub fn node_id_substs<'blk, 'tcx>(bcx: Block<'blk, 'tcx>, @@ -879,7 +879,7 @@ pub fn node_id_substs<'blk, 'tcx>(bcx: Block<'blk, 'tcx>, ExprId(id) => { ty::node_id_item_substs(tcx, id).substs } - MethodCall(method_call) => { + MethodCallKey(method_call) => { (*tcx.method_map.borrow())[method_call].substs.clone() } }; diff --git a/src/librustc_trans/trans/controlflow.rs b/src/librustc_trans/trans/controlflow.rs index a1574aa2f0e..211f8a1f420 100644 --- a/src/librustc_trans/trans/controlflow.rs +++ b/src/librustc_trans/trans/controlflow.rs @@ -8,7 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -use llvm::*; +use llvm::ValueRef; use middle::def; use middle::lang_items::{PanicFnLangItem, PanicBoundsCheckFnLangItem}; use trans::_match; diff --git a/src/librustc_trans/trans/meth.rs b/src/librustc_trans/trans/meth.rs index f1c3c9be396..15f6d7bc3f4 100644 --- a/src/librustc_trans/trans/meth.rs +++ b/src/librustc_trans/trans/meth.rs @@ -124,7 +124,7 @@ pub fn trans_method_callee<'blk, 'tcx>(bcx: Block<'blk, 'tcx>, bcx: bcx, data: Fn(callee::trans_fn_ref(bcx, did, - MethodCall(method_call))), + MethodCallKey(method_call))), } } @@ -344,12 +344,12 @@ fn trans_monomorphized_callee<'blk, 'tcx>(bcx: Block<'blk, 'tcx>, // those from the impl and those from the method: let callee_substs = combine_impl_and_methods_tps( - bcx, MethodCall(method_call), vtable_impl.substs); + bcx, MethodCallKey(method_call), vtable_impl.substs); // translate the function let llfn = trans_fn_ref_with_substs(bcx, mth_id, - MethodCall(method_call), + MethodCallKey(method_call), callee_substs); Callee { bcx: bcx, data: Fn(llfn) } @@ -359,7 +359,7 @@ fn trans_monomorphized_callee<'blk, 'tcx>(bcx: Block<'blk, 'tcx>, // after passing through fulfill_obligation let llfn = trans_fn_ref_with_substs(bcx, closure_def_id, - MethodCall(method_call), + MethodCallKey(method_call), substs); Callee { diff --git a/src/librustc_typeck/lib.rs b/src/librustc_typeck/lib.rs index ec0313d4d8f..49c5f13fa73 100644 --- a/src/librustc_typeck/lib.rs +++ b/src/librustc_typeck/lib.rs @@ -71,7 +71,7 @@ This API is completely unstable and subject to change. html_favicon_url = "http://www.rust-lang.org/favicon.ico", html_root_url = "http://doc.rust-lang.org/nightly/")] -#![feature(default_type_params, globs, import_shadowing, macro_rules, phase, quote)] +#![feature(default_type_params, globs, macro_rules, phase, quote)] #![feature(slicing_syntax, unsafe_destructor)] #![feature(rustc_diagnostic_macros)] #![feature(unboxed_closures)] diff --git a/src/libstd/ascii.rs b/src/libstd/ascii.rs index 2c4dc5313bb..08b17f25e29 100644 --- a/src/libstd/ascii.rs +++ b/src/libstd/ascii.rs @@ -633,7 +633,6 @@ mod tests { use prelude::*; use super::*; use char::from_u32; - use str::StrPrelude; macro_rules! v2ascii { ( [$($e:expr),*]) => (&[$(Ascii{chr:$e}),*]); diff --git a/src/libstd/bitflags.rs b/src/libstd/bitflags.rs index f467b77dbf4..c7cf0b5bc8e 100644 --- a/src/libstd/bitflags.rs +++ b/src/libstd/bitflags.rs @@ -315,7 +315,6 @@ macro_rules! bitflags { #[cfg(test)] #[allow(non_upper_case_globals)] mod tests { - use kinds::Copy; use hash; use option::Option::{Some, None}; use ops::{BitOr, BitAnd, BitXor, Sub, Not}; diff --git a/src/libstd/c_str.rs b/src/libstd/c_str.rs index 8fe3642e702..f1c8e8950a2 100644 --- a/src/libstd/c_str.rs +++ b/src/libstd/c_str.rs @@ -67,18 +67,18 @@ //! } //! ``` -use string::String; -use hash; +use core::prelude::*; +use libc; + use fmt; +use hash; use kinds::marker; use mem; -use core::prelude::*; - use ptr; -use raw::Slice; -use slice; +use slice::{mod, ImmutableIntSlice}; use str; -use libc; +use string::String; + /// The representation of a C String. /// @@ -210,7 +210,7 @@ impl CString { #[inline] pub fn as_bytes<'a>(&'a self) -> &'a [u8] { unsafe { - mem::transmute(Slice { data: self.buf, len: self.len() + 1 }) + slice::from_raw_buf(&self.buf, self.len() + 1).as_unsigned() } } @@ -219,7 +219,7 @@ impl CString { #[inline] pub fn as_bytes_no_nul<'a>(&'a self) -> &'a [u8] { unsafe { - mem::transmute(Slice { data: self.buf, len: self.len() }) + slice::from_raw_buf(&self.buf, self.len()).as_unsigned() } } diff --git a/src/libstd/collections/hash/map.rs b/src/libstd/collections/hash/map.rs index 6bfea7e3cb2..d068c4610be 100644 --- a/src/libstd/collections/hash/map.rs +++ b/src/libstd/collections/hash/map.rs @@ -1428,9 +1428,8 @@ mod test_map { use super::HashMap; use super::{Occupied, Vacant}; - use cmp::Equiv; use hash; - use iter::{Iterator,range_inclusive,range_step_inclusive}; + use iter::{range_inclusive, range_step_inclusive}; use cell::RefCell; use rand::{weak_rng, Rng}; diff --git a/src/libstd/collections/hash/set.rs b/src/libstd/collections/hash/set.rs index 67c0f887832..71cc4a1e5a6 100644 --- a/src/libstd/collections/hash/set.rs +++ b/src/libstd/collections/hash/set.rs @@ -678,7 +678,6 @@ mod test_set { use prelude::*; use super::HashSet; - use slice::PartialEqSliceExt; #[test] fn test_disjoint() { diff --git a/src/libstd/dynamic_lib.rs b/src/libstd/dynamic_lib.rs index 291f384d619..e520c70824e 100644 --- a/src/libstd/dynamic_lib.rs +++ b/src/libstd/dynamic_lib.rs @@ -15,21 +15,10 @@ #![experimental] #![allow(missing_docs)] -use clone::Clone; -use c_str::ToCStr; -use iter::IteratorExt; +use prelude::*; use mem; -use ops::*; -use option::*; -use option::Option::{None, Some}; use os; -use path::{Path,GenericPath}; -use result::*; -use result::Result::{Err, Ok}; -use slice::{AsSlice,SliceExt}; use str; -use string::String; -use vec::Vec; #[allow(missing_copy_implementations)] pub struct DynamicLibrary { @@ -213,13 +202,10 @@ mod test { pub mod dl { pub use self::Rtld::*; - use c_str::{CString, ToCStr}; + use prelude::*; + use c_str::CString; use libc; - use ops::FnOnce; use ptr; - use result::*; - use result::Result::{Err, Ok}; - use string::String; pub unsafe fn open_external(filename: T) -> *mut u8 { filename.with_c_str(|raw_name| { diff --git a/src/libstd/io/buffered.rs b/src/libstd/io/buffered.rs index 25f05940807..9d9e8827571 100644 --- a/src/libstd/io/buffered.rs +++ b/src/libstd/io/buffered.rs @@ -409,7 +409,6 @@ mod test { use super::super::{IoResult, EndOfFile}; use super::super::mem::MemReader; use self::test::Bencher; - use str::StrPrelude; /// A type, free to create, primarily intended for benchmarking creation of /// wrappers that, just for construction, don't need a Reader/Writer that diff --git a/src/libstd/io/fs.rs b/src/libstd/io/fs.rs index fd3bae73cd3..4e736908c37 100644 --- a/src/libstd/io/fs.rs +++ b/src/libstd/io/fs.rs @@ -823,10 +823,6 @@ mod test { use io; use str; use io::fs::*; - use path::Path; - use io; - use ops::Drop; - use str::StrPrelude; macro_rules! check { ($e:expr) => ( match $e { diff --git a/src/libstd/io/mem.rs b/src/libstd/io/mem.rs index 71e8cb4b5ec..431e11cf9ca 100644 --- a/src/libstd/io/mem.rs +++ b/src/libstd/io/mem.rs @@ -398,13 +398,12 @@ impl<'a> Buffer for BufReader<'a> { #[cfg(test)] mod test { - extern crate test; + extern crate "test" as test_crate; use prelude::*; use super::*; use io::*; use io; - use self::test::Bencher; - use str::StrPrelude; + use self::test_crate::Bencher; #[test] fn test_vec_writer() { diff --git a/src/libstd/io/timer.rs b/src/libstd/io/timer.rs index 79048c37ab5..953effe4345 100644 --- a/src/libstd/io/timer.rs +++ b/src/libstd/io/timer.rs @@ -225,11 +225,11 @@ fn in_ms_u64(d: Duration) -> u64 { #[cfg(test)] mod test { - use super::*; - use time::Duration; - use task::spawn; use prelude::*; + use super::Timer; + use time::Duration; + #[test] fn test_io_timer_sleep_simple() { let mut timer = Timer::new().unwrap(); diff --git a/src/libstd/lib.rs b/src/libstd/lib.rs index 78c194745a8..7de3e1c961a 100644 --- a/src/libstd/lib.rs +++ b/src/libstd/lib.rs @@ -106,8 +106,7 @@ #![allow(unknown_features)] #![feature(macro_rules, globs, linkage, thread_local, asm)] #![feature(default_type_params, phase, lang_items, unsafe_destructor)] -#![feature(import_shadowing, slicing_syntax, tuple_indexing)] -#![feature(unboxed_closures)] +#![feature(slicing_syntax, unboxed_closures)] // Don't link to std. We are std. #![no_std] @@ -158,7 +157,7 @@ pub use core::unit; pub use core::result; pub use core::option; -pub use alloc::boxed; +#[cfg(not(test))] pub use alloc::boxed; pub use alloc::rc; pub use core_collections::slice; diff --git a/src/libstd/num/f32.rs b/src/libstd/num/f32.rs index 60b17de1718..d307e1f7415 100644 --- a/src/libstd/num/f32.rs +++ b/src/libstd/num/f32.rs @@ -349,7 +349,6 @@ pub fn to_str_exp_digits(num: f32, dig: uint, upper: bool) -> String { mod tests { use f32::*; use num::*; - use num; #[test] fn test_min_nan() { @@ -364,8 +363,8 @@ mod tests { } #[test] - fn test_num() { - num::test_num(10f32, 2f32); + fn test_num_f32() { + test_num(10f32, 2f32); } #[test] diff --git a/src/libstd/num/f64.rs b/src/libstd/num/f64.rs index 4b31e33236d..dfe20d59c82 100644 --- a/src/libstd/num/f64.rs +++ b/src/libstd/num/f64.rs @@ -357,7 +357,6 @@ pub fn to_str_exp_digits(num: f64, dig: uint, upper: bool) -> String { mod tests { use f64::*; use num::*; - use num; #[test] fn test_min_nan() { @@ -372,8 +371,8 @@ mod tests { } #[test] - fn test_num() { - num::test_num(10f64, 2f64); + fn test_num_f64() { + test_num(10f64, 2f64); } #[test] diff --git a/src/libstd/os.rs b/src/libstd/os.rs index dcc73f7844a..20a72f45fbf 100644 --- a/src/libstd/os.rs +++ b/src/libstd/os.rs @@ -1425,7 +1425,6 @@ mod arch_consts { #[cfg(test)] mod tests { use prelude::*; - use c_str::ToCStr; use option; use os::{env, getcwd, getenv, make_absolute}; use os::{split_paths, join_paths, setenv, unsetenv}; diff --git a/src/libstd/path/mod.rs b/src/libstd/path/mod.rs index 8f98329a4be..ed4bb6ee081 100644 --- a/src/libstd/path/mod.rs +++ b/src/libstd/path/mod.rs @@ -931,8 +931,6 @@ fn contains_nul(v: &T) -> bool { #[cfg(test)] mod tests { use prelude::*; - use super::{GenericPath, PosixPath, WindowsPath}; - use c_str::ToCStr; #[test] fn test_cstring() { diff --git a/src/libstd/path/posix.rs b/src/libstd/path/posix.rs index 62f64159c04..88907951673 100644 --- a/src/libstd/path/posix.rs +++ b/src/libstd/path/posix.rs @@ -445,7 +445,6 @@ mod tests { use prelude::*; use super::*; use str; - use str::StrPrelude; macro_rules! t { (s: $path:expr, $exp:expr) => ( diff --git a/src/libstd/rt/util.rs b/src/libstd/rt/util.rs index fa527a70f83..77500ca74d0 100644 --- a/src/libstd/rt/util.rs +++ b/src/libstd/rt/util.rs @@ -20,7 +20,6 @@ use core::str; use libc::{mod, uintptr_t}; use os; -use str::{FromStr, from_str, Str}; use sync::atomic; /// Dynamically inquire about whether we're running under V. @@ -66,7 +65,7 @@ pub fn min_stack() -> uint { pub fn default_sched_threads() -> uint { match os::getenv("RUST_THREADS") { Some(nstr) => { - let opt_n: Option = FromStr::from_str(nstr.as_slice()); + let opt_n: Option = from_str(nstr.as_slice()); match opt_n { Some(n) if n > 0 => n, _ => panic!("`RUST_THREADS` is `{}`, should be a positive integer", nstr) diff --git a/src/libstd/sync/future.rs b/src/libstd/sync/future.rs index 5e9d234c642..51899a87a32 100644 --- a/src/libstd/sync/future.rs +++ b/src/libstd/sync/future.rs @@ -153,7 +153,6 @@ mod test { use prelude::*; use sync::Future; use task; - use comm::channel; #[test] fn test_from_value() { diff --git a/src/libstd/sync/task_pool.rs b/src/libstd/sync/task_pool.rs index 793825f1b08..366e4b7d35b 100644 --- a/src/libstd/sync/task_pool.rs +++ b/src/libstd/sync/task_pool.rs @@ -131,10 +131,8 @@ fn spawn_in_pool(jobs: Arc>>) { #[cfg(test)] mod test { - use core::prelude::*; + use prelude::*; use super::*; - use comm::channel; - use iter::range; const TEST_TASKS: uint = 4u; diff --git a/src/libstd/sys/common/mutex.rs b/src/libstd/sys/common/mutex.rs index 117d33db328..1a8a92a105a 100644 --- a/src/libstd/sys/common/mutex.rs +++ b/src/libstd/sys/common/mutex.rs @@ -8,8 +8,6 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -pub use sys::mutex::raw; - use sys::mutex as imp; /// An OS-based mutual exclusion lock. diff --git a/src/libstd/sys/unix/fs.rs b/src/libstd/sys/unix/fs.rs index 66f7d85f20d..98d860f9646 100644 --- a/src/libstd/sys/unix/fs.rs +++ b/src/libstd/sys/unix/fs.rs @@ -18,14 +18,11 @@ use io; use prelude::*; use io::{FilePermission, Write, UnstableFileStat, Open, FileAccess, FileMode}; -use io::{IoResult, FileStat, SeekStyle, Reader}; +use io::{IoResult, FileStat, SeekStyle}; use io::{Read, Truncate, SeekCur, SeekSet, ReadWrite, SeekEnd, Append}; -use result::Result::{Ok, Err}; use sys::retry; use sys_common::{keep_going, eof, mkerr_libc}; -pub use path::PosixPath as Path; - pub type fd_t = libc::c_int; pub struct FileDesc { diff --git a/src/libstd/sys/unix/os.rs b/src/libstd/sys/unix/os.rs index 0ed079df55b..6c909d7562d 100644 --- a/src/libstd/sys/unix/os.rs +++ b/src/libstd/sys/unix/os.rs @@ -16,8 +16,8 @@ use error::{FromError, Error}; use fmt; use io::{IoError, IoResult}; use libc::{mod, c_int, c_char, c_void}; -use path::{Path, GenericPath, BytesContainer}; -use ptr::{mod, RawPtr}; +use path::BytesContainer; +use ptr; use sync::atomic::{AtomicInt, INIT_ATOMIC_INT, SeqCst}; use sys::fs::FileDesc; use os; diff --git a/src/libstd/sys/unix/tcp.rs b/src/libstd/sys/unix/tcp.rs index 00643ac0a79..dacd754582b 100644 --- a/src/libstd/sys/unix/tcp.rs +++ b/src/libstd/sys/unix/tcp.rs @@ -20,7 +20,7 @@ use sys::fs::FileDesc; use sys::{set_nonblocking, wouldblock}; use sys; use sys_common; -use sys_common::net::*; +use sys_common::net; pub use sys_common::net::TcpStream; @@ -34,17 +34,19 @@ pub struct TcpListener { impl TcpListener { pub fn bind(addr: ip::SocketAddr) -> IoResult { - let fd = try!(socket(addr, libc::SOCK_STREAM)); + let fd = try!(net::socket(addr, libc::SOCK_STREAM)); let ret = TcpListener { inner: FileDesc::new(fd, true) }; let mut storage = unsafe { mem::zeroed() }; - let len = addr_to_sockaddr(addr, &mut storage); + let len = net::addr_to_sockaddr(addr, &mut storage); let addrp = &storage as *const _ as *const libc::sockaddr; // On platforms with Berkeley-derived sockets, this allows // to quickly rebind a socket, without needing to wait for // the OS to clean up the previous one. - try!(setsockopt(fd, libc::SOL_SOCKET, libc::SO_REUSEADDR, 1 as libc::c_int)); + try!(net::setsockopt(fd, libc::SOL_SOCKET, + libc::SO_REUSEADDR, + 1 as libc::c_int)); match unsafe { libc::bind(fd, addrp, len) } { @@ -77,7 +79,7 @@ impl TcpListener { } pub fn socket_name(&mut self) -> IoResult { - sockname(self.fd(), libc::getsockname) + net::sockname(self.fd(), libc::getsockname) } } @@ -121,15 +123,15 @@ impl TcpAcceptor { -1 => return Err(last_net_error()), fd => return Ok(TcpStream::new(fd as sock_t)), } - try!(await(&[self.fd(), self.inner.reader.fd()], - deadline, Readable)); + try!(net::await(&[self.fd(), self.inner.reader.fd()], + deadline, net::Readable)); } Err(sys_common::eof()) } pub fn socket_name(&mut self) -> IoResult { - sockname(self.fd(), libc::getsockname) + net::sockname(self.fd(), libc::getsockname) } pub fn set_timeout(&mut self, timeout: Option) { diff --git a/src/libstd/sys/windows/condvar.rs b/src/libstd/sys/windows/condvar.rs index 3cabf3a6319..7f9d669c447 100644 --- a/src/libstd/sys/windows/condvar.rs +++ b/src/libstd/sys/windows/condvar.rs @@ -10,7 +10,6 @@ use cell::UnsafeCell; use libc::{mod, DWORD}; -use libc; use os; use sys::mutex::{mod, Mutex}; use sys::sync as ffi; diff --git a/src/libstd/sys/windows/fs.rs b/src/libstd/sys/windows/fs.rs index 0fb52c758d5..d5bf8c5b629 100644 --- a/src/libstd/sys/windows/fs.rs +++ b/src/libstd/sys/windows/fs.rs @@ -26,10 +26,9 @@ use sys; use sys_common::{keep_going, eof, mkerr_libc}; use io::{FilePermission, Write, UnstableFileStat, Open, FileAccess, FileMode}; -use io::{IoResult, IoError, FileStat, SeekStyle, Seek, Writer, Reader}; +use io::{IoResult, IoError, FileStat, SeekStyle}; use io::{Read, Truncate, SeekCur, SeekSet, ReadWrite, SeekEnd, Append}; -pub use path::WindowsPath as Path; pub type fd_t = libc::c_int; pub struct FileDesc { diff --git a/src/libstd/sys/windows/os.rs b/src/libstd/sys/windows/os.rs index 2fbb9494c71..e2220b7b67b 100644 --- a/src/libstd/sys/windows/os.rs +++ b/src/libstd/sys/windows/os.rs @@ -20,12 +20,10 @@ use io::{IoResult, IoError}; use libc::{c_int, c_char, c_void}; use libc; use os; -use path::{Path, GenericPath, BytesContainer}; -use ptr::{mod, RawPtr}; +use path::BytesContainer; +use ptr; use sync::atomic::{AtomicInt, INIT_ATOMIC_INT, SeqCst}; use sys::fs::FileDesc; -use option::Option; -use option::Option::{Some, None}; use slice; use os::TMPBUF_SZ; diff --git a/src/libstd/sys/windows/process.rs b/src/libstd/sys/windows/process.rs index bbfd32ee76b..8945c155e66 100644 --- a/src/libstd/sys/windows/process.rs +++ b/src/libstd/sys/windows/process.rs @@ -29,7 +29,6 @@ use sys_common::helper_thread::Helper; use sys_common::{AsInner, mkerr_libc, timeout}; use io::fs::PathExtensions; -use string::String; pub use sys_common::ProcessConfig; diff --git a/src/libstd/sys/windows/tcp.rs b/src/libstd/sys/windows/tcp.rs index b577372d2fc..505e6137bf9 100644 --- a/src/libstd/sys/windows/tcp.rs +++ b/src/libstd/sys/windows/tcp.rs @@ -18,8 +18,7 @@ use super::{last_error, last_net_error, retry, sock_t}; use sync::{Arc, atomic}; use sys::fs::FileDesc; use sys::{mod, c, set_nonblocking, wouldblock, timer}; -use sys_common::{mod, timeout, eof}; -use sys_common::net::*; +use sys_common::{mod, timeout, eof, net}; pub use sys_common::net::TcpStream; @@ -54,11 +53,11 @@ impl TcpListener { pub fn bind(addr: ip::SocketAddr) -> IoResult { sys::init_net(); - let sock = try!(socket(addr, libc::SOCK_STREAM)); + let sock = try!(net::socket(addr, libc::SOCK_STREAM)); let ret = TcpListener { sock: sock }; let mut storage = unsafe { mem::zeroed() }; - let len = addr_to_sockaddr(addr, &mut storage); + let len = net::addr_to_sockaddr(addr, &mut storage); let addrp = &storage as *const _ as *const libc::sockaddr; match unsafe { libc::bind(sock, addrp, len) } { @@ -95,7 +94,7 @@ impl TcpListener { } pub fn socket_name(&mut self) -> IoResult { - sockname(self.socket(), libc::getsockname) + net::sockname(self.socket(), libc::getsockname) } } @@ -195,7 +194,7 @@ impl TcpAcceptor { } pub fn socket_name(&mut self) -> IoResult { - sockname(self.socket(), libc::getsockname) + net::sockname(self.socket(), libc::getsockname) } pub fn set_timeout(&mut self, timeout: Option) { diff --git a/src/libstd/thread.rs b/src/libstd/thread.rs index 8ef53a22aeb..89773207347 100644 --- a/src/libstd/thread.rs +++ b/src/libstd/thread.rs @@ -124,13 +124,17 @@ //! //! * It can be implemented highly efficiently on many platforms. -use core::prelude::*; - use any::Any; use borrow::IntoCow; use boxed::Box; use cell::UnsafeCell; +use clone::Clone; +use kinds::Send; +use ops::{Drop, FnOnce}; +use option::Option::{mod, Some, None}; +use result::Result::{Err, Ok}; use sync::{Mutex, Condvar, Arc}; +use str::Str; use string::String; use rt::{mod, unwind}; use io::{Writer, stdio}; @@ -424,13 +428,11 @@ impl Drop for JoinGuard { #[cfg(test)] mod test { + use prelude::*; use any::{Any, AnyRefExt}; use boxed::BoxAny; - use prelude::*; - use result::Result::{Ok, Err}; use result; use std::io::{ChanReader, ChanWriter}; - use string::String; use thunk::Thunk; use super::{Thread, Builder}; diff --git a/src/libsyntax/lib.rs b/src/libsyntax/lib.rs index 5d5b56d444f..5f62c74ef07 100644 --- a/src/libsyntax/lib.rs +++ b/src/libsyntax/lib.rs @@ -24,7 +24,7 @@ #![allow(unknown_features)] #![feature(macro_rules, globs, default_type_params, phase, slicing_syntax)] -#![feature(quote, unsafe_destructor, import_shadowing)] +#![feature(quote, unsafe_destructor)] #![feature(unboxed_closures)] extern crate arena; diff --git a/src/libsyntax/parse/mod.rs b/src/libsyntax/parse/mod.rs index d6f5d0e248a..3d0877dd432 100644 --- a/src/libsyntax/parse/mod.rs +++ b/src/libsyntax/parse/mod.rs @@ -745,8 +745,7 @@ mod test { use owned_slice::OwnedSlice; use ast; use abi; - use attr; - use attr::AttrMetaMethods; + use attr::{first_attr_value_str_by_name, AttrMetaMethods}; use parse::parser::Parser; use parse::token::{str_to_ident}; use print::pprust::view_item_to_string; @@ -1195,7 +1194,7 @@ mod test { let name = "".to_string(); let source = "/// doc comment\r\nfn foo() {}".to_string(); let item = parse_item_from_source_str(name.clone(), source, Vec::new(), &sess).unwrap(); - let doc = attr::first_attr_value_str_by_name(item.attrs.as_slice(), "doc").unwrap(); + let doc = first_attr_value_str_by_name(item.attrs.as_slice(), "doc").unwrap(); assert_eq!(doc.get(), "/// doc comment"); let source = "/// doc comment\r\n/// line 2\r\nfn foo() {}".to_string(); @@ -1207,7 +1206,7 @@ mod test { let source = "/** doc comment\r\n * with CRLF */\r\nfn foo() {}".to_string(); let item = parse_item_from_source_str(name, source, Vec::new(), &sess).unwrap(); - let doc = attr::first_attr_value_str_by_name(item.attrs.as_slice(), "doc").unwrap(); + let doc = first_attr_value_str_by_name(item.attrs.as_slice(), "doc").unwrap(); assert_eq!(doc.get(), "/** doc comment\n * with CRLF */"); } }