about summary refs log tree commit diff
path: root/src/libsyntax_pos/caching_source_map_view.rs
diff options
context:
space:
mode:
authorMark Rousskov <mark.simulacrum@gmail.com>2019-12-22 17:42:04 -0500
committerMark Rousskov <mark.simulacrum@gmail.com>2019-12-22 17:42:47 -0500
commita06baa56b95674fc626b3c3fd680d6a65357fe60 (patch)
treecd9d867c2ca3cff5c1d6b3bd73377c44649fb075 /src/libsyntax_pos/caching_source_map_view.rs
parent8eb7c58dbb7b32701af113bc58722d0d1fefb1eb (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.rs27
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,
+        ));
     }
 }