Improve wording and spans for unexpected token
* Point at where the token was expected instead of the last token successfuly parsed. * Only show `unexpected token` if the next char and the unexpected token don't have the same span. * Change some cfail and pfail tests to ui test. * Don't show all possible tokens in span label if they are more than 6.
This commit is contained in:
parent
03eca71381
commit
78ae8feebb
13 changed files with 102 additions and 15 deletions
|
@ -79,6 +79,12 @@ impl Span {
|
|||
Span { lo: BytePos(lo), hi: self.hi, expn_id: self.expn_id}
|
||||
}
|
||||
|
||||
/// Returns a new span representing the next character after the end-point of this span
|
||||
pub fn next_point(self) -> Span {
|
||||
let lo = BytePos(cmp::max(self.hi.0, self.lo.0 + 1));
|
||||
Span { lo: lo, hi: lo, expn_id: self.expn_id}
|
||||
}
|
||||
|
||||
/// Returns `self` if `self` is not the dummy span, and `other` otherwise.
|
||||
pub fn substitute_dummy(self, other: Span) -> Span {
|
||||
if self.source_equal(&DUMMY_SP) { other } else { self }
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue