]> git.lizzy.rs Git - rust.git/commitdiff
Better error message for unknown start of token
authorKevin Ballard <kevin@sb.org>
Fri, 16 Aug 2013 04:16:40 +0000 (21:16 -0700)
committerKevin Ballard <kevin@sb.org>
Fri, 16 Aug 2013 04:16:40 +0000 (21:16 -0700)
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

index d0041021f7cc77158a8e1fa130a1c8bf4a361e75..c7b247f2dd24c6aa90fca24c2c987397030610f9 100644 (file)
@@ -782,7 +782,9 @@ fn binop(rdr: @mut StringReader, op: token::binop) -> 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));
       }
     }
 }