about summary refs log tree commit diff
path: root/src/libsyntax/ext
diff options
context:
space:
mode:
authorAlex Crichton <alex@alexcrichton.com>2013-05-02 18:33:33 -0400
committerAlex Crichton <alex@alexcrichton.com>2013-05-10 02:46:18 -0400
commit5eb6d19803ebcb5279f8a42b584a4d81152fa82d (patch)
treef64e9e944ccaaf83b8a993c0ce1c404f22c9cd41 /src/libsyntax/ext
parent3ce9dba6775c7e1dbfb510626c073a8f926b6880 (diff)
downloadrust-5eb6d19803ebcb5279f8a42b584a4d81152fa82d.tar.gz
rust-5eb6d19803ebcb5279f8a42b584a4d81152fa82d.zip
syntax: Use the new `for` protocol
Diffstat (limited to 'src/libsyntax/ext')
-rw-r--r--src/libsyntax/ext/expand.rs14
-rw-r--r--src/libsyntax/ext/pipes/proto.rs16
2 files changed, 18 insertions, 12 deletions
diff --git a/src/libsyntax/ext/expand.rs b/src/libsyntax/ext/expand.rs
index 68c74c2d12b..5129fa6ebd2 100644
--- a/src/libsyntax/ext/expand.rs
+++ b/src/libsyntax/ext/expand.rs
@@ -195,18 +195,8 @@ pub fn expand_item(extsbox: @mut SyntaxEnv,
 }
 
 // does this attribute list contain "macro_escape" ?
-pub fn contains_macro_escape (attrs: &[ast::attribute]) -> bool{
-    let mut accum = false;
-    do attrs.each |attr| {
-        let mname = attr::get_attr_name(attr);
-        if (mname == @~"macro_escape") {
-            accum = true;
-            false
-        } else {
-            true
-        }
-    }
-    accum
+pub fn contains_macro_escape (attrs: &[ast::attribute]) -> bool {
+    attrs.any(|attr| "macro_escape" == *attr::get_attr_name(attr))
 }
 
 // this macro disables (one layer of) macro
diff --git a/src/libsyntax/ext/pipes/proto.rs b/src/libsyntax/ext/pipes/proto.rs
index 647c7741bd8..7c78ec066d0 100644
--- a/src/libsyntax/ext/pipes/proto.rs
+++ b/src/libsyntax/ext/pipes/proto.rs
@@ -100,6 +100,7 @@ pub impl state_ {
 
     /// Iterate over the states that can be reached in one message
     /// from this state.
+    #[cfg(stage0)]
     fn reachable(&self, f: &fn(state) -> bool) {
         for self.messages.each |m| {
             match *m {
@@ -111,6 +112,21 @@ pub impl state_ {
             }
         }
     }
+    /// Iterate over the states that can be reached in one message
+    /// from this state.
+    #[cfg(not(stage0))]
+    fn reachable(&self, f: &fn(state) -> bool) -> bool {
+        for self.messages.each |m| {
+            match *m {
+              message(_, _, _, _, Some(next_state { state: ref id, _ })) => {
+                let state = self.proto.get_state((*id));
+                if !f(state) { return false; }
+              }
+              _ => ()
+            }
+        }
+        return true;
+    }
 }
 
 pub type protocol = @mut protocol_;