diff options
| author | Esteban Küber <esteban@kuber.com.ar> | 2017-03-25 15:36:59 -0700 |
|---|---|---|
| committer | Esteban Küber <esteban@kuber.com.ar> | 2017-03-25 15:36:59 -0700 |
| commit | 78ae8feebbf9a2c70d42780d0c646cbbc1f2cdbc (patch) | |
| tree | 6280f6af76d15fd058ac2175a83c12a70212b496 /src/libsyntax_pos | |
| parent | 03eca713816ee00ecacde27cc655dc199c6bff40 (diff) | |
| download | rust-78ae8feebbf9a2c70d42780d0c646cbbc1f2cdbc.tar.gz rust-78ae8feebbf9a2c70d42780d0c646cbbc1f2cdbc.zip | |
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.
Diffstat (limited to 'src/libsyntax_pos')
| -rw-r--r-- | src/libsyntax_pos/lib.rs | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/src/libsyntax_pos/lib.rs b/src/libsyntax_pos/lib.rs index 3808923e772..07494ff904e 100644 --- a/src/libsyntax_pos/lib.rs +++ b/src/libsyntax_pos/lib.rs @@ -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 } |
