]> git.lizzy.rs Git - rust.git/commitdiff
Fallout from deprecation
authorAaron Turon <aturon@mozilla.com>
Wed, 12 Nov 2014 23:51:51 +0000 (15:51 -0800)
committerAaron Turon <aturon@mozilla.com>
Mon, 17 Nov 2014 19:26:48 +0000 (11:26 -0800)
This commit handles the fallout from deprecating `_with` and `_equiv` methods.

21 files changed:
src/grammar/verify.rs
src/libcollections/tree/mod.rs
src/libcollections/trie/mod.rs
src/libregex/re.rs
src/librustc/lint/context.rs
src/librustc/metadata/creader.rs
src/librustc/metadata/decoder.rs
src/librustc/metadata/filesearch.rs
src/librustc/metadata/loader.rs
src/librustc/middle/lang_items.rs
src/librustc/middle/trans/base.rs
src/librustc/middle/trans/debuginfo.rs
src/librustc/middle/trans/type_.rs
src/librustdoc/html/render.rs
src/libserialize/json.rs
src/libstd/collections/hash/map.rs
src/libsyntax/diagnostics/registry.rs
src/libsyntax/ext/format.rs
src/libsyntax/util/interner.rs
src/libterm/terminfo/mod.rs
src/test/bench/shootout-k-nucleotide-pipes.rs

