Skip to content

Commit 7537eb3

Browse files
committed
auto merge of #19511 : eddyb/rust/no-shadow, r=alexcrichton
r? @erickt
2 parents 1c2df5c + 64a4474 commit 7537eb3

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

59 files changed

+210
-240
lines changed

src/libcollections/bench.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
1010

11-
use std::prelude::*;
11+
use prelude::*;
1212
use std::rand;
1313
use std::rand::Rng;
1414
use test::Bencher;

src/libcollections/binary_heap.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -617,10 +617,9 @@ impl<T: Ord> Extend<T> for BinaryHeap<T> {
617617

618618
#[cfg(test)]
619619
mod tests {
620-
use std::prelude::*;
620+
use prelude::*;
621621

622622
use super::BinaryHeap;
623-
use vec::Vec;
624623

625624
#[test]
626625
fn test_iterator() {

src/libcollections/bit.rs

+4-5
Original file line numberDiff line numberDiff line change
@@ -1686,16 +1686,15 @@ impl<'a> Iterator<uint> for TwoBitPositions<'a> {
16861686

16871687
#[cfg(test)]
16881688
mod tests {
1689-
use std::prelude::*;
1690-
use std::iter::range_step;
1689+
use prelude::*;
1690+
use core::iter::range_step;
1691+
use core::u32;
16911692
use std::rand;
16921693
use std::rand::Rng;
1693-
use std::u32;
16941694
use test::{Bencher, black_box};
16951695

16961696
use super::{Bitv, BitvSet, from_fn, from_bytes};
16971697
use bitv;
1698-
use vec::Vec;
16991698

17001699
static BENCH_BITS : uint = 1 << 14;
17011700

@@ -2038,7 +2037,7 @@ mod tests {
20382037
#[test]
20392038
fn test_from_bytes() {
20402039
let bitv = from_bytes(&[0b10110110, 0b00000000, 0b11111111]);
2041-
let str = format!("{}{}{}", "10110110", "00000000", "11111111");
2040+
let str = concat!("10110110", "00000000", "11111111");
20422041
assert_eq!(bitv.to_string(), str);
20432042
}
20442043

src/libcollections/btree/map.rs

+15-12
Original file line numberDiff line numberDiff line change
@@ -131,12 +131,12 @@ pub enum Entry<'a, K:'a, V:'a> {
131131
/// A vacant Entry.
132132
pub struct VacantEntry<'a, K:'a, V:'a> {
133133
key: K,
134-
stack: stack::SearchStack<'a, K, V, node::Edge, node::Leaf>,
134+
stack: stack::SearchStack<'a, K, V, node::handle::Edge, node::handle::Leaf>,
135135
}
136136

137137
/// An occupied Entry.
138138
pub struct OccupiedEntry<'a, K:'a, V:'a> {
139-
stack: stack::SearchStack<'a, K, V, node::KV, node::LeafOrInternal>,
139+
stack: stack::SearchStack<'a, K, V, node::handle::KV, node::handle::LeafOrInternal>,
140140
}
141141

142142
impl<K: Ord, V> BTreeMap<K, V> {
@@ -496,7 +496,8 @@ mod stack {
496496
use core::kinds::marker;
497497
use core::mem;
498498
use super::BTreeMap;
499-
use super::super::node::{mod, Node, Fit, Split, KV, Edge, Internal, Leaf, LeafOrInternal};
499+
use super::super::node::{mod, Node, Fit, Split, Internal, Leaf};
500+
use super::super::node::handle;
500501
use vec::Vec;
501502

502503
/// A generic mutable reference, identical to `&mut` except for the fact that its lifetime
@@ -520,7 +521,7 @@ mod stack {
520521
}
521522
}
522523

523-
type StackItem<K, V> = node::Handle<*mut Node<K, V>, Edge, Internal>;
524+
type StackItem<K, V> = node::Handle<*mut Node<K, V>, handle::Edge, handle::Internal>;
524525
type Stack<K, V> = Vec<StackItem<K, V>>;
525526

526527
/// A `PartialSearchStack` handles the construction of a search stack.
@@ -595,7 +596,9 @@ mod stack {
595596
/// Pushes the requested child of the stack's current top on top of the stack. If the child
596597
/// exists, then a new PartialSearchStack is yielded. Otherwise, a VacantSearchStack is
597598
/// yielded.
598-
pub fn push(mut self, mut edge: node::Handle<IdRef<'id, Node<K, V>>, Edge, Internal>)
599+
pub fn push(mut self, mut edge: node::Handle<IdRef<'id, Node<K, V>>,
600+
handle::Edge,
601+
handle::Internal>)
599602
-> PartialSearchStack<'a, K, V> {
600603
self.stack.push(edge.as_raw());
601604
PartialSearchStack {
@@ -617,7 +620,7 @@ mod stack {
617620
}
618621
}
619622

620-
impl<'a, K, V, NodeType> SearchStack<'a, K, V, KV, NodeType> {
623+
impl<'a, K, V, NodeType> SearchStack<'a, K, V, handle::KV, NodeType> {
621624
/// Gets a reference to the value the stack points to.
622625
pub fn peek(&self) -> &V {
623626
unsafe { self.top.from_raw().into_kv().1 }
@@ -640,7 +643,7 @@ mod stack {
640643
}
641644
}
642645

643-
impl<'a, K, V> SearchStack<'a, K, V, KV, Leaf> {
646+
impl<'a, K, V> SearchStack<'a, K, V, handle::KV, handle::Leaf> {
644647
/// Removes the key and value in the top element of the stack, then handles underflows as
645648
/// described in BTree's pop function.
646649
fn remove_leaf(mut self) -> V {
@@ -686,7 +689,7 @@ mod stack {
686689
}
687690
}
688691

689-
impl<'a, K, V> SearchStack<'a, K, V, KV, LeafOrInternal> {
692+
impl<'a, K, V> SearchStack<'a, K, V, handle::KV, handle::LeafOrInternal> {
690693
/// Removes the key and value in the top element of the stack, then handles underflows as
691694
/// described in BTree's pop function.
692695
pub fn remove(self) -> V {
@@ -703,7 +706,7 @@ mod stack {
703706
/// leaves the tree in an inconsistent state that must be repaired by the caller by
704707
/// removing the entry in question. Specifically the key-value pair and its successor will
705708
/// become swapped.
706-
fn into_leaf(mut self) -> SearchStack<'a, K, V, KV, Leaf> {
709+
fn into_leaf(mut self) -> SearchStack<'a, K, V, handle::KV, handle::Leaf> {
707710
unsafe {
708711
let mut top_raw = self.top;
709712
let mut top = top_raw.from_raw_mut();
@@ -757,7 +760,7 @@ mod stack {
757760
}
758761
}
759762

760-
impl<'a, K, V> SearchStack<'a, K, V, Edge, Leaf> {
763+
impl<'a, K, V> SearchStack<'a, K, V, handle::Edge, handle::Leaf> {
761764
/// Inserts the key and value into the top element in the stack, and if that node has to
762765
/// split recursively inserts the split contents into the next element stack until
763766
/// splits stop.
@@ -1332,7 +1335,7 @@ impl<K: Ord, V> BTreeMap<K, V> {
13321335

13331336
#[cfg(test)]
13341337
mod test {
1335-
use std::prelude::*;
1338+
use prelude::*;
13361339

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

@@ -1534,7 +1537,7 @@ mod test {
15341537

15351538
#[cfg(test)]
15361539
mod bench {
1537-
use std::prelude::*;
1540+
use prelude::*;
15381541
use std::rand::{weak_rng, Rng};
15391542
use test::{Bencher, black_box};
15401543

src/libcollections/btree/node.rs

+36-29
Original file line numberDiff line numberDiff line change
@@ -34,9 +34,9 @@ pub enum InsertionResult<K, V> {
3434
/// Represents the result of a search for a key in a single node
3535
pub enum SearchResult<NodeRef> {
3636
/// The element was found at the given index
37-
Found(Handle<NodeRef, KV, LeafOrInternal>),
37+
Found(Handle<NodeRef, handle::KV, handle::LeafOrInternal>),
3838
/// The element wasn't found, but if it's anywhere, it must be beyond this edge
39-
GoDown(Handle<NodeRef, Edge, LeafOrInternal>),
39+
GoDown(Handle<NodeRef, handle::Edge, handle::LeafOrInternal>),
4040
}
4141

4242
/// A B-Tree Node. We keep keys/edges/values separate to optimize searching for keys.
@@ -494,12 +494,16 @@ pub struct Handle<NodeRef, Type, NodeType> {
494494
index: uint
495495
}
496496

497-
pub enum KV {}
498-
pub enum Edge {}
497+
pub mod handle {
498+
// Handle types.
499+
pub enum KV {}
500+
pub enum Edge {}
499501

500-
pub enum LeafOrInternal {}
501-
pub enum Leaf {}
502-
pub enum Internal {}
502+
// Handle node types.
503+
pub enum LeafOrInternal {}
504+
pub enum Leaf {}
505+
pub enum Internal {}
506+
}
503507

504508
impl<K: Ord, V> Node<K, V> {
505509
/// Searches for the given key in the node. If it finds an exact match,
@@ -625,7 +629,7 @@ impl<K, V, Type, NodeType> Handle<*mut Node<K, V>, Type, NodeType> {
625629
}
626630
}
627631

628-
impl<'a, K: 'a, V: 'a> Handle<&'a Node<K, V>, Edge, Internal> {
632+
impl<'a, K: 'a, V: 'a> Handle<&'a Node<K, V>, handle::Edge, handle::Internal> {
629633
/// Turns the handle into a reference to the edge it points at. This is necessary because the
630634
/// returned pointer has a larger lifetime than what would be returned by `edge` or `edge_mut`,
631635
/// making it more suitable for moving down a chain of nodes.
@@ -636,7 +640,7 @@ impl<'a, K: 'a, V: 'a> Handle<&'a Node<K, V>, Edge, Internal> {
636640
}
637641
}
638642

639-
impl<'a, K: 'a, V: 'a> Handle<&'a mut Node<K, V>, Edge, Internal> {
643+
impl<'a, K: 'a, V: 'a> Handle<&'a mut Node<K, V>, handle::Edge, handle::Internal> {
640644
/// Turns the handle into a mutable reference to the edge it points at. This is necessary
641645
/// because the returned pointer has a larger lifetime than what would be returned by
642646
/// `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<K, V>, Edge, Internal> {
647651
}
648652
}
649653

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

659663
pub enum ForceResult<NodeRef, Type> {
660-
Leaf(Handle<NodeRef, Type, Leaf>),
661-
Internal(Handle<NodeRef, Type, Internal>)
664+
Leaf(Handle<NodeRef, Type, handle::Leaf>),
665+
Internal(Handle<NodeRef, Type, handle::Internal>)
662666
}
663667

664-
impl<K, V, NodeRef: Deref<Node<K, V>>, Type> Handle<NodeRef, Type, LeafOrInternal> {
668+
impl<K, V, NodeRef: Deref<Node<K, V>>, Type> Handle<NodeRef, Type, handle::LeafOrInternal> {
665669
/// Figure out whether this handle is pointing to something in a leaf node or to something in
666670
/// an internal node, clarifying the type according to the result.
667671
pub fn force(self) -> ForceResult<NodeRef, Type> {
@@ -679,7 +683,7 @@ impl<K, V, NodeRef: Deref<Node<K, V>>, Type> Handle<NodeRef, Type, LeafOrInterna
679683
}
680684
}
681685

682-
impl<K, V, NodeRef: DerefMut<Node<K, V>>> Handle<NodeRef, Edge, Leaf> {
686+
impl<K, V, NodeRef: DerefMut<Node<K, V>>> Handle<NodeRef, handle::Edge, handle::Leaf> {
683687
/// Tries to insert this key-value pair at the given index in this leaf node
684688
/// If the node is full, we have to split it.
685689
///
@@ -711,7 +715,7 @@ impl<K, V, NodeRef: DerefMut<Node<K, V>>> Handle<NodeRef, Edge, Leaf> {
711715
}
712716
}
713717

714-
impl<K, V, NodeRef: DerefMut<Node<K, V>>> Handle<NodeRef, Edge, Internal> {
718+
impl<K, V, NodeRef: DerefMut<Node<K, V>>> Handle<NodeRef, handle::Edge, handle::Internal> {
715719
/// Returns a mutable reference to the edge pointed-to by this handle. This should not be
716720
/// confused with `node`, which references the parent node of what is returned here.
717721
pub fn edge_mut(&mut self) -> &mut Node<K, V> {
@@ -794,11 +798,11 @@ impl<K, V, NodeRef: DerefMut<Node<K, V>>> Handle<NodeRef, Edge, Internal> {
794798
}
795799
}
796800

797-
impl<K, V, NodeRef: DerefMut<Node<K, V>>, NodeType> Handle<NodeRef, Edge, NodeType> {
801+
impl<K, V, NodeRef: DerefMut<Node<K, V>>, NodeType> Handle<NodeRef, handle::Edge, NodeType> {
798802
/// Gets the handle pointing to the key/value pair just to the left of the pointed-to edge.
799803
/// This is unsafe because the handle might point to the first edge in the node, which has no
800804
/// pair to its left.
801-
unsafe fn left_kv<'a>(&'a mut self) -> Handle<&'a mut Node<K, V>, KV, NodeType> {
805+
unsafe fn left_kv<'a>(&'a mut self) -> Handle<&'a mut Node<K, V>, handle::KV, NodeType> {
802806
Handle {
803807
node: &mut *self.node,
804808
index: self.index - 1
@@ -808,15 +812,15 @@ impl<K, V, NodeRef: DerefMut<Node<K, V>>, NodeType> Handle<NodeRef, Edge, NodeTy
808812
/// Gets the handle pointing to the key/value pair just to the right of the pointed-to edge.
809813
/// This is unsafe because the handle might point to the last edge in the node, which has no
810814
/// pair to its right.
811-
unsafe fn right_kv<'a>(&'a mut self) -> Handle<&'a mut Node<K, V>, KV, NodeType> {
815+
unsafe fn right_kv<'a>(&'a mut self) -> Handle<&'a mut Node<K, V>, handle::KV, NodeType> {
812816
Handle {
813817
node: &mut *self.node,
814818
index: self.index
815819
}
816820
}
817821
}
818822

819-
impl<'a, K: 'a, V: 'a, NodeType> Handle<&'a Node<K, V>, KV, NodeType> {
823+
impl<'a, K: 'a, V: 'a, NodeType> Handle<&'a Node<K, V>, handle::KV, NodeType> {
820824
/// Turns the handle into references to the key and value it points at. This is necessary
821825
/// because the returned pointers have larger lifetimes than what would be returned by `key`
822826
/// or `val`.
@@ -831,7 +835,7 @@ impl<'a, K: 'a, V: 'a, NodeType> Handle<&'a Node<K, V>, KV, NodeType> {
831835
}
832836
}
833837

834-
impl<'a, K: 'a, V: 'a, NodeType> Handle<&'a mut Node<K, V>, KV, NodeType> {
838+
impl<'a, K: 'a, V: 'a, NodeType> Handle<&'a mut Node<K, V>, handle::KV, NodeType> {
835839
/// Turns the handle into mutable references to the key and value it points at. This is
836840
/// necessary because the returned pointers have larger lifetimes than what would be returned
837841
/// by `key_mut` or `val_mut`.
@@ -848,15 +852,16 @@ impl<'a, K: 'a, V: 'a, NodeType> Handle<&'a mut Node<K, V>, KV, NodeType> {
848852
/// Convert this handle into one pointing at the edge immediately to the left of the key/value
849853
/// pair pointed-to by this handle. This is useful because it returns a reference with larger
850854
/// lifetime than `left_edge`.
851-
pub fn into_left_edge(self) -> Handle<&'a mut Node<K, V>, Edge, NodeType> {
855+
pub fn into_left_edge(self) -> Handle<&'a mut Node<K, V>, handle::Edge, NodeType> {
852856
Handle {
853857
node: &mut *self.node,
854858
index: self.index
855859
}
856860
}
857861
}
858862

859-
impl<'a, K: 'a, V: 'a, NodeRef: Deref<Node<K, V>> + 'a, NodeType> Handle<NodeRef, KV, NodeType> {
863+
impl<'a, K: 'a, V: 'a, NodeRef: Deref<Node<K, V>> + 'a, NodeType> Handle<NodeRef, handle::KV,
864+
NodeType> {
860865
// These are fine to include, but are currently unneeded.
861866
//
862867
// /// 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<Node<K, V>> + 'a, NodeType> Handle<NodeRef
874879
// }
875880
}
876881

877-
impl<'a, K: 'a, V: 'a, NodeRef: DerefMut<Node<K, V>> + 'a, NodeType> Handle<NodeRef, KV, NodeType> {
882+
impl<'a, K: 'a, V: 'a, NodeRef: DerefMut<Node<K, V>> + 'a, NodeType> Handle<NodeRef, handle::KV,
883+
NodeType> {
878884
/// Returns a mutable reference to the key pointed-to by this handle. This doesn't return a
879885
/// reference with a lifetime as large as `into_kv_mut`, but it also does not consume the
880886
/// handle.
@@ -890,10 +896,10 @@ impl<'a, K: 'a, V: 'a, NodeRef: DerefMut<Node<K, V>> + 'a, NodeType> Handle<Node
890896
}
891897
}
892898

893-
impl<K, V, NodeRef: DerefMut<Node<K, V>>, NodeType> Handle<NodeRef, KV, NodeType> {
899+
impl<K, V, NodeRef: DerefMut<Node<K, V>>, NodeType> Handle<NodeRef, handle::KV, NodeType> {
894900
/// Gets the handle pointing to the edge immediately to the left of the key/value pair pointed
895901
/// to by this handle.
896-
pub fn left_edge<'a>(&'a mut self) -> Handle<&'a mut Node<K, V>, Edge, NodeType> {
902+
pub fn left_edge<'a>(&'a mut self) -> Handle<&'a mut Node<K, V>, handle::Edge, NodeType> {
897903
Handle {
898904
node: &mut *self.node,
899905
index: self.index
@@ -902,15 +908,15 @@ impl<K, V, NodeRef: DerefMut<Node<K, V>>, NodeType> Handle<NodeRef, KV, NodeType
902908

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

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

924-
impl<K, V, NodeRef: DerefMut<Node<K, V>>> Handle<NodeRef, KV, Internal> {
930+
impl<K, V, NodeRef: DerefMut<Node<K, V>>> Handle<NodeRef, handle::KV, handle::Internal> {
925931
/// Steal! Stealing is roughly analogous to a binary tree rotation.
926932
/// In this case, we're "rotating" right.
927933
unsafe fn steal_rightward(&mut self) {
@@ -1004,7 +1010,8 @@ impl<K, V> Node<K, V> {
10041010
/// # Panics (in debug build)
10051011
///
10061012
/// Panics if the given index is out of bounds.
1007-
pub fn kv_handle(&mut self, index: uint) -> Handle<&mut Node<K, V>, KV, LeafOrInternal> {
1013+
pub fn kv_handle(&mut self, index: uint) -> Handle<&mut Node<K, V>, handle::KV,
1014+
handle::LeafOrInternal> {
10081015
// Necessary for correctness, but in a private module
10091016
debug_assert!(index < self.len(), "kv_handle index out of bounds");
10101017
Handle {

src/libcollections/btree/set.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -726,7 +726,7 @@ impl<'a, T: Ord> Iterator<&'a T> for UnionItems<'a, T> {
726726

727727
#[cfg(test)]
728728
mod test {
729-
use std::prelude::*;
729+
use prelude::*;
730730

731731
use super::BTreeSet;
732732
use std::hash;

src/libcollections/dlist.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -788,14 +788,14 @@ impl<S: Writer, A: Hash<S>> Hash<S> for DList<A> {
788788

789789
#[cfg(test)]
790790
mod tests {
791-
use std::prelude::*;
791+
use prelude::*;
792792
use std::rand;
793793
use std::hash;
794+
use std::task::spawn;
794795
use test::Bencher;
795796
use test;
796797

797798
use super::{DList, Node, ListInsertion};
798-
use vec::Vec;
799799

800800
pub fn check_links<T>(list: &DList<T>) {
801801
let mut len = 0u;

0 commit comments

Comments
 (0)