From fdaae344785f11ff4226c6eaaacd7b8c954ca013 Mon Sep 17 00:00:00 2001 From: Kevin Ballard Date: Thu, 15 Aug 2013 21:16:40 -0700 Subject: [PATCH] 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 #3747. --- src/libsyntax/parse/lexer.rs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/libsyntax/parse/lexer.rs b/src/libsyntax/parse/lexer.rs index d0041021f7c..c7b247f2dd2 100644 --- a/src/libsyntax/parse/lexer.rs +++ b/src/libsyntax/parse/lexer.rs @@ -782,7 +782,9 @@ fn next_token_inner(rdr: @mut StringReader) -> token::Token { c => { // So the error span points to the unrecognized character rdr.peek_span = codemap::mk_sp(rdr.last_pos, rdr.pos); - rdr.fatal(fmt!("unknown start of token: %d", c as int)); + let mut cs = ~""; + char::escape_default(c, |c| cs.push_char(c)); + rdr.fatal(fmt!("unknown start of token: %s", cs)); } } }