Skip to content

Commit 7d52144

Browse files
committed
Avoid iterating two times over the list of LHSes.
1 parent eb364e9 commit 7d52144

File tree

1 file changed

+4
-5
lines changed

1 file changed

+4
-5
lines changed

src/libsyntax/ext/tt/macro_rules.rs

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -291,17 +291,16 @@ pub fn compile<'cx>(cx: &'cx mut ExtCtxt,
291291
let lhses = match **argument_map.get(&lhs_nm.name).unwrap() {
292292
MatchedSeq(ref s, _) => {
293293
s.iter().map(|m| match **m {
294-
MatchedNonterminal(NtTT(ref tt)) => (**tt).clone(),
294+
MatchedNonterminal(NtTT(ref tt)) => {
295+
valid &= check_lhs_nt_follows(cx, tt);
296+
(**tt).clone()
297+
}
295298
_ => cx.span_bug(def.span, "wrong-structured lhs")
296299
}).collect()
297300
}
298301
_ => cx.span_bug(def.span, "wrong-structured lhs")
299302
};
300303

301-
for lhs in &lhses {
302-
valid &= check_lhs_nt_follows(cx, lhs);
303-
}
304-
305304
let rhses = match **argument_map.get(&rhs_nm.name).unwrap() {
306305
MatchedSeq(ref s, _) => {
307306
s.iter().map(|m| match **m {

0 commit comments

Comments
 (0)