about summary refs log tree commit diff
path: root/src/libsyntax/ext
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2014-10-31 02:27:15 +0000
committerbors <bors@rust-lang.org>2014-10-31 02:27:15 +0000
commit221fc1e3cdcc208e1bb7debcc2de27d47c847747 (patch)
tree5e2d393fe5a4a94cd6a09d93f4ddcf5a4f6aecaa /src/libsyntax/ext
parenta12d06b73fcb38cf23dfe71da725428a1094395f (diff)
parent6fcba8826fd26028341a35d88b07208378ac05ea (diff)
downloadrust-221fc1e3cdcc208e1bb7debcc2de27d47c847747.tar.gz
rust-221fc1e3cdcc208e1bb7debcc2de27d47c847747.zip
auto merge of #18459 : alexcrichton/rust/rollup, r=alexcrichton
Diffstat (limited to 'src/libsyntax/ext')
-rw-r--r--src/libsyntax/ext/asm.rs8
-rw-r--r--src/libsyntax/ext/base.rs2
-rw-r--r--src/libsyntax/ext/format.rs4
-rw-r--r--src/libsyntax/ext/quote.rs34
-rw-r--r--src/libsyntax/ext/tt/macro_parser.rs16
-rw-r--r--src/libsyntax/ext/tt/macro_rules.rs5
-rw-r--r--src/libsyntax/ext/tt/transcribe.rs14
7 files changed, 42 insertions, 41 deletions
diff --git a/src/libsyntax/ext/asm.rs b/src/libsyntax/ext/asm.rs
index 2b52b7feacc..d57d6e52d7f 100644
--- a/src/libsyntax/ext/asm.rs
+++ b/src/libsyntax/ext/asm.rs
@@ -84,9 +84,9 @@ pub fn expand_asm<'cx>(cx: &'cx mut ExtCtxt, sp: Span, tts: &[ast::TokenTree])
 
                     let span = p.last_span;
 
-                    p.expect(&token::LParen);
+                    p.expect(&token::OpenDelim(token::Paren));
                     let out = p.parse_expr();
-                    p.expect(&token::RParen);
+                    p.expect(&token::CloseDelim(token::Paren));
 
                     // Expands a read+write operand into two operands.
                     //
@@ -129,9 +129,9 @@ pub fn expand_asm<'cx>(cx: &'cx mut ExtCtxt, sp: Span, tts: &[ast::TokenTree])
                         cx.span_err(p.last_span, "input operand constraint contains '+'");
                     }
 
-                    p.expect(&token::LParen);
+                    p.expect(&token::OpenDelim(token::Paren));
                     let input = p.parse_expr();
-                    p.expect(&token::RParen);
+                    p.expect(&token::CloseDelim(token::Paren));
 
                     inputs.push((constraint, input));
                 }
diff --git a/src/libsyntax/ext/base.rs b/src/libsyntax/ext/base.rs
index a8326e79ef3..e641abbfeee 100644
--- a/src/libsyntax/ext/base.rs
+++ b/src/libsyntax/ext/base.rs
@@ -785,6 +785,6 @@ impl SyntaxEnv {
 
     pub fn info<'a>(&'a mut self) -> &'a mut BlockInfo {
         let last_chain_index = self.chain.len() - 1;
-        &mut self.chain.get_mut(last_chain_index).info
+        &mut self.chain[last_chain_index].info
     }
 }
diff --git a/src/libsyntax/ext/format.rs b/src/libsyntax/ext/format.rs
index 1b12ae67ee5..fa9a844233a 100644
--- a/src/libsyntax/ext/format.rs
+++ b/src/libsyntax/ext/format.rs
@@ -247,7 +247,7 @@ impl<'a, 'b> Context<'a, 'b> {
                     self.verify_same(self.args[arg].span, &ty, arg_type);
                 }
                 if self.arg_types[arg].is_none() {
-                    *self.arg_types.get_mut(arg) = Some(ty);
+                    self.arg_types[arg] = Some(ty);
                 }
             }
 
