Skip to content

Commit be93735

Browse files
committed
fix one remaining token comparison, refactor token comparison to avoid == check
1 parent 63b5412 commit be93735

File tree

1 file changed

+10
-11
lines changed

1 file changed

+10
-11
lines changed

src/libsyntax/ext/tt/macro_parser.rs

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -234,16 +234,12 @@ pub fn parse_or_else(
234234
}
235235
}
236236
237-
// temporary for testing
237+
// perform a token equality check, ignoring syntax context (that is, an unhygienic comparison)
238238
pub fn token_name_eq(t1 : &Token, t2 : &Token) -> bool {
239-
if (*t1 == *t2) {
240-
true
241-
} else {
242-
match (t1,t2) {
243-
(&token::IDENT(id1,_),&token::IDENT(id2,_)) =>
244-
id1.name == id2.name,
245-
_ => false
246-
}
239+
match (t1,t2) {
240+
(&token::IDENT(id1,_),&token::IDENT(id2,_)) =>
241+
id1.name == id2.name,
242+
_ => *t1 == *t2
247243
}
248244
}
249245
@@ -310,7 +306,10 @@ pub fn parse(
310306
// the *_t vars are workarounds for the lack of unary move
311307
match ei.sep {
312308
Some(ref t) if idx == len => { // we need a separator
313-
if tok == (*t) { //pass the separator
309+
// i'm conflicted about whether this should be hygienic....
310+
// though in this case, if the separators are never legal
311+
// idents, it shouldn't matter.
312+
if token_name_eq(&tok, t) { //pass the separator
314313
let mut ei_t = ei.clone();
315314
ei_t.idx += 1;
316315
next_eis.push(ei_t);
@@ -367,7 +366,7 @@ pub fn parse(
367366
}
368367

369368
/* error messages here could be improved with links to orig. rules */
370-
if tok == EOF {
369+
if token_name_eq(&tok, &EOF) {
371370
if eof_eis.len() == 1u {
372371
let mut v = ~[];
373372
for dv in eof_eis[0u].matches.mut_iter() {

0 commit comments

Comments
 (0)