summary refs log tree commit diff
path: root/src/libsyntax/ext
diff options
context:
space:
mode:
authorAlex Crichton <alex@alexcrichton.com>2013-03-21 15:41:37 -0400
committerAlex Crichton <alex@alexcrichton.com>2013-03-26 19:20:02 -0400
commite4c3d805a4d8151158abbddf990a5430529b829f (patch)
tree71a30e4b910586a55681a68bd6a5045dff9fc143 /src/libsyntax/ext
parentfa7772893a63e6ac83ab461f80fb1f35c8633325 (diff)
downloadrust-e4c3d805a4d8151158abbddf990a5430529b829f.tar.gz
rust-e4c3d805a4d8151158abbddf990a5430529b829f.zip
syntax: Removing uses of HashMap
Diffstat (limited to 'src/libsyntax/ext')
-rw-r--r--src/libsyntax/ext/tt/macro_parser.rs16
-rw-r--r--src/libsyntax/ext/tt/macro_rules.rs4
-rw-r--r--src/libsyntax/ext/tt/transcribe.rs12
3 files changed, 18 insertions, 14 deletions
diff --git a/src/libsyntax/ext/tt/macro_parser.rs b/src/libsyntax/ext/tt/macro_parser.rs
index 70b639d6648..b7ba9c5c6c0 100644
--- a/src/libsyntax/ext/tt/macro_parser.rs
+++ b/src/libsyntax/ext/tt/macro_parser.rs
@@ -186,9 +186,9 @@ pub enum named_match {
 pub type earley_item = ~MatcherPos;
 
 pub fn nameize(p_s: @mut ParseSess, ms: ~[matcher], res: ~[@named_match])
-            -> HashMap<ident,@named_match> {
+            -> LinearMap<ident,@named_match> {
     fn n_rec(p_s: @mut ParseSess, m: matcher, res: ~[@named_match],
-             ret_val: HashMap<ident, @named_match>) {
+             ret_val: &mut LinearMap<ident, @named_match>) {
         match m {
           codemap::spanned {node: match_tok(_), _} => (),
           codemap::spanned {node: match_seq(ref more_ms, _, _, _, _), _} => {
@@ -207,13 +207,13 @@ pub fn nameize(p_s: @mut ParseSess, ms: ~[matcher], res: ~[@named_match])
           }
         }
     }
-    let ret_val = HashMap();
-    for ms.each() |m| { n_rec(p_s, *m, res, ret_val) }
+    let mut ret_val = LinearMap::new();
+    for ms.each() |m| { n_rec(p_s, *m, res, &mut ret_val) }
     return ret_val;
 }
 
 pub enum parse_result {
-    success(HashMap<ident, @named_match>),
+    success(LinearMap<ident, @named_match>),
     failure(codemap::span, ~str),
     error(codemap::span, ~str)
 }
@@ -223,11 +223,11 @@ pub fn parse_or_else(
     +cfg: ast::crate_cfg,
     rdr: @reader,
     ms: ~[matcher]
-) -> HashMap<ident, @named_match> {
+) -> LinearMap<ident, @named_match> {
     match parse(sess, cfg, rdr, ms) {
       success(m) => m,
-      failure(sp, ref str) => sess.span_diagnostic.span_fatal(sp, (*str)),
-      error(sp, ref str) => sess.span_diagnostic.span_fatal(sp, (*str))
+      failure(sp, str) => sess.span_diagnostic.span_fatal(sp, str),
+      error(sp, str) => sess.span_diagnostic.span_fatal(sp, str)
     }
 }
 
diff --git a/src/libsyntax/ext/tt/macro_rules.rs b/src/libsyntax/ext/tt/macro_rules.rs
index 5a6fd6fec58..6bd72b95109 100644
--- a/src/libsyntax/ext/tt/macro_rules.rs
+++ b/src/libsyntax/ext/tt/macro_rules.rs
@@ -63,12 +63,12 @@ pub fn add_new_extension(cx: @ext_ctxt,
                                      argument_gram);
 
     // Extract the arguments:
-    let lhses = match argument_map.get(&lhs_nm) {
+    let lhses = match *argument_map.get(&lhs_nm) {
         @matched_seq(ref s, _) => /* FIXME (#2543) */ copy *s,
         _ => cx.span_bug(sp, ~"wrong-structured lhs")
     };
 
-    let rhses = match argument_map.get(&rhs_nm) {
+    let rhses = match *argument_map.get(&rhs_nm) {
       @matched_seq(ref s, _) => /* FIXME (#2543) */ copy *s,
       _ => cx.span_bug(sp, ~"wrong-structured rhs")
     };
diff --git a/src/libsyntax/ext/tt/transcribe.rs b/src/libsyntax/ext/tt/transcribe.rs
index a0d90a0c70b..67c2f438269 100644
--- a/src/libsyntax/ext/tt/transcribe.rs
+++ b/src/libsyntax/ext/tt/transcribe.rs
@@ -18,6 +18,7 @@ use ext::tt::macro_parser::{named_match, matched_seq, matched_nonterminal};
 use parse::token::{EOF, INTERPOLATED, IDENT, Token, nt_ident, ident_interner};
 use parse::lexer::TokenAndSpan;
 
+use core::hashmap::linear::LinearMap;
 use core::option;
 use core::vec;
 
@@ -38,7 +39,7 @@ pub struct TtReader {
     // the unzipped tree:
     cur: @mut TtFrame,
     /* for MBE-style macro transcription */
-    interpolations: std::oldmap::HashMap<ident, @named_match>,
+    interpolations: LinearMap<ident, @named_match>,
     repeat_idx: ~[uint],
     repeat_len: ~[uint],
     /* cached: */
@@ -51,7 +52,7 @@ pub struct TtReader {
  *  should) be none. */
 pub fn new_tt_reader(sp_diag: @span_handler,
                      itr: @ident_interner,
-                     interp: Option<std::oldmap::HashMap<ident,@named_match>>,
+                     interp: Option<LinearMap<ident,@named_match>>,
                      +src: ~[ast::token_tree])
                   -> @mut TtReader {
     let r = @mut TtReader {
@@ -65,7 +66,7 @@ pub fn new_tt_reader(sp_diag: @span_handler,
             up: option::None
         },
         interpolations: match interp { /* just a convienience */
-            None => std::oldmap::HashMap(),
+            None => LinearMap::new(),
             Some(x) => x
         },
         repeat_idx: ~[],
@@ -123,7 +124,10 @@ fn lookup_cur_matched_by_matched(r: &mut TtReader,
 }
 
 fn lookup_cur_matched(r: &mut TtReader, name: ident) -> @named_match {
-    lookup_cur_matched_by_matched(r, r.interpolations.get(&name))
+    // FIXME (#3850): this looks a bit silly with an extra scope.
+    let start;
+    { start = *r.interpolations.get(&name); }
+    return lookup_cur_matched_by_matched(r, start);
 }
 enum lis {
     lis_unconstrained, lis_constraint(uint, ident), lis_contradiction(~str)