about summary refs log tree commit diff
path: root/src/libsyntax
diff options
context:
space:
mode:
authorAaron Turon <aturon@mozilla.com>2014-11-12 15:51:51 -0800
committerAaron Turon <aturon@mozilla.com>2014-11-17 11:26:48 -0800
commit7213de1c49e448c7c6ad2d30dc3e6b3a13e090df (patch)
tree9133e9f7b6f954432eddd947cb74248a1751ea36 /src/libsyntax
parent80a2867ea736007397aa2fbaa0e4c539c80e162c (diff)
downloadrust-7213de1c49e448c7c6ad2d30dc3e6b3a13e090df.tar.gz
rust-7213de1c49e448c7c6ad2d30dc3e6b3a13e090df.zip
Fallout from deprecation
This commit handles the fallout from deprecating `_with` and `_equiv` methods.
Diffstat (limited to 'src/libsyntax')
-rw-r--r--src/libsyntax/diagnostics/registry.rs2
-rw-r--r--src/libsyntax/ext/format.rs6
-rw-r--r--src/libsyntax/util/interner.rs20
3 files changed, 18 insertions, 10 deletions
diff --git a/src/libsyntax/diagnostics/registry.rs b/src/libsyntax/diagnostics/registry.rs
index 71d82a41f38..4caef247aeb 100644
--- a/src/libsyntax/diagnostics/registry.rs
+++ b/src/libsyntax/diagnostics/registry.rs
@@ -20,6 +20,6 @@ impl Registry {
     }
 
     pub fn find_description(&self, code: &str) -> Option<&'static str> {
-        self.descriptions.find_equiv(code).map(|desc| *desc)
+        self.descriptions.get(code).map(|desc| *desc)
     }
 }
diff --git a/src/libsyntax/ext/format.rs b/src/libsyntax/ext/format.rs
index 9a9724de8fb..f1b92b4d6bc 100644
--- a/src/libsyntax/ext/format.rs
+++ b/src/libsyntax/ext/format.rs
@@ -144,7 +144,7 @@ fn parse_args(ecx: &mut ExtCtxt, sp: Span, allow_method: bool,
             let name = interned_name.get();
             p.expect(&token::Eq);
             let e = p.parse_expr();
-            match names.find_equiv(name) {
+            match names.get(name) {
                 None => {}
                 Some(prev) => {
                     ecx.span_err(e.span,
@@ -366,7 +366,7 @@ impl<'a, 'b> Context<'a, 'b> {
                 self.ecx.expr_path(path)
             }
             parse::CountIsName(n) => {
-                let i = match self.name_positions.find_equiv(n) {
+                let i = match self.name_positions.get(n) {
                     Some(&i) => i,
                     None => 0, // error already emitted elsewhere
                 };
@@ -410,7 +410,7 @@ impl<'a, 'b> Context<'a, 'b> {
                     // Named arguments are converted to positional arguments at
                     // the end of the list of arguments
                     parse::ArgumentNamed(n) => {
-                        let i = match self.name_positions.find_equiv(n) {
+                        let i = match self.name_positions.get(n) {
                             Some(&i) => i,
                             None => 0, // error already emitted elsewhere
                         };
diff --git a/src/libsyntax/util/interner.rs b/src/libsyntax/util/interner.rs
index 08ada3e4435..ede967bba25 100644
--- a/src/libsyntax/util/interner.rs
+++ b/src/libsyntax/util/interner.rs
@@ -14,9 +14,9 @@
 
 use ast::Name;
 
+use std::borrow::BorrowFrom;
 use std::collections::HashMap;
 use std::cell::RefCell;
-use std::cmp::Equiv;
 use std::fmt;
 use std::hash::Hash;
 use std::rc::Rc;
@@ -75,9 +75,10 @@ impl<T: Eq + Hash + Clone + 'static> Interner<T> {
         (*vect).len()
     }
 
-    pub fn find_equiv<Sized? Q: Hash + Equiv<T>>(&self, val: &Q) -> Option<Name> {
+    pub fn find<Sized? Q>(&self, val: &Q) -> Option<Name>
+    where Q: BorrowFrom<T> + Eq + Hash {
         let map = self.map.borrow();
-        match (*map).find_equiv(val) {
+        match (*map).get(val) {
             Some(v) => Some(*v),
             None => None,
         }
@@ -117,6 +118,12 @@ impl fmt::Show for RcStr {
     }
 }
 
+impl BorrowFrom<RcStr> for str {
+    fn borrow_from(owned: &RcStr) -> &str {
+        owned.string.as_slice()
+    }
+}
+
 impl RcStr {
     pub fn new(string: &str) -> RcStr {
         RcStr {
@@ -149,7 +156,7 @@ impl StrInterner {
 
     pub fn intern(&self, val: &str) -> Name {
         let mut map = self.map.borrow_mut();
-        match map.find_equiv(val) {
+        match map.get(val) {
             Some(&idx) => return idx,
             None => (),
         }
@@ -195,8 +202,9 @@ impl StrInterner {
         self.vect.borrow().len()
     }
 
-    pub fn find_equiv<Sized? Q:Hash + Equiv<RcStr>>(&self, val: &Q) -> Option<Name> {
-        match (*self.map.borrow()).find_equiv(val) {
+    pub fn find<Sized? Q>(&self, val: &Q) -> Option<Name>
+    where Q: BorrowFrom<RcStr> + Eq + Hash {
+        match (*self.map.borrow()).get(val) {
             Some(v) => Some(*v),
             None => None,
         }