index a4641c40165aca9ede5d17025b5b0d32d9858e0b..159a62f01107206b1a4f0e92be71fae111a37c92 100644 (file)
@@ -178,7 +178,7 @@ fn parse_antlr_token(s: &str, tokens: &HashMap<String, Token>) -> TokenAndSpan {
     let toknum = m.name("toknum");
     let content = m.name("content");
 
-    let proto_tok = tokens.find_equiv(&toknum).expect(format!("didn't find token {} in the map",
+    let proto_tok = tokens.get(&toknum).expect(format!("didn't find token {} in the map",
                                                               toknum).as_slice());
 
     let nm = parse::token::intern(content);
index ac8279c92feeb8f3f73cef427ff69b2eba3a17e3..20823a2affc7f5d73fd887a23bf81b9b932089d2 100644 (file)
@@ -33,4 +33,4 @@
 //! ```
 
 pub mod map;
-pub mod set;
\ No newline at end of file
+pub mod set;
index f0f8f00a6a0db8608717287a7a1e8b6031ffd402..9dcb182cd267570b259926cb1993bfbdc0f27527 100644 (file)
@@ -17,4 +17,4 @@
 //! `TrieMap` is ordered.
 
 pub mod map;
-pub mod set;
\ No newline at end of file
+pub mod set;
index dbdb271874474eeaf59031a74a158fc6effda21b..e1e2abcb1b7c540e011443e6959a8b86fa3e63b4 100644 (file)
@@ -726,7 +726,7 @@ pub fn name(&self, name: &str) -> &'t str {
         match self.named {
             None => "",
             Some(ref h) => {
-                match h.find_equiv(name) {
+                match h.get(name) {
                     None => "",
                     Some(i) => self.at(*i),
                 }
index 85cc413a1b801702d8f571be45ad10744db2e6bd..aa6a021a210ef60580a7bac46a41c5c902cbf910 100644 (file)
@@ -165,7 +165,7 @@ pub fn register_group(&mut self, sess: Option<&Session>,
     }
 
     fn register_renamed(&mut self, old_name: &str, new_name: &str) {
-        let target = match self.by_name.find_equiv(new_name) {
+        let target = match self.by_name.get(new_name) {
             Some(&Id(lint_id)) => lint_id.clone(),
             _ => panic!("invalid lint renaming of {} to {}", old_name, new_name)
         };
@@ -259,7 +259,7 @@ macro_rules! add_lint_group ( ( $sess:ident, $name:expr, $($lint:ident),* ) => (
     fn find_lint(&self, lint_name: &str, sess: &Session, span: Option<Span>)
                  -> Option<LintId>
     {
-        match self.by_name.find_equiv(lint_name) {
+        match self.by_name.get(lint_name) {
             Some(&Id(lint_id)) => Some(lint_id),
             Some(&Renamed(ref new_name, lint_id)) => {
                 let warning = format!("lint {} has been renamed to {}",
@@ -282,7 +282,7 @@ pub fn process_command_line(&mut self, sess: &Session) {
                     match self.lint_groups.iter().map(|(&x, pair)| (x, pair.ref0().clone()))
                                                  .collect::<FnvHashMap<&'static str,
                                                                        Vec<LintId>>>()
-                                                 .find_equiv(lint_name.as_slice()) {
+                                                 .get(lint_name.as_slice()) {
                         Some(v) => {
                             v.iter()
                              .map(|lint_id: &LintId|
@@ -489,7 +489,7 @@ fn with_lint_attrs(&mut self,
                     match self.lints.find_lint(lint_name.get(), &self.tcx.sess, Some(span)) {
                         Some(lint_id) => vec![(lint_id, level, span)],
                         None => {
-                            match self.lints.lint_groups.find_equiv(lint_name.get()) {
+                            match self.lints.lint_groups.get(lint_name.get()) {
                                 Some(&(ref v, _)) => v.iter()
                                                       .map(|lint_id: &LintId|
                                                            (*lint_id, level, span))
index dbf0e4054085c68be26cca75433fd370ce360f34..1cfe565fd7deecc16006162c0cba59e5824716a2 100644 (file)
@@ -321,7 +321,7 @@ fn existing_match(e: &Env, name: &str,
         // `source` stores paths which are normalized which may be different
         // from the strings on the command line.
         let source = e.sess.cstore.get_used_crate_source(cnum).unwrap();
-        match e.sess.opts.externs.find_equiv(name) {
+        match e.sess.opts.externs.get(name) {
             Some(locs) => {
                 let found = locs.iter().any(|l| {
                     let l = fs::realpath(&Path::new(l.as_slice())).ok();
index 2af1f12a2cd82ac5ff06a81ad57da3d321967805..e0110a81c179f0d6e3fe03086151634b9f01fe60 100644 (file)
@@ -298,7 +298,7 @@ fn item_path(item_doc: rbml::Doc) -> Vec<ast_map::PathElem> {
 fn item_name(intr: &IdentInterner, item: rbml::Doc) -> ast::Name {
     let name = reader::get_doc(item, tag_paths_data_name);
     let string = name.as_str_slice();
-    match intr.find_equiv(string) {
+    match intr.find(string) {
         None => token::intern(string),
         Some(val) => val,
     }
@@ -1449,4 +1449,3 @@ pub fn is_associated_type(cdata: Cmd, id: ast::NodeId) -> bool {
         Some(item) => item_sort(item) == 't',
     }
 }
-
index aeed829f8055b05a7c14e42d8b668237d9f0feea..f7d666e48150d97bc39bf5f5c6e5a6fba2a5f909 100644 (file)
@@ -54,7 +54,7 @@ pub fn for_each_lib_search_path(&self, f: |&Path| -> FileMatch) {
         debug!("filesearch: searching lib path");
         let tlib_path = make_target_lib_path(self.sysroot,
                                     self.triple);
-        if !visited_dirs.contains_equiv(tlib_path.as_vec()) {
+        if !visited_dirs.contains(tlib_path.as_vec()) {
             match f(&tlib_path) {
                 FileMatches => found = true,
                 FileDoesntMatch => ()
@@ -69,9 +69,9 @@ pub fn for_each_lib_search_path(&self, f: |&Path| -> FileMatch) {
                 let tlib_path = make_rustpkg_lib_path(
                     self.sysroot, path, self.triple);
                 debug!("is {} in visited_dirs? {}", tlib_path.display(),
-                        visited_dirs.contains_equiv(&tlib_path.as_vec().to_vec()));
+                        visited_dirs.contains(&tlib_path.as_vec().to_vec()));
 
-                if !visited_dirs.contains_equiv(tlib_path.as_vec()) {
+                if !visited_dirs.contains(tlib_path.as_vec()) {
                     visited_dirs.insert(tlib_path.as_vec().to_vec());
                     // Don't keep searching the RUST_PATH if one match turns up --
                     // if we did, we'd get a "multiple matching crates" error
index c3d92a19a20560bdcb8ab2ca4f6b02f8b4dbeced..30bef248b4738c6a8afe52380d1c55f25bdcb45e 100644 (file)
@@ -596,7 +596,7 @@ fn dylibname(&self) -> (String, String) {
     }
 
     fn find_commandline_library(&mut self) -> Option<Library> {
-        let locs = match self.sess.opts.externs.find_equiv(self.crate_name) {
+        let locs = match self.sess.opts.externs.get(self.crate_name) {
             Some(s) => s,
             None => return None,
         };
index 4fe770a1e0fb33c207cd683b98ad37d27dadcddb..ffc8a83e42edad9fd8704502e2df1488f6daf8c1 100644 (file)
@@ -132,7 +132,7 @@ impl<'a, 'v> Visitor<'v> for LanguageItemCollector<'a> {
     fn visit_item(&mut self, item: &ast::Item) {
         match extract(item.attrs.as_slice()) {
             Some(value) => {
-                let item_index = self.item_refs.find_equiv(&value).map(|x| *x);
+                let item_index = self.item_refs.get(value.get()).map(|x| *x);
 
                 match item_index {
                     Some(item_index) => {
index b267d1d7f3e1e8fb24157f54f5759fb4a38d8346..cc51be31760a370c3d2650ce558a37f69289db93 100644 (file)
@@ -216,7 +216,7 @@ pub fn get_extern_fn(ccx: &CrateContext,
                      ty: Type,
                      output: ty::t)
                      -> ValueRef {
-    match externs.find_equiv(name) {
+    match externs.get(name) {
         Some(n) => return *n,
         None => {}
     }
@@ -226,7 +226,7 @@ pub fn get_extern_fn(ccx: &CrateContext,
 }
 
 fn get_extern_rust_fn(ccx: &CrateContext, fn_ty: ty::t, name: &str, did: ast::DefId) -> ValueRef {
-    match ccx.externs().borrow().find_equiv(name) {
+    match ccx.externs().borrow().get(name) {
         Some(n) => return *n,
         None => ()
     }
@@ -2983,7 +2983,7 @@ fn internalize_symbols(cx: &SharedCrateContext, reachable: &HashSet<String>) {
 
                 let name = CString::new(llvm::LLVMGetValueName(val), false);
                 if !declared.contains(&name) &&
-                   !reachable.contains_equiv(name.as_str().unwrap()) {
+                   !reachable.contains(name.as_str().unwrap()) {
                     llvm::SetLinkage(val, llvm::InternalLinkage);
                 }
             }
index eaff757679aa076942cb01e011da0ebb3ff55b4c..de8e80b02757b6b21bc217c3560271aabca9e410 100644 (file)
@@ -1677,7 +1677,7 @@ fn declare_local(bcx: Block,
 }
 
 fn file_metadata(cx: &CrateContext, full_path: &str) -> DIFile {
-    match debug_context(cx).created_files.borrow().find_equiv(full_path) {
+    match debug_context(cx).created_files.borrow().get(full_path) {
         Some(file_metadata) => return *file_metadata,
         None => ()
     }
index d6a2d0c86a11149185fbf138c003cd94b2e807f7..69861290b8d0d16f47d8d7d5b7e061b27f6533f2 100644 (file)
@@ -336,7 +336,7 @@ pub fn associate_type(&self, s: &str, t: &Type) {
     }
 
     pub fn find_type(&self, s: &str) -> Option<Type> {
-        self.named_types.borrow().find_equiv(s).map(|x| Type::from_ref(*x))
+        self.named_types.borrow().get(s).map(|x| Type::from_ref(*x))
     }
 
     pub fn type_to_string(&self, ty: Type) -> String {
index 1dd651481693f88e5b08417bd0c3d420a11d317b..8e9ac7095dae1bde2d1a85089b11a6719638d20a 100644 (file)
@@ -2122,7 +2122,7 @@ fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
 
         fn block(w: &mut fmt::Formatter, short: &str, longty: &str,
                  cur: &clean::Item, cx: &Context) -> fmt::Result {
-            let items = match cx.sidebar.find_equiv(short) {
+            let items = match cx.sidebar.get(short) {
                 Some(items) => items.as_slice(),
                 None => return Ok(())
             };
index 80238f6df415db950610b83c732e8bc523f1f6d9..03e0452a4158d5a02d601cc3910ee7ebbd0a3d1c 100644 (file)
@@ -901,7 +901,7 @@ pub fn to_pretty_str(&self) -> string::String {
     /// Otherwise, returns None.
     pub fn find<'a>(&'a self, key: &str) -> Option<&'a Json>{
         match self {
-            &Object(ref map) => map.find_with(|s| key.cmp(s.as_slice())),
+            &Object(ref map) => map.get(key),
             _ => None
         }
     }
@@ -926,7 +926,7 @@ pub fn find_path<'a>(&'a self, keys: &[&str]) -> Option<&'a Json>{
     pub fn search<'a>(&'a self, key: &str) -> Option<&'a Json> {
         match self {
             &Object(ref map) => {
-                match map.find_with(|s| key.cmp(s.as_slice())) {
+                match map.get(key) {
                     Some(json_value) => Some(json_value),
                     None => {
                         for (_, v) in map.iter() {
index 2eee6976339cea7d2e296851f6024a645d7f5f30..69375e8d4f84e131d5044185422b130c96589472 100644 (file)
@@ -1944,11 +1944,11 @@ fn test_find_equiv() {
         m.insert("baz".to_string(), baz);
 
 
-        assert_eq!(m.find_equiv("foo"), Some(&foo));
-        assert_eq!(m.find_equiv("bar"), Some(&bar));
-        assert_eq!(m.find_equiv("baz"), Some(&baz));
+        assert_eq!(m.get("foo"), Some(&foo));
+        assert_eq!(m.get("bar"), Some(&bar));
+        assert_eq!(m.get("baz"), Some(&baz));
 
-        assert_eq!(m.find_equiv("qux"), None);
+        assert_eq!(m.get("qux"), None);
     }
 
     #[test]
index 71d82a41f38683e7ae4d7bfb5c19ed0fdf487f11..4caef247aebc26f601318c8d4de23ec70cfdfe02 100644 (file)
@@ -20,6 +20,6 @@ pub fn new(descriptions: &[(&'static str, &'static str)]) -> 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)
     }
 }
index 9a9724de8fb702201ad997adf0813cfd5d696b40..f1b92b4d6bc1d7406bcac881eb0c1f09a79a1889 100644 (file)
@@ -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 @@ fn trans_count(&self, c: parse::Count) -> P<ast::Expr> {
                 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 @@ fn trans_piece(&mut self, piece: &parse::Piece) -> Option<P<ast::Expr>> {
                     // 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
                         };
index 08ada3e4435903a8990e0432cd94c40d45b97b27..ede967bba25cd20bad2a12dd2d56ae77148f3179 100644 (file)
@@ -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 @@ pub fn len(&self) -> uint {
         (*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 @@ fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
     }
 }
 
+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 @@ pub fn prefill(init: &[&str]) -> 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 @@ pub fn len(&self) -> uint {
         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,
         }
index 0b5092a64d0f33294f154f16a6426a0b09c1e5cf..c1393767c8adcaf62af86f86b2f1e70452e9c64a 100644 (file)
@@ -78,7 +78,7 @@ fn fg(&mut self, color: color::Color) -> IoResult<bool> {
         if self.num_colors > color {
             let s = expand(self.ti
                                .strings
-                               .find_equiv("setaf")
+                               .get("setaf")
                                .unwrap()
                                .as_slice(),
                            &[Number(color as int)], &mut Variables::new());
@@ -95,7 +95,7 @@ fn bg(&mut self, color: color::Color) -> IoResult<bool> {
         if self.num_colors > color {
             let s = expand(self.ti
                                .strings
-                               .find_equiv("setab")
+                               .get("setab")
                                .unwrap()
                                .as_slice(),
                            &[Number(color as int)], &mut Variables::new());
@@ -113,7 +113,7 @@ fn attr(&mut self, attr: attr::Attr) -> IoResult<bool> {
             attr::BackgroundColor(c) => self.bg(c),
             _ => {
                 let cap = cap_for_attr(attr);
-                let parm = self.ti.strings.find_equiv(cap);
+                let parm = self.ti.strings.get(cap);
                 if parm.is_some() {
                     let s = expand(parm.unwrap().as_slice(),
                                    &[],
@@ -135,19 +135,19 @@ fn supports_attr(&self, attr: attr::Attr) -> bool {
             }
             _ => {
                 let cap = cap_for_attr(attr);
-                self.ti.strings.find_equiv(cap).is_some()
+                self.ti.strings.get(cap).is_some()
             }
         }
     }
 
     fn reset(&mut self) -> IoResult<()> {
-        let mut cap = self.ti.strings.find_equiv("sgr0");
+        let mut cap = self.ti.strings.get("sgr0");
         if cap.is_none() {
             // are there any terminals that have color/attrs and not sgr0?
             // Try falling back to sgr, then op
-            cap = self.ti.strings.find_equiv("sgr");
+            cap = self.ti.strings.get("sgr");
             if cap.is_none() {
-                cap = self.ti.strings.find_equiv("op");
+                cap = self.ti.strings.get("op");
             }
         }
         let s = cap.map_or(Err("can't find terminfo capability `sgr0`".to_string()), |op| {
@@ -202,9 +202,9 @@ pub fn new(out: T) -> Option<Box<Terminal<T>+Send+'static>> {
         }
 
         let inf = ti.unwrap();
-        let nc = if inf.strings.find_equiv("setaf").is_some()
-                 && inf.strings.find_equiv("setab").is_some() {
-                     inf.numbers.find_equiv("colors").map_or(0, |&n| n)
+        let nc = if inf.strings.get("setaf").is_some()
+                 && inf.strings.get("setab").is_some() {
+                     inf.numbers.get("colors").map_or(0, |&n| n)
                  } else { 0 };
 
         return Some(box TerminfoTerminal {out: out,
index e40c477ec66effb5f91dc4cecb977cffe9a6cd64..e39cd743ad55ac75d921912f1a419eac21df1cb3 100644 (file)
@@ -76,7 +76,7 @@ fn sortKV(mut orig: Vec<(Vec<u8> ,f64)> ) -> Vec<(Vec<u8> ,f64)> {
 // given a map, search for the frequency of a pattern
 fn find(mm: &HashMap<Vec<u8> , uint>, key: String) -> uint {
    let key = key.into_ascii().as_slice().to_lowercase().into_string();
-   match mm.find_equiv(key.as_bytes()) {
+   match mm.get(key.as_bytes()) {
       option::None      => { return 0u; }
       option::Some(&num) => { return num; }
    }