Skip to content

Commit

Permalink
lexer: show correct span on unrecognized token start
Browse files Browse the repository at this point in the history
Fixes part of rust-lang#7048.
  • Loading branch information
Blei committed Jun 11, 2013
1 parent 6bdd4c8 commit 1ac90bb
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/libsyntax/parse/lexer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -772,7 +772,11 @@ fn next_token_inner(rdr: @mut StringReader) -> token::Token {
'/' => { return binop(rdr, token::SLASH); }
'^' => { return binop(rdr, token::CARET); }
'%' => { return binop(rdr, token::PERCENT); }
c => { rdr.fatal(fmt!("unknown start of token: %d", c as int)); }
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));
}
}
}

Expand Down

0 comments on commit 1ac90bb

Please sign in to comment.