From 386db05df8aa8349857ad6f5486db0bdcc79f3cd Mon Sep 17 00:00:00 2001 From: Edward Wang Date: Sat, 15 Feb 2014 16:54:32 +0800 Subject: Make break and continue hygienic Makes labelled loops hygiene by performing renaming of the labels defined in e.g. `'x: loop { ... }` and then used in break and continue statements within loop body so that they act hygienically when used with macros. Closes #12262. --- src/libsyntax/ext/tt/macro_parser.rs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'src/libsyntax/ext/tt') diff --git a/src/libsyntax/ext/tt/macro_parser.rs b/src/libsyntax/ext/tt/macro_parser.rs index 456533de5e9..edd875a57a7 100644 --- a/src/libsyntax/ext/tt/macro_parser.rs +++ b/src/libsyntax/ext/tt/macro_parser.rs @@ -218,8 +218,9 @@ pub fn parse_or_else(sess: @ParseSess, // perform a token equality check, ignoring syntax context (that is, an unhygienic comparison) pub fn token_name_eq(t1 : &Token, t2 : &Token) -> bool { match (t1,t2) { - (&token::IDENT(id1,_),&token::IDENT(id2,_)) => - id1.name == id2.name, + (&token::IDENT(id1,_),&token::IDENT(id2,_)) + | (&token::LIFETIME(id1),&token::LIFETIME(id2)) => + id1.name == id2.name, _ => *t1 == *t2 } } -- cgit 1.4.1-3-g733a5