Skip to content

Remove all uses of feature(import_shadowing). #19511

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Dec 20, 2014
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/libcollections/bench.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
3 changes: 1 addition & 2 deletions src/libcollections/binary_heap.rs
Original file line number Diff line number Diff line change
Expand Up @@ -617,10 +617,9 @@ impl<T: Ord> Extend<T> for BinaryHeap<T> {

#[cfg(test)]
mod tests {
use std::prelude::*;
use prelude::*;

use super::BinaryHeap;
use vec::Vec;

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yessss. use vec::Vec is my secret nemesis.

#[test]
fn test_iterator() {
Expand Down
9 changes: 4 additions & 5 deletions src/libcollections/bit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1686,16 +1686,15 @@ impl<'a> Iterator<uint> 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;

Expand Down Expand Up @@ -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);
}

Expand Down
27 changes: 15 additions & 12 deletions src/libcollections/btree/map.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<K: Ord, V> BTreeMap<K, V> {
Expand Down Expand Up @@ -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
Expand All @@ -520,7 +521,7 @@ mod stack {
}
}

type StackItem<K, V> = node::Handle<*mut Node<K, V>, Edge, Internal>;
type StackItem<K, V> = node::Handle<*mut Node<K, V>, handle::Edge, handle::Internal>;
type Stack<K, V> = Vec<StackItem<K, V>>;

/// A `PartialSearchStack` handles the construction of a search stack.
Expand Down Expand Up @@ -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<IdRef<'id, Node<K, V>>, Edge, Internal>)
pub fn push(mut self, mut edge: node::Handle<IdRef<'id, Node<K, V>>,
handle::Edge,
handle::Internal>)
-> PartialSearchStack<'a, K, V> {
self.stack.push(edge.as_raw());
PartialSearchStack {
Expand All @@ -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 }
Expand All @@ -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 {
Expand Down Expand Up @@ -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 {
Expand All @@ -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();
Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -1332,7 +1335,7 @@ impl<K: Ord, V> BTreeMap<K, V> {

#[cfg(test)]
mod test {
use std::prelude::*;
use prelude::*;

use super::{BTreeMap, Occupied, Vacant};

Expand Down Expand Up @@ -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};

Expand Down
65 changes: 36 additions & 29 deletions src/libcollections/btree/node.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,9 @@ pub enum InsertionResult<K, V> {
/// Represents the result of a search for a key in a single node
pub enum SearchResult<NodeRef> {
/// The element was found at the given index
Found(Handle<NodeRef, KV, LeafOrInternal>),
Found(Handle<NodeRef, handle::KV, handle::LeafOrInternal>),
/// The element wasn't found, but if it's anywhere, it must be beyond this edge
GoDown(Handle<NodeRef, Edge, LeafOrInternal>),
GoDown(Handle<NodeRef, handle::Edge, handle::LeafOrInternal>),
}

/// A B-Tree Node. We keep keys/edges/values separate to optimize searching for keys.
Expand Down Expand Up @@ -494,12 +494,16 @@ pub struct Handle<NodeRef, Type, NodeType> {
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<K: Ord, V> Node<K, V> {
/// Searches for the given key in the node. If it finds an exact match,
Expand Down Expand Up @@ -625,7 +629,7 @@ impl<K, V, Type, NodeType> Handle<*mut Node<K, V>, Type, NodeType> {
}
}

impl<'a, K: 'a, V: 'a> Handle<&'a Node<K, V>, Edge, Internal> {
impl<'a, K: 'a, V: 'a> Handle<&'a Node<K, V>, 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.
Expand All @@ -636,7 +640,7 @@ impl<'a, K: 'a, V: 'a> Handle<&'a Node<K, V>, Edge, Internal> {
}
}

impl<'a, K: 'a, V: 'a> Handle<&'a mut Node<K, V>, Edge, Internal> {
impl<'a, K: 'a, V: 'a> Handle<&'a mut Node<K, V>, 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.
Expand All @@ -647,7 +651,7 @@ impl<'a, K: 'a, V: 'a> Handle<&'a mut Node<K, V>, Edge, Internal> {
}
}

impl<K, V, NodeRef: Deref<Node<K, V>>> Handle<NodeRef, Edge, Internal> {
impl<K, V, NodeRef: Deref<Node<K, V>>> Handle<NodeRef, handle::Edge, handle::Internal> {
// This doesn't exist because there are no uses for it,
// but is fine to add, analagous to edge_mut.
//
Expand All @@ -657,11 +661,11 @@ impl<K, V, NodeRef: Deref<Node<K, V>>> Handle<NodeRef, Edge, Internal> {
}

pub enum ForceResult<NodeRef, Type> {
Leaf(Handle<NodeRef, Type, Leaf>),
Internal(Handle<NodeRef, Type, Internal>)
Leaf(Handle<NodeRef, Type, handle::Leaf>),
Internal(Handle<NodeRef, Type, handle::Internal>)
}

impl<K, V, NodeRef: Deref<Node<K, V>>, Type> Handle<NodeRef, Type, LeafOrInternal> {
impl<K, V, NodeRef: Deref<Node<K, V>>, Type> Handle<NodeRef, Type, handle::LeafOrInternal> {
/// 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<NodeRef, Type> {
Expand All @@ -679,7 +683,7 @@ impl<K, V, NodeRef: Deref<Node<K, V>>, Type> Handle<NodeRef, Type, LeafOrInterna
}
}

impl<K, V, NodeRef: DerefMut<Node<K, V>>> Handle<NodeRef, Edge, Leaf> {
impl<K, V, NodeRef: DerefMut<Node<K, V>>> Handle<NodeRef, handle::Edge, handle::Leaf> {
/// 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.
///
Expand Down Expand Up @@ -711,7 +715,7 @@ impl<K, V, NodeRef: DerefMut<Node<K, V>>> Handle<NodeRef, Edge, Leaf> {
}
}

impl<K, V, NodeRef: DerefMut<Node<K, V>>> Handle<NodeRef, Edge, Internal> {
impl<K, V, NodeRef: DerefMut<Node<K, V>>> Handle<NodeRef, handle::Edge, handle::Internal> {
/// 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<K, V> {
Expand Down Expand Up @@ -794,11 +798,11 @@ impl<K, V, NodeRef: DerefMut<Node<K, V>>> Handle<NodeRef, Edge, Internal> {
}
}

impl<K, V, NodeRef: DerefMut<Node<K, V>>, NodeType> Handle<NodeRef, Edge, NodeType> {
impl<K, V, NodeRef: DerefMut<Node<K, V>>, NodeType> Handle<NodeRef, handle::Edge, NodeType> {
/// 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<K, V>, KV, NodeType> {
unsafe fn left_kv<'a>(&'a mut self) -> Handle<&'a mut Node<K, V>, handle::KV, NodeType> {
Handle {
node: &mut *self.node,
index: self.index - 1
Expand All @@ -808,15 +812,15 @@ impl<K, V, NodeRef: DerefMut<Node<K, V>>, NodeType> Handle<NodeRef, Edge, NodeTy
/// Gets the handle pointing to the key/value pair just to the right of the pointed-to edge.
/// This is unsafe because the handle might point to the last edge in the node, which has no
/// pair to its right.
unsafe fn right_kv<'a>(&'a mut self) -> Handle<&'a mut Node<K, V>, KV, NodeType> {
unsafe fn right_kv<'a>(&'a mut self) -> Handle<&'a mut Node<K, V>, handle::KV, NodeType> {
Handle {
node: &mut *self.node,
index: self.index
}
}
}

impl<'a, K: 'a, V: 'a, NodeType> Handle<&'a Node<K, V>, KV, NodeType> {
impl<'a, K: 'a, V: 'a, NodeType> Handle<&'a Node<K, V>, 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`.
Expand All @@ -831,7 +835,7 @@ impl<'a, K: 'a, V: 'a, NodeType> Handle<&'a Node<K, V>, KV, NodeType> {
}
}

impl<'a, K: 'a, V: 'a, NodeType> Handle<&'a mut Node<K, V>, KV, NodeType> {
impl<'a, K: 'a, V: 'a, NodeType> Handle<&'a mut Node<K, V>, 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`.
Expand All @@ -848,15 +852,16 @@ impl<'a, K: 'a, V: 'a, NodeType> Handle<&'a mut Node<K, V>, 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<K, V>, Edge, NodeType> {
pub fn into_left_edge(self) -> Handle<&'a mut Node<K, V>, handle::Edge, NodeType> {
Handle {
node: &mut *self.node,
index: self.index
}
}
}

impl<'a, K: 'a, V: 'a, NodeRef: Deref<Node<K, V>> + 'a, NodeType> Handle<NodeRef, KV, NodeType> {
impl<'a, K: 'a, V: 'a, NodeRef: Deref<Node<K, V>> + 'a, NodeType> Handle<NodeRef, handle::KV,
NodeType> {
// 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
Expand All @@ -874,7 +879,8 @@ impl<'a, K: 'a, V: 'a, NodeRef: Deref<Node<K, V>> + 'a, NodeType> Handle<NodeRef
// }
}

impl<'a, K: 'a, V: 'a, NodeRef: DerefMut<Node<K, V>> + 'a, NodeType> Handle<NodeRef, KV, NodeType> {
impl<'a, K: 'a, V: 'a, NodeRef: DerefMut<Node<K, V>> + 'a, NodeType> Handle<NodeRef, handle::KV,
NodeType> {
/// 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.
Expand All @@ -890,10 +896,10 @@ impl<'a, K: 'a, V: 'a, NodeRef: DerefMut<Node<K, V>> + 'a, NodeType> Handle<Node
}
}

impl<K, V, NodeRef: DerefMut<Node<K, V>>, NodeType> Handle<NodeRef, KV, NodeType> {
impl<K, V, NodeRef: DerefMut<Node<K, V>>, NodeType> Handle<NodeRef, handle::KV, NodeType> {
/// 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<K, V>, Edge, NodeType> {
pub fn left_edge<'a>(&'a mut self) -> Handle<&'a mut Node<K, V>, handle::Edge, NodeType> {
Handle {
node: &mut *self.node,
index: self.index
Expand All @@ -902,15 +908,15 @@ impl<K, V, NodeRef: DerefMut<Node<K, V>>, NodeType> Handle<NodeRef, KV, NodeType

/// Gets the handle pointing to the edge immediately to the right of the key/value pair pointed
/// to by this handle.
pub fn right_edge<'a>(&'a mut self) -> Handle<&'a mut Node<K, V>, Edge, NodeType> {
pub fn right_edge<'a>(&'a mut self) -> Handle<&'a mut Node<K, V>, handle::Edge, NodeType> {
Handle {
node: &mut *self.node,
index: self.index + 1
}
}
}

impl<K, V, NodeRef: DerefMut<Node<K, V>>> Handle<NodeRef, KV, Leaf> {
impl<K, V, NodeRef: DerefMut<Node<K, V>>> Handle<NodeRef, handle::KV, handle::Leaf> {
/// Removes the key/value pair at the handle's location.
///
/// # Panics (in debug build)
Expand All @@ -921,7 +927,7 @@ impl<K, V, NodeRef: DerefMut<Node<K, V>>> Handle<NodeRef, KV, Leaf> {
}
}

impl<K, V, NodeRef: DerefMut<Node<K, V>>> Handle<NodeRef, KV, Internal> {
impl<K, V, NodeRef: DerefMut<Node<K, V>>> Handle<NodeRef, handle::KV, handle::Internal> {
/// Steal! Stealing is roughly analogous to a binary tree rotation.
/// In this case, we're "rotating" right.
unsafe fn steal_rightward(&mut self) {
Expand Down Expand Up @@ -1004,7 +1010,8 @@ impl<K, V> Node<K, V> {
/// # Panics (in debug build)
///
/// Panics if the given index is out of bounds.
pub fn kv_handle(&mut self, index: uint) -> Handle<&mut Node<K, V>, KV, LeafOrInternal> {
pub fn kv_handle(&mut self, index: uint) -> Handle<&mut Node<K, V>, handle::KV,
handle::LeafOrInternal> {
// Necessary for correctness, but in a private module
debug_assert!(index < self.len(), "kv_handle index out of bounds");
Handle {
Expand Down
2 changes: 1 addition & 1 deletion src/libcollections/btree/set.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
4 changes: 2 additions & 2 deletions src/libcollections/dlist.rs
Original file line number Diff line number Diff line change
Expand Up @@ -788,14 +788,14 @@ impl<S: Writer, A: Hash<S>> Hash<S> for DList<A> {

#[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<T>(list: &DList<T>) {
let mut len = 0u;
Expand Down
Loading