about summary refs log tree commit diff
path: root/compiler/rustc_span
diff options
context:
space:
mode:
authorCamille Gillot <gillot.camille@gmail.com>2025-08-16 16:23:21 +0000
committerCamille Gillot <gillot.camille@gmail.com>2025-08-16 16:23:21 +0000
commita84373085e184460c3cbaefaad0339723af4944e (patch)
treeb5ee217d4ef90ea57cac3ae451ccd455f91fc2b9 /compiler/rustc_span
parent6c1533901788a1e40fc4a9f9b712ad70d7c17a22 (diff)
downloadrust-a84373085e184460c3cbaefaad0339723af4944e.tar.gz
rust-a84373085e184460c3cbaefaad0339723af4944e.zip
Simplify span_data_to_lines_and_cols.
Diffstat (limited to 'compiler/rustc_span')
-rw-r--r--compiler/rustc_span/src/caching_source_map_view.rs30
1 files changed, 14 insertions, 16 deletions
diff --git a/compiler/rustc_span/src/caching_source_map_view.rs b/compiler/rustc_span/src/caching_source_map_view.rs
index a887b50ec1e..41cfaa3ee34 100644
--- a/compiler/rustc_span/src/caching_source_map_view.rs
+++ b/compiler/rustc_span/src/caching_source_map_view.rs
@@ -123,27 +123,25 @@ impl<'sm> CachingSourceMapView<'sm> {
 
         if lo_cache_idx != -1 && hi_cache_idx != -1 {
             // Cache hit for span lo and hi. Check if they belong to the same file.
-            let result = {
-                let lo = &self.line_cache[lo_cache_idx as usize];
-                let hi = &self.line_cache[hi_cache_idx as usize];
+            let lo_file_index = self.line_cache[lo_cache_idx as usize].file_index;
+            let hi_file_index = self.line_cache[hi_cache_idx as usize].file_index;
 
-                if lo.file_index != hi.file_index {
-                    return None;
-                }
-
-                (
-                    lo.file.stable_id,
-                    lo.line_number,
-                    span_data.lo - lo.line.start,
-                    hi.line_number,
-                    span_data.hi - hi.line.start,
-                )
-            };
+            if lo_file_index != hi_file_index {
+                return None;
+            }
 
             self.line_cache[lo_cache_idx as usize].touch(self.time_stamp);
             self.line_cache[hi_cache_idx as usize].touch(self.time_stamp);
 
-            return Some(result);
+            let lo = &self.line_cache[lo_cache_idx as usize];
+            let hi = &self.line_cache[hi_cache_idx as usize];
+            return Some((
+                lo.file.stable_id,
+                lo.line_number,
+                span_data.lo - lo.line.start,
+                hi.line_number,
+                span_data.hi - hi.line.start,
+            ));
         }
 
         // No cache hit or cache hit for only one of span lo and hi.