Skip to content

Commit fdaae34

Browse files
committed
Better error message for unknown start of token
The span was fixed at some point to point to the correct character, but the error message is still bad. Update it to emit the actual character in question (potentially escaped). Fixes rust-lang#3747.
1 parent c4656cf commit fdaae34

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

src/libsyntax/parse/lexer.rs

+3-1
Original file line numberDiff line numberDiff line change
@@ -782,7 +782,9 @@ fn next_token_inner(rdr: @mut StringReader) -> token::Token {
782782
c => {
783783
// So the error span points to the unrecognized character
784784
rdr.peek_span = codemap::mk_sp(rdr.last_pos, rdr.pos);
785-
rdr.fatal(fmt!("unknown start of token: %d", c as int));
785+
let mut cs = ~"";
786+
char::escape_default(c, |c| cs.push_char(c));
787+
rdr.fatal(fmt!("unknown start of token: %s", cs));
786788
}
787789
}
788790
}

0 commit comments

Comments
 (0)