about summary refs log tree commit diff
path: root/src/libsyntax/parse
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2013-03-26 16:21:59 -0700
committerbors <bors@rust-lang.org>2013-03-26 16:21:59 -0700
commitfa82b9af2ae1f5a32a6f0d34366f0a26aee151d6 (patch)
tree65b4789c0d2ba30391c2cef2681c753bc4e40ff6 /src/libsyntax/parse
parent3d588c528685fa0590ff91f189f0ef44a3815ec2 (diff)
parentd69108d8f78a9b5a8669606b62fe6df6409d17e7 (diff)
downloadrust-fa82b9af2ae1f5a32a6f0d34366f0a26aee151d6.tar.gz
rust-fa82b9af2ae1f5a32a6f0d34366f0a26aee151d6.zip
auto merge of #5523 : alexcrichton/rust/less-oldmap, r=thestinger
I started out just removing a few instances of `HashMap` throughout rustc, but it ended up snowballing to remove the entire thing. Most uses translated to just using `@mut LinearMap` instead of `HashMap`, although I tried where possible to drop the `@mut` modifier. This ended up working out some of the time, but definitely not in the major use cases.

Things got kinda weird in some cases like:

* https://github.com/alexcrichton/rust/compare/mozilla:a56ec8c1342453a88be79e192a11501844375d40...alexcrichton:621b63300358cacad088ddd7f78180f29c40e66e#L39R1587
* https://github.com/alexcrichton/rust/compare/mozilla:a56ec8c1342453a88be79e192a11501844375d40...alexcrichton:621b63300358cacad088ddd7f78180f29c40e66e#L61R3760
* https://github.com/alexcrichton/rust/compare/mozilla:a56ec8c1342453a88be79e192a11501844375d40...alexcrichton:621b63300358cacad088ddd7f78180f29c40e66e#L71R917
* https://github.com/alexcrichton/rust/compare/mozilla:a56ec8c1342453a88be79e192a11501844375d40...alexcrichton:621b63300358cacad088ddd7f78180f29c40e66e#L91R127

I tried to tag them all with bugs which I thought would make them less weird, but I may have the wrong bug in a few places. These cases only came up when I tried to pass around `&mut LinearMap` instead of an `@mut LinearMap`.

I also ran into a few bugs when migrating to `LinearMap`, one of which is #5521. There's another set of bugs which a00d779042fb8753c716e07b4f1aac0d5ab7bf66 addresses (all marked with `XXX`). I have a feeling they're all the same bug, but all I've been able is to reproduce them. I tried to whittle down the test cases and try to get some input which causes a failure, but I've been unable to do so. All I know is that it's vaguely related to `*T` pointers being used as `&*T` (return value of `find`). I'm not able to open a very descriptive issue, but I'll do so if there seems no other better route.

