From 5eb6d19803ebcb5279f8a42b584a4d81152fa82d Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Thu, 2 May 2013 18:33:33 -0400 Subject: syntax: Use the new `for` protocol --- src/libsyntax/ext/expand.rs | 14 ++------------ src/libsyntax/ext/pipes/proto.rs | 16 ++++++++++++++++ 2 files changed, 18 insertions(+), 12 deletions(-) (limited to 'src/libsyntax/ext') 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_; -- cgit 1.4.1-3-g733a5