Skip to content

Commit 1ac90bb

Browse files
committed
lexer: show correct span on unrecognized token start
Fixes part of rust-lang#7048.
1 parent 6bdd4c8 commit 1ac90bb

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

src/libsyntax/parse/lexer.rs

+5-1
Original file line numberDiff line numberDiff line change
@@ -772,7 +772,11 @@ fn next_token_inner(rdr: @mut StringReader) -> token::Token {
772772
'/' => { return binop(rdr, token::SLASH); }
773773
'^' => { return binop(rdr, token::CARET); }
774774
'%' => { return binop(rdr, token::PERCENT); }
775-
c => { rdr.fatal(fmt!("unknown start of token: %d", c as int)); }
775+
c => {
776+
// So the error span points to the unrecognized character
777+
rdr.peek_span = codemap::mk_sp(rdr.last_pos, rdr.pos);
778+
rdr.fatal(fmt!("unknown start of token: %d", c as int));
779+
}
776780
}
777781
}
778782

0 commit comments

Comments
 (0)