about summary refs log tree commit diff
path: root/src/libsyntax
diff options
context:
space:
mode:
authorDavid Wood <david@davidtw.co>2018-01-17 16:41:58 +0000
committerDavid Wood <david@davidtw.co>2018-01-27 11:46:29 +0000
commit0c467d5d0924e705c8a4b84b250e127c62222239 (patch)
treec7607faaa2aea73cde00a9e3cf70e9dfa47b069b /src/libsyntax
parent71b7500241d97e1e6fb9c9c163c98b17b30c6f1c (diff)
downloadrust-0c467d5d0924e705c8a4b84b250e127c62222239.tar.gz
rust-0c467d5d0924e705c8a4b84b250e127c62222239.zip
Now handling case where span has same lo and hi.
Diffstat (limited to 'src/libsyntax')
-rw-r--r--src/libsyntax/codemap.rs7
1 files changed, 6 insertions, 1 deletions
diff --git a/src/libsyntax/codemap.rs b/src/libsyntax/codemap.rs
index cfb891f0faa..8c1bdab28a9 100644
--- a/src/libsyntax/codemap.rs
+++ b/src/libsyntax/codemap.rs
@@ -637,7 +637,7 @@ impl CodeMap {
     /// Finds the width of a character, either before or after the provided span.
     fn find_width_of_character_at_span(&self, sp: Span, forwards: bool) -> u32 {
         // Disregard malformed spans and assume a one-byte wide character.
-        if sp.lo() > sp.hi() {
+        if sp.lo() >= sp.hi() {
             return 1;
         }
 
@@ -671,11 +671,16 @@ impl CodeMap {
         } else {
             return 1;
         };
+        debug!("DTW start {:?} end {:?}", start_index, end_index);
+        debug!("DTW snippet {:?}", snippet);
 
         let mut target = if forwards { end_index + 1 } else { end_index - 1 };
+        debug!("DTW initial target {:?}", target);
         while !snippet.is_char_boundary(target - start_index) {
             target = if forwards { target + 1 } else { target - 1 };
+            debug!("DTW update target {:?}", target);
         }
+        debug!("DTW final target {:?}", target);
 
         if forwards {
             (target - end_index) as u32