about summary refs log tree commit diff
path: root/src/librustc
diff options
context:
space:
mode:
Diffstat (limited to 'src/librustc')
-rw-r--r--src/librustc/lint/mod.rs8
-rw-r--r--src/librustc/metadata/encoder.rs42
-rw-r--r--src/librustc/middle/ty.rs15
-rw-r--r--src/librustc/util/common.rs103
-rw-r--r--src/librustc/util/nodemap.rs31
-rw-r--r--src/librustc/util/ppaux.rs18
6 files changed, 6 insertions, 211 deletions
diff --git a/src/librustc/lint/mod.rs b/src/librustc/lint/mod.rs
index bdcc10ebcec..021827b0101 100644
--- a/src/librustc/lint/mod.rs
+++ b/src/librustc/lint/mod.rs
@@ -185,14 +185,6 @@ impl PartialEq for LintId {
 
 impl Eq for LintId { }
 
-#[cfg(stage0)]
-impl<S: hash::Writer + hash::Hasher> hash::Hash<S> for LintId {
-    fn hash(&self, state: &mut S) {
-        let ptr = self.lint as *const Lint;
-        ptr.hash(state);
-    }
-}
-#[cfg(not(stage0))]
 impl hash::Hash for LintId {
     fn hash<H: hash::Hasher>(&self, state: &mut H) {
         let ptr = self.lint as *const Lint;
diff --git a/src/librustc/metadata/encoder.rs b/src/librustc/metadata/encoder.rs
index 42a70cec5df..b7cdf63dd99 100644
--- a/src/librustc/metadata/encoder.rs
+++ b/src/librustc/metadata/encoder.rs
@@ -1588,48 +1588,6 @@ fn encode_info_for_items(ecx: &EncodeContext,
 
 // Path and definition ID indexing
 
-#[cfg(stage0)]
-fn encode_index<T, F>(rbml_w: &mut Encoder, index: Vec<entry<T>>, mut write_fn: F) where
-    F: FnMut(&mut SeekableMemWriter, &T),
-    T: Hash<SipHasher>,
-{
-    let mut buckets: Vec<Vec<entry<T>>> = (0..256u16).map(|_| Vec::new()).collect();
-    for elt in index {
-        let mut s = SipHasher::new();
-        elt.val.hash(&mut s);
-        let h = s.finish() as uint;
-        (&mut buckets[h % 256]).push(elt);
-    }
-
-    rbml_w.start_tag(tag_index);
-    let mut bucket_locs = Vec::new();
-    rbml_w.start_tag(tag_index_buckets);
-    for bucket in &buckets {
-        bucket_locs.push(rbml_w.writer.tell().unwrap());
-        rbml_w.start_tag(tag_index_buckets_bucket);
-        for elt in bucket {
-            rbml_w.start_tag(tag_index_buckets_bucket_elt);
-            assert!(elt.pos < 0xffff_ffff);
-            {
-                let wr: &mut SeekableMemWriter = rbml_w.writer;
-                wr.write_be_u32(elt.pos as u32);
-            }
-            write_fn(rbml_w.writer, &elt.val);
-            rbml_w.end_tag();
-        }
-        rbml_w.end_tag();
-    }
-    rbml_w.end_tag();
-    rbml_w.start_tag(tag_index_table);
-    for pos in &bucket_locs {
-        assert!(*pos < 0xffff_ffff);
-        let wr: &mut SeekableMemWriter = rbml_w.writer;
-        wr.write_be_u32(*pos as u32);
-    }
-    rbml_w.end_tag();
-    rbml_w.end_tag();
-}
-#[cfg(not(stage0))]
 fn encode_index<T, F>(rbml_w: &mut Encoder, index: Vec<entry<T>>, mut write_fn: F) where
     F: FnMut(&mut SeekableMemWriter, &T),
     T: Hash,
diff --git a/src/librustc/middle/ty.rs b/src/librustc/middle/ty.rs
index e9908397f97..87f0e1ed6c6 100644
--- a/src/librustc/middle/ty.rs
+++ b/src/librustc/middle/ty.rs
@@ -73,7 +73,6 @@ use std::cell::{Cell, RefCell};
 use std::cmp;
 use std::fmt;
 use std::hash::{Hash, SipHasher, Hasher};
-#[cfg(stage0)] use std::hash::Writer;
 use std::mem;
 use std::ops;
 use std::rc::Rc;
@@ -959,13 +958,6 @@ impl<'tcx> PartialEq for TyS<'tcx> {
 }
 impl<'tcx> Eq for TyS<'tcx> {}
 
-#[cfg(stage0)]
-impl<'tcx, S: Writer + Hasher> Hash<S> for TyS<'tcx> {
-    fn hash(&self, s: &mut S) {
-        (self as *const _).hash(s)
-    }
-}
-#[cfg(not(stage0))]
 impl<'tcx> Hash for TyS<'tcx> {
     fn hash<H: Hasher>(&self, s: &mut H) {
         (self as *const _).hash(s)
@@ -988,13 +980,6 @@ impl<'tcx> PartialEq for InternedTy<'tcx> {
 
 impl<'tcx> Eq for InternedTy<'tcx> {}
 
-#[cfg(stage0)]
-impl<'tcx, S: Writer + Hasher> Hash<S> for InternedTy<'tcx> {
-    fn hash(&self, s: &mut S) {
-        self.ty.sty.hash(s)
-    }
-}
-#[cfg(not(stage0))]
 impl<'tcx> Hash for InternedTy<'tcx> {
     fn hash<H: Hasher>(&self, s: &mut H) {
         self.ty.sty.hash(s)
diff --git a/src/librustc/util/common.rs b/src/librustc/util/common.rs
index c9d50b9cecf..a3cc23b7bba 100644
--- a/src/librustc/util/common.rs
+++ b/src/librustc/util/common.rs
@@ -14,7 +14,6 @@ use std::cell::{RefCell, Cell};
 use std::collections::HashMap;
 use std::fmt::Debug;
 use std::hash::Hash;
-#[cfg(stage0)] use std::hash::Hasher;
 use std::iter::repeat;
 use std::time::Duration;
 use std::collections::hash_state::HashState;
@@ -139,57 +138,13 @@ pub fn block_query<P>(b: &ast::Block, p: P) -> bool where P: FnMut(&ast::Expr) -
 
 /// K: Eq + Hash<S>, V, S, H: Hasher<S>
 ///
-/// Determines whether there exists a path from `source` to `destination`.  The graph is defined by
-/// the `edges_map`, which maps from a node `S` to a list of its adjacent nodes `T`.
+/// Determines whether there exists a path from `source` to `destination`.  The
+/// graph is defined by the `edges_map`, which maps from a node `S` to a list of
+/// its adjacent nodes `T`.
 ///
-/// Efficiency note: This is implemented in an inefficient way because it is typically invoked on
-/// very small graphs. If the graphs become larger, a more efficient graph representation and
-/// algorithm would probably be advised.
-#[cfg(stage0)]
-pub fn can_reach<T, S>(edges_map: &HashMap<T, Vec<T>, S>, source: T,
-                       destination: T) -> bool
-    where S: HashState,
-          <S as HashState>::Hasher: Hasher<Output=u64>,
-          T: Hash<<S as HashState>::Hasher> + Eq + Clone,
-{
-    if source == destination {
-        return true;
-    }
-
-    // Do a little breadth-first-search here.  The `queue` list
-    // doubles as a way to detect if we've seen a particular FR
-    // before.  Note that we expect this graph to be an *extremely
-    // shallow* tree.
-    let mut queue = vec!(source);
-    let mut i = 0;
-    while i < queue.len() {
-        match edges_map.get(&queue[i]) {
-            Some(edges) => {
-                for target in edges {
-                    if *target == destination {
-                        return true;
-                    }
-
-                    if !queue.iter().any(|x| x == target) {
-                        queue.push((*target).clone());
-                    }
-                }
-            }
-            None => {}
-        }
-        i += 1;
-    }
-    return false;
-}
-/// K: Eq + Hash<S>, V, S, H: Hasher<S>
-///
-/// Determines whether there exists a path from `source` to `destination`.  The graph is defined by
-/// the `edges_map`, which maps from a node `S` to a list of its adjacent nodes `T`.
-///
-/// Efficiency note: This is implemented in an inefficient way because it is typically invoked on
-/// very small graphs. If the graphs become larger, a more efficient graph representation and
-/// algorithm would probably be advised.
-#[cfg(not(stage0))]
+/// Efficiency note: This is implemented in an inefficient way because it is
+/// typically invoked on very small graphs. If the graphs become larger, a more
+/// efficient graph representation and algorithm would probably be advised.
 pub fn can_reach<T, S>(edges_map: &HashMap<T, Vec<T>, S>, source: T,
                        destination: T) -> bool
     where S: HashState, T: Hash + Eq + Clone,
@@ -250,52 +205,6 @@ pub fn can_reach<T, S>(edges_map: &HashMap<T, Vec<T>, S>, source: T,
 /// }
 /// ```
 #[inline(always)]
-#[cfg(stage0)]
-pub fn memoized<T, U, S, F>(cache: &RefCell<HashMap<T, U, S>>, arg: T, f: F) -> U
-    where T: Clone + Hash<<S as HashState>::Hasher> + Eq,
-          U: Clone,
-          S: HashState,
-          <S as HashState>::Hasher: Hasher<Output=u64>,
-          F: FnOnce(T) -> U,
-{
-    let key = arg.clone();
-    let result = cache.borrow().get(&key).cloned();
-    match result {
-        Some(result) => result,
-        None => {
-            let result = f(arg);
-            cache.borrow_mut().insert(key, result.clone());
-            result
-        }
-    }
-}
-/// Memoizes a one-argument closure using the given RefCell containing
-/// a type implementing MutableMap to serve as a cache.
-///
-/// In the future the signature of this function is expected to be:
-/// ```
-/// pub fn memoized<T: Clone, U: Clone, M: MutableMap<T, U>>(
-///    cache: &RefCell<M>,
-///    f: &|T| -> U
-/// ) -> impl |T| -> U {
-/// ```
-/// but currently it is not possible.
-///
-/// # Example
-/// ```
-/// struct Context {
-///    cache: RefCell<HashMap<uint, uint>>
-/// }
-///
-/// fn factorial(ctxt: &Context, n: uint) -> uint {
-///     memoized(&ctxt.cache, n, |n| match n {
-///         0 | 1 => n,
-///         _ => factorial(ctxt, n - 2) + factorial(ctxt, n - 1)
-///     })
-/// }
-/// ```
-#[inline(always)]
-#[cfg(not(stage0))]
 pub fn memoized<T, U, S, F>(cache: &RefCell<HashMap<T, U, S>>, arg: T, f: F) -> U
     where T: Clone + Hash + Eq,
           U: Clone,
diff --git a/src/librustc/util/nodemap.rs b/src/librustc/util/nodemap.rs
index 1b07ce789e7..b15da7dab3e 100644
--- a/src/librustc/util/nodemap.rs
+++ b/src/librustc/util/nodemap.rs
@@ -16,7 +16,6 @@ use std::collections::hash_state::{DefaultState};
 use std::collections::{HashMap, HashSet};
 use std::default::Default;
 use std::hash::{Hasher, Hash};
-#[cfg(stage0)] use std::hash::Writer;
 use syntax::ast;
 
 pub type FnvHashMap<K, V> = HashMap<K, V, DefaultState<FnvHasher>>;
@@ -28,19 +27,9 @@ pub type DefIdMap<T> = FnvHashMap<ast::DefId, T>;
 pub type NodeSet = FnvHashSet<ast::NodeId>;
 pub type DefIdSet = FnvHashSet<ast::DefId>;
 
-#[cfg(stage0)]
-pub fn FnvHashMap<K: Hash<FnvHasher> + Eq, V>() -> FnvHashMap<K, V> {
-    Default::default()
-}
-#[cfg(stage0)]
-pub fn FnvHashSet<V: Hash<FnvHasher> + Eq>() -> FnvHashSet<V> {
-    Default::default()
-}
-#[cfg(not(stage0))]
 pub fn FnvHashMap<K: Hash + Eq, V>() -> FnvHashMap<K, V> {
     Default::default()
 }
-#[cfg(not(stage0))]
 pub fn FnvHashSet<V: Hash + Eq>() -> FnvHashSet<V> {
     Default::default()
 }
@@ -63,26 +52,6 @@ impl Default for FnvHasher {
     fn default() -> FnvHasher { FnvHasher(0xcbf29ce484222325) }
 }
 
-#[cfg(stage0)]
-impl Hasher for FnvHasher {
-    type Output = u64;
-    fn reset(&mut self) { *self = Default::default(); }
-    fn finish(&self) -> u64 { self.0 }
-}
-
-#[cfg(stage0)]
-impl Writer for FnvHasher {
-    fn write(&mut self, bytes: &[u8]) {
-        let FnvHasher(mut hash) = *self;
-        for byte in bytes {
-            hash = hash ^ (*byte as u64);
-            hash = hash * 0x100000001b3;
-        }
-        *self = FnvHasher(hash);
-    }
-}
-
-#[cfg(not(stage0))]
 impl Hasher for FnvHasher {
     fn write(&mut self, bytes: &[u8]) {
         let FnvHasher(mut hash) = *self;
diff --git a/src/librustc/util/ppaux.rs b/src/librustc/util/ppaux.rs
index 1d46c011bb3..0454af45b7c 100644
--- a/src/librustc/util/ppaux.rs
+++ b/src/librustc/util/ppaux.rs
@@ -29,7 +29,6 @@ use middle::ty_fold::TypeFoldable;
 use std::collections::HashMap;
 use std::collections::hash_state::HashState;
 use std::hash::Hash;
-#[cfg(stage0)] use std::hash::Hasher;
 use std::rc::Rc;
 use syntax::abi;
 use syntax::ast_map;
@@ -1434,23 +1433,6 @@ impl<'tcx, T:Repr<'tcx>> Repr<'tcx> for ty::Binder<T> {
     }
 }
 
-#[cfg(stage0)]
-impl<'tcx, S, K, V> Repr<'tcx> for HashMap<K, V, S>
-    where K: Hash<<S as HashState>::Hasher> + Eq + Repr<'tcx>,
-          V: Repr<'tcx>,
-          S: HashState,
-          <S as HashState>::Hasher: Hasher<Output=u64>,
-{
-    fn repr(&self, tcx: &ctxt<'tcx>) -> String {
-        format!("HashMap({})",
-                self.iter()
-                    .map(|(k,v)| format!("{} => {}", k.repr(tcx), v.repr(tcx)))
-                    .collect::<Vec<String>>()
-                    .connect(", "))
-    }
-}
-
-#[cfg(not(stage0))]
 impl<'tcx, S, K, V> Repr<'tcx> for HashMap<K, V, S>
     where K: Hash + Eq + Repr<'tcx>,
           V: Repr<'tcx>,