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`
This commit is contained in:
commit
a991861ec9
20 changed files with 260 additions and 369 deletions
|
@ -22,7 +22,7 @@ use rustc_span::hygiene::{
|
|||
ExpnId, HygieneDecodeContext, HygieneEncodeContext, SyntaxContext, SyntaxContextData,
|
||||
};
|
||||
use rustc_span::source_map::{SourceMap, StableSourceFileId};
|
||||
use rustc_span::{BytePos, ExpnData, ExpnHash, Pos, SourceFile, Span};
|
||||
use rustc_span::{BytePos, ExpnData, ExpnHash, Pos, RelativeBytePos, SourceFile, Span};
|
||||
use rustc_span::{CachingSourceMapView, Symbol};
|
||||
use std::collections::hash_map::Entry;
|
||||
use std::io;
|
||||
|
@ -688,11 +688,12 @@ impl<'a, 'tcx> Decodable<CacheDecoder<'a, 'tcx>> for Span {
|
|||
|
||||
let file_lo_index = SourceFileIndex::decode(decoder);
|
||||
let line_lo = usize::decode(decoder);
|
||||
let col_lo = BytePos::decode(decoder);
|
||||
let col_lo = RelativeBytePos::decode(decoder);
|
||||
let len = BytePos::decode(decoder);
|
||||
|
||||
let file_lo = decoder.file_index_to_file(file_lo_index);
|
||||
let lo = file_lo.lines(|lines| lines[line_lo - 1] + col_lo);
|
||||
let lo = file_lo.absolute_position(lo);
|
||||
let hi = lo + len;
|
||||
|
||||
Span::new(lo, hi, ctxt, parent)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue