From 7d521445fd47d8403b63c36b712d0238b62a8771 Mon Sep 17 00:00:00 2001 From: Leo Testard Date: Thu, 19 May 2016 00:38:08 +0200 Subject: [PATCH] Avoid iterating two times over the list of LHSes. --- src/libsyntax/ext/tt/macro_rules.rs | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/src/libsyntax/ext/tt/macro_rules.rs b/src/libsyntax/ext/tt/macro_rules.rs index 36d705f35969..3522c8863cf5 100644 --- a/src/libsyntax/ext/tt/macro_rules.rs +++ b/src/libsyntax/ext/tt/macro_rules.rs @@ -291,17 +291,16 @@ pub fn compile<'cx>(cx: &'cx mut ExtCtxt, let lhses = match **argument_map.get(&lhs_nm.name).unwrap() { MatchedSeq(ref s, _) => { s.iter().map(|m| match **m { - MatchedNonterminal(NtTT(ref tt)) => (**tt).clone(), + MatchedNonterminal(NtTT(ref tt)) => { + valid &= check_lhs_nt_follows(cx, tt); + (**tt).clone() + } _ => cx.span_bug(def.span, "wrong-structured lhs") }).collect() } _ => cx.span_bug(def.span, "wrong-structured lhs") }; - for lhs in &lhses { - valid &= check_lhs_nt_follows(cx, lhs); - } - let rhses = match **argument_map.get(&rhs_nm.name).unwrap() { MatchedSeq(ref s, _) => { s.iter().map(|m| match **m {