about summary refs log tree commit diff
path: root/src/test
diff options
context:
space:
mode:
authorJeffrey Seyfried <jeffrey.seyfried@gmail.com>2016-11-04 09:07:00 +0000
committerJeffrey Seyfried <jeffrey.seyfried@gmail.com>2016-11-04 09:07:00 +0000
commit51104e5ca60177b9f646f0c906eac358050664b7 (patch)
tree61caef4bedee35dc832f6cf59bc968371572d752 /src/test
parentb7eed53b55d43c8d63ede9e8e45c532e9cc83cc2 (diff)
Fix fallout in tests.
Diffstat (limited to 'src/test')
-rw-r--r--src/test/run-pass-fulldeps/auxiliary/procedural_mbe_matching.rs61
1 files changed, 33 insertions, 28 deletions
diff --git a/src/test/run-pass-fulldeps/auxiliary/procedural_mbe_matching.rs b/src/test/run-pass-fulldeps/auxiliary/procedural_mbe_matching.rs
index 5229d42f1fd..6ac0d5ad1a3 100644
--- a/src/test/run-pass-fulldeps/auxiliary/procedural_mbe_matching.rs
+++ b/src/test/run-pass-fulldeps/auxiliary/procedural_mbe_matching.rs
@@ -18,10 +18,10 @@ extern crate syntax_pos;
 extern crate rustc;
 extern crate rustc_plugin;
 
-use syntax::parse::token::{self, str_to_ident, NtExpr, NtPat};
+use syntax::parse::token::{str_to_ident, NtExpr, NtPat};
 use syntax::ast::{Pat};
 use syntax::tokenstream::{TokenTree};
-use syntax::ext::base::{ExtCtxt, MacResult, DummyResult, MacEager};
+use syntax::ext::base::{ExtCtxt, MacResult, MacEager};
 use syntax::ext::build::AstBuilder;
 use syntax::ext::tt::macro_parser::{MatchedSeq, MatchedNonterminal};
 use syntax::ext::tt::macro_parser::{Success, Failure, Error};
@@ -30,35 +30,12 @@ use syntax::ptr::P;
 use syntax_pos::Span;
 use rustc_plugin::Registry;
 
-fn expand_mbe_matches(cx: &mut ExtCtxt, sp: Span, args: &[TokenTree])
+fn expand_mbe_matches(cx: &mut ExtCtxt, _: Span, args: &[TokenTree])
         -> Box<MacResult + 'static> {
 
     let mbe_matcher = quote_matcher!(cx, $matched:expr, $($pat:pat)|+);
-
-    let mac_expr = match TokenTree::parse(cx, &mbe_matcher[..], args) {
-        Success(map) => {
-            match (&*map[&str_to_ident("matched")], &*map[&str_to_ident("pat")]) {
-                (&MatchedNonterminal(NtExpr(ref matched_expr)),
-                 &MatchedSeq(ref pats, seq_sp)) => {
-                    let pats: Vec<P<Pat>> = pats.iter().map(|pat_nt|
-                        if let &MatchedNonterminal(NtPat(ref pat)) = &**pat_nt {
-                            pat.clone()
-                        } else {
-                            unreachable!()
-                        }
-                    ).collect();
-                    let arm = cx.arm(seq_sp, pats, cx.expr_bool(seq_sp, true));
-
-                    quote_expr!(cx,
-                        match $matched_expr {
-                            $arm
-                            _ => false
-                        }
-                    )
-                }
-                _ => unreachable!()
-            }
-        }
+    let map = match TokenTree::parse(cx, &mbe_matcher, args) {
+        Success(map) => map,
         Failure(_, tok) => {
             panic!("expected Success, but got Failure: {}", parse_failure_msg(tok));
         }
@@ -67,6 +44,34 @@ fn expand_mbe_matches(cx: &mut ExtCtxt, sp: Span, args: &[TokenTree])
         }
     };
 
+    let matched_nt = match *map[&str_to_ident("matched")] {
+        MatchedNonterminal(ref nt) => nt.clone(),
+        _ => unreachable!(),
+    };
+
+    let mac_expr = match (&*matched_nt, &*map[&str_to_ident("pat")]) {
+        (&NtExpr(ref matched_expr), &MatchedSeq(ref pats, seq_sp)) => {
+            let pats: Vec<P<Pat>> = pats.iter().map(|pat_nt| {
+                match **pat_nt {
+                    MatchedNonterminal(ref nt) => match **nt {
+                        NtPat(ref pat) => pat.clone(),
+                        _ => unreachable!(),
+                    },
+                    _ => unreachable!(),
+                }
+            }).collect();
+            let arm = cx.arm(seq_sp, pats, cx.expr_bool(seq_sp, true));
+
+            quote_expr!(cx,
+                match $matched_expr {
+                    $arm
+                    _ => false
+                }
+            )
+        }
+        _ => unreachable!()
+    };
+
     MacEager::expr(mac_expr)
 }