diff options
| author | bors <bors@rust-lang.org> | 2017-10-19 11:41:11 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2017-10-19 11:41:11 +0000 |
| commit | e3fb84e951e3c602d2dbbfebbd4ee275ac414893 (patch) | |
| tree | ff2aeeef0e941873ae6764acf025f2312dd61257 /src/libsyntax | |
| parent | b7960878ba77124505aabe7dc99d0a898354c326 (diff) | |
| parent | 8e6ed1203b777747bb435c7eb11272ccf252cd52 (diff) | |
| download | rust-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  r? @estebank
Diffstat (limited to 'src/libsyntax')
| -rw-r--r-- | src/libsyntax/codemap.rs | 11 |
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, '{') } |
