about summary refs log tree commit diff
path: root/src/libsyntax_pos/lib.rs
diff options
context:
space:
mode:
authorEsteban Küber <esteban@kuber.com.ar>2017-03-25 15:36:59 -0700
committerEsteban Küber <esteban@kuber.com.ar>2017-03-25 15:36:59 -0700
commit78ae8feebbf9a2c70d42780d0c646cbbc1f2cdbc (patch)
tree6280f6af76d15fd058ac2175a83c12a70212b496 /src/libsyntax_pos/lib.rs
parent03eca713816ee00ecacde27cc655dc199c6bff40 (diff)
downloadrust-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/lib.rs')
-rw-r--r--src/libsyntax_pos/lib.rs6
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 }