@@ -567,7 +567,7 @@ impl<'a, 'b> Context<'a, 'b> {
             let lname = self.ecx.ident_of(format!("__arg{}",
                                                   *name).as_slice());
             pats.push(self.ecx.pat_ident(e.span, lname));
-            *names.get_mut(self.name_positions[*name]) =
+            names[self.name_positions[*name]] =
                 Some(Context::format_arg(self.ecx, e.span, arg_ty,
                                          self.ecx.expr_ident(e.span, lname)));
             heads.push(self.ecx.expr_addr_of(e.span, e));
diff --git a/src/libsyntax/ext/quote.rs b/src/libsyntax/ext/quote.rs
index a95a737720a..f751655c9ff 100644
--- a/src/libsyntax/ext/quote.rs
+++ b/src/libsyntax/ext/quote.rs
@@ -531,7 +531,16 @@ fn mk_binop(cx: &ExtCtxt, sp: Span, bop: token::BinOpToken) -> P<ast::Expr> {
     mk_token_path(cx, sp, name)
 }
 
-#[allow(non_uppercase_statics)] // NOTE(stage0): remove this attribute after the next snapshot
+fn mk_delim(cx: &ExtCtxt, sp: Span, delim: token::DelimToken) -> P<ast::Expr> {
+    let name = match delim {
+        token::Paren     => "Paren",
+        token::Bracket   => "Bracket",
+        token::Brace     => "Brace",
+    };
+    mk_token_path(cx, sp, name)
+}
+
+#[allow(non_upper_case_globals)]
 fn mk_token(cx: &ExtCtxt, sp: Span, tok: &token::Token) -> P<ast::Expr> {
     match *tok {
         token::BinOp(binop) => {
@@ -542,6 +551,15 @@ fn mk_token(cx: &ExtCtxt, sp: Span, tok: &token::Token) -> P<ast::Expr> {
                                 vec!(mk_binop(cx, sp, binop)));
         }
 
+        token::OpenDelim(delim) => {
+            return cx.expr_call(sp, mk_token_path(cx, sp, "OpenDelim"),
+                                vec![mk_delim(cx, sp, delim)]);
+        }
+        token::CloseDelim(delim) => {
+            return cx.expr_call(sp, mk_token_path(cx, sp, "CloseDelim"),
+                                vec![mk_delim(cx, sp, delim)]);
+        }
+
         token::LitByte(i) => {
             let e_byte = mk_name(cx, sp, i.ident());
 
@@ -625,12 +643,6 @@ fn mk_token(cx: &ExtCtxt, sp: Span, tok: &token::Token) -> P<ast::Expr> {
         token::RArrow       => "RArrow",
         token::LArrow       => "LArrow",
         token::FatArrow     => "FatArrow",
-        token::LParen       => "LParen",
-        token::RParen       => "RParen",
-        token::LBracket     => "LBracket",
-        token::RBracket     => "RBracket",
-        token::LBrace       => "LBrace",
-        token::RBrace       => "RBrace",
         token::Pound        => "Pound",
         token::Dollar       => "Dollar",
         token::Underscore   => "Underscore",
@@ -640,7 +652,6 @@ fn mk_token(cx: &ExtCtxt, sp: Span, tok: &token::Token) -> P<ast::Expr> {
     mk_token_path(cx, sp, name)
 }
 
-
 fn mk_tt(cx: &ExtCtxt, _: Span, tt: &ast::TokenTree) -> Vec<P<ast::Stmt>> {
     match *tt {
         ast::TtToken(sp, ref tok) => {
@@ -656,10 +667,9 @@ fn mk_tt(cx: &ExtCtxt, _: Span, tt: &ast::TokenTree) -> Vec<P<ast::Stmt>> {
             vec!(cx.stmt_expr(e_push))
         },
         ast::TtDelimited(sp, ref delimed) => {
-            let (ref open, ref tts, ref close) = **delimed;
-            mk_tt(cx, sp, &open.to_tt()).into_iter()
-                .chain(tts.iter().flat_map(|tt| mk_tt(cx, sp, tt).into_iter()))
-                .chain(mk_tt(cx, sp, &close.to_tt()).into_iter())
+            mk_tt(cx, sp, &delimed.open_tt()).into_iter()
+                .chain(delimed.tts.iter().flat_map(|tt| mk_tt(cx, sp, tt).into_iter()))
+                .chain(mk_tt(cx, sp, &delimed.close_tt()).into_iter())
                 .collect()
         },
         ast::TtSequence(..) => panic!("TtSequence in quote!"),
diff --git a/src/libsyntax/ext/tt/macro_parser.rs b/src/libsyntax/ext/tt/macro_parser.rs
index 9260a45adb9..b522d5881d7 100644
--- a/src/libsyntax/ext/tt/macro_parser.rs
+++ b/src/libsyntax/ext/tt/macro_parser.rs
@@ -288,8 +288,7 @@ pub fn parse(sess: &ParseSess,
                         // Only touch the binders we have actually bound
                         for idx in range(ei.match_lo, ei.match_hi) {
                             let sub = (ei.matches[idx]).clone();
-                            new_pos.matches
-                                   .get_mut(idx)
+                            new_pos.matches[idx]
                                    .push(Rc::new(MatchedSeq(sub, mk_sp(ei.sp_lo,
                                                                        sp.hi))));
                         }
@@ -331,8 +330,7 @@ pub fn parse(sess: &ParseSess,
                         new_ei.idx += 1u;
                         //we specifically matched zero repeats.
                         for idx in range(match_idx_lo, match_idx_hi) {
-                            new_ei.matches
-                                  .get_mut(idx)
+                            new_ei.matches[idx]
                                   .push(Rc::new(MatchedSeq(Vec::new(), sp)));
                         }
 
@@ -355,10 +353,8 @@ pub fn parse(sess: &ParseSess,
                     // Built-in nonterminals never start with these tokens,
                     // so we can eliminate them from consideration.
                     match tok {
-                        token::RParen |
-                        token::RBrace |
-                        token::RBracket => {},
-                        _ => bb_eis.push(ei)
+                        token::CloseDelim(_) => {},
+                        _ => bb_eis.push(ei),
                     }
                   }
                   MatchTok(ref t) => {
@@ -376,7 +372,7 @@ pub fn parse(sess: &ParseSess,
         if token_name_eq(&tok, &token::Eof) {
             if eof_eis.len() == 1u {
                 let mut v = Vec::new();
-                for dv in eof_eis.get_mut(0).matches.iter_mut() {
+                for dv in eof_eis[0].matches.iter_mut() {
                     v.push(dv.pop().unwrap());
                 }
                 return Success(nameize(sess, ms, v.as_slice()));
@@ -417,7 +413,7 @@ pub fn parse(sess: &ParseSess,
                 match ei.elts[ei.idx].node {
                   MatchNonterminal(_, name, idx) => {
                     let name_string = token::get_ident(name);
-                    ei.matches.get_mut(idx).push(Rc::new(MatchedNonterminal(
+                    ei.matches[idx].push(Rc::new(MatchedNonterminal(
                         parse_nt(&mut rust_parser, name_string.get()))));
                     ei.idx += 1u;
                   }
diff --git a/src/libsyntax/ext/tt/macro_rules.rs b/src/libsyntax/ext/tt/macro_rules.rs
index 85bd5cde304..e50d4457af2 100644
--- a/src/libsyntax/ext/tt/macro_rules.rs
+++ b/src/libsyntax/ext/tt/macro_rules.rs
@@ -172,10 +172,7 @@ fn generic_extension<'cx>(cx: &'cx ExtCtxt,
                     MatchedNonterminal(NtTT(ref tt)) => {
                         match **tt {
                             // ignore delimiters
-                            TtDelimited(_, ref delimed) => {
-                                let (_, ref tts, _) = **delimed;
-                                tts.clone()
-                            },
+                            TtDelimited(_, ref delimed) => delimed.tts.clone(),
                             _ => cx.span_fatal(sp, "macro rhs must be delimited"),
                         }
                     },
diff --git a/src/libsyntax/ext/tt/transcribe.rs b/src/libsyntax/ext/tt/transcribe.rs
index 2c7b583d460..249a985a648 100644
--- a/src/libsyntax/ext/tt/transcribe.rs
+++ b/src/libsyntax/ext/tt/transcribe.rs
@@ -129,8 +129,7 @@ impl Add<LockstepIterSize, LockstepIterSize> for LockstepIterSize {
 fn lockstep_iter_size(t: &TokenTree, r: &TtReader) -> LockstepIterSize {
     match *t {
         TtDelimited(_, ref delimed) => {
-            let (_, ref tts, _) = **delimed;
-            tts.iter().fold(LisUnconstrained, |size, tt| {
+            delimed.tts.iter().fold(LisUnconstrained, |size, tt| {
                 size + lockstep_iter_size(tt, r)
             })
         },
@@ -207,14 +206,13 @@ pub fn tt_next_token(r: &mut TtReader) -> TokenAndSpan {
         };
         match t {
             TtDelimited(_, ref delimed) => {
-                let (ref open, ref tts, ref close) = **delimed;
-                let mut forest = Vec::with_capacity(1 + tts.len() + 1);
-                forest.push(open.to_tt());
-                forest.extend(tts.iter().map(|x| (*x).clone()));
-                forest.push(close.to_tt());
+                let mut tts = Vec::with_capacity(1 + delimed.tts.len() + 1);
+                tts.push(delimed.open_tt());
+                tts.extend(delimed.tts.iter().map(|tt| tt.clone()));
+                tts.push(delimed.close_tt());
 
                 r.stack.push(TtFrame {
-                    forest: Rc::new(forest),
+                    forest: Rc::new(tts),
                     idx: 0,
                     dotdotdoted: false,
                     sep: None