I realize this is a very large pull request, so if it'd be better to split this up into multiple segments I'd be more than willing to do so. So far the tests all pass locally, although I'm sure bors will turn something up. I also don't mind keeping this up to date with rebasing. This maybe should wait until after 0.6 because it is a fairly large change...
Diffstat (limited to 'src/libsyntax/parse')
-rw-r--r--src/libsyntax/parse/common.rs8
-rw-r--r--src/libsyntax/parse/obsolete.rs4
-rw-r--r--src/libsyntax/parse/parser.rs12
-rw-r--r--src/libsyntax/parse/token.rs54
4 files changed, 38 insertions, 40 deletions
diff --git a/src/libsyntax/parse/common.rs b/src/libsyntax/parse/common.rs
index ea599e8290a..c14c7bed139 100644
--- a/src/libsyntax/parse/common.rs
+++ b/src/libsyntax/parse/common.rs
@@ -129,7 +129,7 @@ pub impl Parser {
 
     // A sanity check that the word we are asking for is a known keyword
     fn require_keyword(&self, word: &~str) {
-        if !self.keywords.contains_key(word) {
+        if !self.keywords.contains(word) {
             self.bug(fmt!("unknown keyword: %s", *word));
         }
     }
@@ -153,7 +153,7 @@ pub impl Parser {
     fn is_any_keyword(&self, tok: &token::Token) -> bool {
         match *tok {
           token::IDENT(sid, false) => {
-            self.keywords.contains_key(self.id_to_str(sid))
+            self.keywords.contains(self.id_to_str(sid))
           }
           _ => false
         }
@@ -183,7 +183,7 @@ pub impl Parser {
     }
 
     fn is_strict_keyword(&self, word: &~str) -> bool {
-        self.strict_keywords.contains_key(word)
+        self.strict_keywords.contains(word)
     }
 
     fn check_strict_keywords(&self) {
@@ -203,7 +203,7 @@ pub impl Parser {
     }
 
     fn is_reserved_keyword(&self, word: &~str) -> bool {
-        self.reserved_keywords.contains_key(word)
+        self.reserved_keywords.contains(word)
     }
 
     fn check_reserved_keywords(&self) {
diff --git a/src/libsyntax/parse/obsolete.rs b/src/libsyntax/parse/obsolete.rs
index 0f4de9257c9..32c8b88aed8 100644
--- a/src/libsyntax/parse/obsolete.rs
+++ b/src/libsyntax/parse/obsolete.rs
@@ -225,9 +225,9 @@ pub impl Parser {
                    desc: &str) {
         self.span_err(sp, fmt!("obsolete syntax: %s", kind_str));
 
-        if !self.obsolete_set.contains_key(&kind) {
+        if !self.obsolete_set.contains(&kind) {
             self.sess.span_diagnostic.handler().note(fmt!("%s", desc));
-            self.obsolete_set.insert(kind, ());
+            self.obsolete_set.insert(kind);
         }
     }
 
diff --git a/src/libsyntax/parse/parser.rs b/src/libsyntax/parse/parser.rs
index af64bf07b7c..171cd90bcd2 100644
--- a/src/libsyntax/parse/parser.rs
+++ b/src/libsyntax/parse/parser.rs
@@ -92,8 +92,8 @@ use opt_vec::OptVec;
 
 use core::either::{Either, Left, Right};
 use core::either;
+use core::hashmap::linear::LinearSet;
 use core::vec;
-use std::oldmap::HashMap;
 
 #[deriving(Eq)]
 enum restriction {
@@ -240,7 +240,7 @@ pub fn Parser(sess: @mut ParseSess,
         keywords: token::keyword_table(),
         strict_keywords: token::strict_keyword_table(),
         reserved_keywords: token::reserved_keyword_table(),
-        obsolete_set: HashMap(),
+        obsolete_set: @mut LinearSet::new(),
         mod_path_stack: @mut ~[],
     }
 }
@@ -259,12 +259,12 @@ pub struct Parser {
     quote_depth: @mut uint, // not (yet) related to the quasiquoter
     reader: @reader,
     interner: @token::ident_interner,
-    keywords: HashMap<~str, ()>,
-    strict_keywords: HashMap<~str, ()>,
-    reserved_keywords: HashMap<~str, ()>,
+    keywords: LinearSet<~str>,
+    strict_keywords: LinearSet<~str>,
+    reserved_keywords: LinearSet<~str>,
     /// The set of seen errors about obsolete syntax. Used to suppress
     /// extra detail when the same error is seen twice
-    obsolete_set: HashMap<ObsoleteSyntax, ()>,
+    obsolete_set: @mut LinearSet<ObsoleteSyntax>,
     /// Used to determine the path to externally loaded source files
     mod_path_stack: @mut ~[~str],
 
diff --git a/src/libsyntax/parse/token.rs b/src/libsyntax/parse/token.rs
index 074bb13e199..5fdf6f7620c 100644
--- a/src/libsyntax/parse/token.rs
+++ b/src/libsyntax/parse/token.rs
@@ -18,9 +18,9 @@ use util::interner;
 
 use core::cast;
 use core::char;
+use core::hashmap::linear::LinearSet;
 use core::str;
 use core::task;
-use std::oldmap::HashMap;
 
 #[auto_encode]
 #[auto_decode]
@@ -458,35 +458,33 @@ pub fn mk_fake_ident_interner() -> @ident_interner {
  * appear as identifiers at all. Reserved keywords are not used anywhere in
  * the language and may not appear as identifiers.
  */
-pub fn keyword_table() -> HashMap<~str, ()> {
-    let keywords = HashMap();
-    for temporary_keyword_table().each_key |&word| {
-        keywords.insert(word, ());
-    }
-    for strict_keyword_table().each_key |&word| {
-        keywords.insert(word, ());
-    }
-    for reserved_keyword_table().each_key |&word| {
-        keywords.insert(word, ());
-    }
-    keywords
+pub fn keyword_table() -> LinearSet<~str> {
+    let mut keywords = LinearSet::new();
+    let mut tmp = temporary_keyword_table();
+    let mut strict = strict_keyword_table();
+    let mut reserved = reserved_keyword_table();
+
+    do tmp.consume |word|      { keywords.insert(word); }
+    do strict.consume |word|   { keywords.insert(word); }
+    do reserved.consume |word| { keywords.insert(word); }
+    return keywords;
 }
 
 /// Keywords that may be used as identifiers
-pub fn temporary_keyword_table() -> HashMap<~str, ()> {
-    let words = HashMap();
+pub fn temporary_keyword_table() -> LinearSet<~str> {
+    let mut words = LinearSet::new();
     let keys = ~[
         ~"self", ~"static",
     ];
-    for keys.each |word| {
-        words.insert(copy *word, ());
+    do vec::consume(keys) |_, s| {
+        words.insert(s);
     }
-    words
+    return words;
 }
 
 /// Full keywords. May not appear anywhere else.
-pub fn strict_keyword_table() -> HashMap<~str, ()> {
-    let words = HashMap();
+pub fn strict_keyword_table() -> LinearSet<~str> {
+    let mut words = LinearSet::new();
     let keys = ~[
         ~"as",
         ~"break",
@@ -505,21 +503,21 @@ pub fn strict_keyword_table() -> HashMap<~str, ()> {
         ~"unsafe", ~"use",
         ~"while"
     ];
-    for keys.each |word| {
-        words.insert(copy *word, ());
+    do vec::consume(keys) |_, w| {
+        words.insert(w);
     }
-    words
+    return words;
 }
 
-pub fn reserved_keyword_table() -> HashMap<~str, ()> {
-    let words = HashMap();
+pub fn reserved_keyword_table() -> LinearSet<~str> {
+    let mut words = LinearSet::new();
     let keys = ~[
         ~"be"
     ];
-    for keys.each |word| {
-        words.insert(copy *word, ());
+    do vec::consume(keys) |_, s| {
+        words.insert(s);
     }
-    words
+    return words;
 }