about summary refs log tree commit diff
path: root/src/libsyntax
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2017-10-19 11:41:11 +0000
committerbors <bors@rust-lang.org>2017-10-19 11:41:11 +0000
commite3fb84e951e3c602d2dbbfebbd4ee275ac414893 (patch)
treeff2aeeef0e941873ae6764acf025f2312dd61257 /src/libsyntax
parentb7960878ba77124505aabe7dc99d0a898354c326 (diff)
parent8e6ed1203b777747bb435c7eb11272ccf252cd52 (diff)
downloadrust-e3fb84e951e3c602d2dbbfebbd4ee275ac414893.tar.gz
rust-e3fb84e951e3c602d2dbbfebbd4ee275ac414893.zip
Auto merge of #45232 - zackmdavis:moar_lint_suggestions, r=estebank
code suggestions for non-shorthand field pattern, no-mangle lints

continuing in the spirit of #44942

![moar_lint_suggestions](https://user-images.githubusercontent.com/1076988/31485011-3b20cc80-aee7-11e7-993d-81267ab77732.png)

r? @estebank
Diffstat (limited to 'src/libsyntax')
-rw-r--r--src/libsyntax/codemap.rs11
1 files changed, 11 insertions, 0 deletions
diff --git a/src/libsyntax/codemap.rs b/src/libsyntax/codemap.rs
index efaa5e5e3da..dd46903bb88 100644
--- a/src/libsyntax/codemap.rs
+++ b/src/libsyntax/codemap.rs
@@ -471,6 +471,17 @@ impl CodeMap {
         }
     }
 
+    /// Given a `Span`, try to get a shorter span ending just after the first
+    /// occurrence of `char` `c`.
+    pub fn span_through_char(&self, sp: Span, c: char) -> Span {
+        if let Ok(snippet) = self.span_to_snippet(sp) {
+            if let Some(offset) = snippet.find(c) {
+                return sp.with_hi(BytePos(sp.lo().0 + (offset + c.len_utf8()) as u32));
+            }
+        }
+        sp
+    }
+
     pub fn def_span(&self, sp: Span) -> Span {
         self.span_until_char(sp, '{')
     }