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.
This commit is contained in:
parent
551da06157
commit
386db05df8
18 changed files with 262 additions and 28 deletions
|
|
@ -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)
|
||||
};
|
||||
|
|
|
|||
|
|
@ -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
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue