auto merge of #12338 : edwardw/rust/hygienic-break-continue, r=cmr

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.
This commit is contained in:
bors 2014-02-23 15:37:05 -08:00
commit 329fcd48e5
18 changed files with 262 additions and 28 deletions

View file

@ -1822,7 +1822,7 @@ impl Parser {
let ex = if Parser::token_is_lifetime(&self.token) {
let lifetime = self.get_lifetime();
self.bump();
ExprAgain(Some(lifetime.name))
ExprAgain(Some(lifetime))
} else {
ExprAgain(None)
};
@ -1885,7 +1885,7 @@ impl Parser {
if Parser::token_is_lifetime(&self.token) {
let lifetime = self.get_lifetime();
self.bump();
ex = ExprBreak(Some(lifetime.name));
ex = ExprBreak(Some(lifetime));
} else {
ex = ExprBreak(None);
}
@ -2579,7 +2579,7 @@ impl Parser {
let ex = if Parser::token_is_lifetime(&self.token) {
let lifetime = self.get_lifetime();
self.bump();
ExprAgain(Some(lifetime.name))
ExprAgain(Some(lifetime))
} else {
ExprAgain(None)
};

View file

@ -704,8 +704,8 @@ pub fn is_reserved_keyword(tok: &Token) -> bool {
pub fn mtwt_token_eq(t1 : &Token, t2 : &Token) -> bool {
match (t1,t2) {
(&IDENT(id1,_),&IDENT(id2,_)) =>
ast_util::mtwt_resolve(id1) == ast_util::mtwt_resolve(id2),
(&IDENT(id1,_),&IDENT(id2,_)) | (&LIFETIME(id1),&LIFETIME(id2)) =>
ast_util::mtwt_resolve(id1) == ast_util::mtwt_resolve(id2),
_ => *t1 == *t2
}
}