about summary refs log tree commit diff
path: root/src/libsyntax
diff options
context:
space:
mode:
authorEsteban Küber <esteban@kuber.com.ar>2018-01-23 13:53:08 -0800
committerEsteban Küber <esteban@kuber.com.ar>2018-01-26 14:24:17 -0800
commitfa7767e1ea825bb4cbadbb05c0bfa8ff8a9100e1 (patch)
tree7a4c42298b4a55a34d6c2d6493812567f608533b /src/libsyntax
parentd0bd090efb574cda08647ac07e1870cdafe4ac7d (diff)
downloadrust-fa7767e1ea825bb4cbadbb05c0bfa8ff8a9100e1.tar.gz
rust-fa7767e1ea825bb4cbadbb05c0bfa8ff8a9100e1.zip
review comment
Diffstat (limited to 'src/libsyntax')
-rw-r--r--src/libsyntax/codemap.rs10
1 files changed, 4 insertions, 6 deletions
diff --git a/src/libsyntax/codemap.rs b/src/libsyntax/codemap.rs
index c9b524a0c89..fbd9088797e 100644
--- a/src/libsyntax/codemap.rs
+++ b/src/libsyntax/codemap.rs
@@ -598,18 +598,16 @@ impl CodeMap {
     /// If `sp` points to `"let mut x"`, then a span pointing at `"let "` will be returned.
     pub fn span_until_non_whitespace(&self, sp: Span) -> Span {
         if let Ok(snippet) = self.span_to_snippet(sp) {
-            let mut offset = 0;
-            let mut pos = 0;
+            let mut offset = 1;
             // get the bytes width of all the non-whitespace characters
-            for (i, c) in snippet.chars().take_while(|c| !c.is_whitespace()).enumerate() {
+            for c in snippet.chars().take_while(|c| !c.is_whitespace()) {
                 offset += c.len_utf8();
-                pos = i + 1;
             }
             // get the bytes width of all the whitespace characters after that
-            for c in snippet[pos..].chars().take_while(|c| c.is_whitespace()) {
+            for c in snippet[offset..].chars().take_while(|c| c.is_whitespace()) {
                 offset += c.len_utf8();
             }
-            if offset != 0 {
+            if offset > 1 {
                 return sp.with_hi(BytePos(sp.lo().0 + offset as u32));
             }
         }