about summary refs log tree commit diff
path: root/compiler/rustc_span/src/source_map
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2023-09-05 21:03:56 +0000
committerbors <bors@rust-lang.org>2023-09-05 21:03:56 +0000
commita991861ec9fd8aedffbe5744a8852c7c64dd40b2 (patch)
treeea4300be75a907b849ce41f5e116b29d57b40f88 /compiler/rustc_span/src/source_map
parentf91c53d73820251cc222356dcb65586469cf2018 (diff)
parent3edeac06a5722e9b29c350a22e54b8cc1396c62d (diff)
downloadrust-a991861ec9fd8aedffbe5744a8852c7c64dd40b2.tar.gz
rust-a991861ec9fd8aedffbe5744a8852c7c64dd40b2.zip
Auto merge of #115507 - cjgillot:relative-source-file, r=oli-obk
Use relative positions inside a SourceFile.

This allows to remove the normalization of start positions for hashing, and simplify allocation of global address space.

cc `@Zoxc`
Diffstat (limited to 'compiler/rustc_span/src/source_map')
-rw-r--r--compiler/rustc_span/src/source_map/tests.rs7
1 files changed, 3 insertions, 4 deletions
diff --git a/compiler/rustc_span/src/source_map/tests.rs b/compiler/rustc_span/src/source_map/tests.rs
index 686b3b00d70..7689e6afac5 100644
--- a/compiler/rustc_span/src/source_map/tests.rs
+++ b/compiler/rustc_span/src/source_map/tests.rs
@@ -50,6 +50,7 @@ impl SourceMap {
     fn bytepos_to_file_charpos(&self, bpos: BytePos) -> CharPos {
         let idx = self.lookup_source_file_idx(bpos);
         let sf = &(*self.files.borrow().source_files)[idx];
+        let bpos = sf.relative_position(bpos);
         sf.bytepos_to_file_charpos(bpos)
     }
 }
@@ -230,8 +231,7 @@ fn t10() {
     let SourceFile {
         name,
         src_hash,
-        start_pos,
-        end_pos,
+        source_len,
         lines,
         multibyte_chars,
         non_narrow_chars,
@@ -244,13 +244,12 @@ fn t10() {
         name,
         src_hash,
         name_hash,
-        (end_pos - start_pos).to_usize(),
+        source_len.to_u32(),
         CrateNum::new(0),
         lines,
         multibyte_chars,
         non_narrow_chars,
         normalized_pos,
-        start_pos,
         0,
     );