diff options
| author | Mark Rousskov <mark.simulacrum@gmail.com> | 2019-12-22 17:42:04 -0500 |
|---|---|---|
| committer | Mark Rousskov <mark.simulacrum@gmail.com> | 2019-12-22 17:42:47 -0500 |
| commit | a06baa56b95674fc626b3c3fd680d6a65357fe60 (patch) | |
| tree | cd9d867c2ca3cff5c1d6b3bd73377c44649fb075 /src/libsyntax_pos/caching_source_map_view.rs | |
| parent | 8eb7c58dbb7b32701af113bc58722d0d1fefb1eb (diff) | |
Format the world
Diffstat (limited to 'src/libsyntax_pos/caching_source_map_view.rs')
| -rw-r--r-- | src/libsyntax_pos/caching_source_map_view.rs | 27 |
1 files changed, 16 insertions, 11 deletions
diff --git a/src/libsyntax_pos/caching_source_map_view.rs b/src/libsyntax_pos/caching_source_map_view.rs index 82371730876..c329f2225b0 100644 --- a/src/libsyntax_pos/caching_source_map_view.rs +++ b/src/libsyntax_pos/caching_source_map_view.rs @@ -1,6 +1,6 @@ -use rustc_data_structures::sync::Lrc; use crate::source_map::SourceMap; use crate::{BytePos, SourceFile}; +use rustc_data_structures::sync::Lrc; #[derive(Clone)] struct CacheEntry { @@ -39,9 +39,10 @@ impl<'cm> CachingSourceMapView<'cm> { } } - pub fn byte_pos_to_line_and_col(&mut self, - pos: BytePos) - -> Option<(Lrc<SourceFile>, usize, BytePos)> { + pub fn byte_pos_to_line_and_col( + &mut self, + pos: BytePos, + ) -> Option<(Lrc<SourceFile>, usize, BytePos)> { self.time_stamp += 1; // Check if the position is in one of the cached lines @@ -49,15 +50,17 @@ impl<'cm> CachingSourceMapView<'cm> { if pos >= cache_entry.line_start && pos < cache_entry.line_end { cache_entry.time_stamp = self.time_stamp; - return Some((cache_entry.file.clone(), - cache_entry.line_number, - pos - cache_entry.line_start)); + return Some(( + cache_entry.file.clone(), + cache_entry.line_number, + pos - cache_entry.line_start, + )); } } // No cache hit ... let mut oldest = 0; - for index in 1 .. self.line_cache.len() { + for index in 1..self.line_cache.len() { if self.line_cache[index].time_stamp < self.line_cache[oldest].time_stamp { oldest = index; } @@ -96,8 +99,10 @@ impl<'cm> CachingSourceMapView<'cm> { cache_entry.line_end = line_bounds.1; cache_entry.time_stamp = self.time_stamp; - return Some((cache_entry.file.clone(), - cache_entry.line_number, - pos - cache_entry.line_start)); + return Some(( + cache_entry.file.clone(), + cache_entry.line_number, + pos - cache_entry.line_start, + )); } } |
