diff options
| author | Niko Matsakis <niko@alum.mit.edu> | 2018-07-07 19:53:52 -0400 |
|---|---|---|
| committer | Niko Matsakis <niko@alum.mit.edu> | 2018-07-09 00:20:36 -0400 |
| commit | a6adb1ebff51dd4ff2e724bf980c9b8586142beb (patch) | |
| tree | f20994d71db37670c4848505637ef4a2e9312ee4 /src/libsyntax | |
| parent | 9fd3d7899a444fe110ae9277542b306844ecf0c4 (diff) | |
| download | rust-a6adb1ebff51dd4ff2e724bf980c9b8586142beb.tar.gz rust-a6adb1ebff51dd4ff2e724bf980c9b8586142beb.zip | |
find and highlight the `&` or `'_` in `region_name`
Diffstat (limited to 'src/libsyntax')
| -rw-r--r-- | src/libsyntax/codemap.rs | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/src/libsyntax/codemap.rs b/src/libsyntax/codemap.rs index ea6b39504e8..8381adaea79 100644 --- a/src/libsyntax/codemap.rs +++ b/src/libsyntax/codemap.rs @@ -689,6 +689,15 @@ impl CodeMap { self.span_until_char(sp, '{') } + /// Returns a new span representing just the start-point of this span + pub fn start_point(&self, sp: Span) -> Span { + let pos = sp.lo().0; + let width = self.find_width_of_character_at_span(sp, false); + let corrected_start_position = pos.checked_add(width).unwrap_or(pos); + let end_point = BytePos(cmp::max(corrected_start_position, sp.lo().0)); + sp.with_hi(end_point) + } + /// Returns a new span representing just the end-point of this span pub fn end_point(&self, sp: Span) -> Span { let pos = sp.hi().0; |
