mv FileMap SourceFile
This commit is contained in:
parent
c655473378
commit
d6dcbcd4e1
22 changed files with 126 additions and 126 deletions
|
@ -63,7 +63,7 @@ use syntax::errors::DiagnosticBuilder;
|
||||||
use syntax::parse::{self, token};
|
use syntax::parse::{self, token};
|
||||||
use syntax::symbol::Symbol;
|
use syntax::symbol::Symbol;
|
||||||
use syntax::tokenstream;
|
use syntax::tokenstream;
|
||||||
use syntax_pos::{FileMap, Pos, FileName};
|
use syntax_pos::{Pos, FileName};
|
||||||
|
|
||||||
/// The main type provided by this crate, representing an abstract stream of
|
/// The main type provided by this crate, representing an abstract stream of
|
||||||
/// tokens, or, more specifically, a sequence of token trees.
|
/// tokens, or, more specifically, a sequence of token trees.
|
||||||
|
@ -308,7 +308,7 @@ impl Span {
|
||||||
#[unstable(feature = "proc_macro_span", issue = "38356")]
|
#[unstable(feature = "proc_macro_span", issue = "38356")]
|
||||||
pub fn source_file(&self) -> SourceFile {
|
pub fn source_file(&self) -> SourceFile {
|
||||||
SourceFile {
|
SourceFile {
|
||||||
filemap: __internal::lookup_char_pos(self.0.lo()).file,
|
source_file: __internal::lookup_char_pos(self.0.lo()).file,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -419,7 +419,7 @@ impl !Sync for LineColumn {}
|
||||||
#[unstable(feature = "proc_macro_span", issue = "38356")]
|
#[unstable(feature = "proc_macro_span", issue = "38356")]
|
||||||
#[derive(Clone)]
|
#[derive(Clone)]
|
||||||
pub struct SourceFile {
|
pub struct SourceFile {
|
||||||
filemap: Lrc<FileMap>,
|
source_file: Lrc<syntax_pos::SourceFile>,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[unstable(feature = "proc_macro_span", issue = "38356")]
|
#[unstable(feature = "proc_macro_span", issue = "38356")]
|
||||||
|
|
|
@ -10,7 +10,7 @@
|
||||||
|
|
||||||
use rustc_data_structures::sync::Lrc;
|
use rustc_data_structures::sync::Lrc;
|
||||||
use syntax::codemap::SourceMap;
|
use syntax::codemap::SourceMap;
|
||||||
use syntax_pos::{BytePos, FileMap};
|
use syntax_pos::{BytePos, SourceFile};
|
||||||
|
|
||||||
#[derive(Clone)]
|
#[derive(Clone)]
|
||||||
struct CacheEntry {
|
struct CacheEntry {
|
||||||
|
@ -18,7 +18,7 @@ struct CacheEntry {
|
||||||
line_number: usize,
|
line_number: usize,
|
||||||
line_start: BytePos,
|
line_start: BytePos,
|
||||||
line_end: BytePos,
|
line_end: BytePos,
|
||||||
file: Lrc<FileMap>,
|
file: Lrc<SourceFile>,
|
||||||
file_index: usize,
|
file_index: usize,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -51,7 +51,7 @@ impl<'cm> CachingCodemapView<'cm> {
|
||||||
|
|
||||||
pub fn byte_pos_to_line_and_col(&mut self,
|
pub fn byte_pos_to_line_and_col(&mut self,
|
||||||
pos: BytePos)
|
pos: BytePos)
|
||||||
-> Option<(Lrc<FileMap>, usize, BytePos)> {
|
-> Option<(Lrc<SourceFile>, usize, BytePos)> {
|
||||||
self.time_stamp += 1;
|
self.time_stamp += 1;
|
||||||
|
|
||||||
// Check if the position is in one of the cached lines
|
// Check if the position is in one of the cached lines
|
||||||
|
|
|
@ -309,7 +309,7 @@ impl<'a> HashStable<StableHashingContext<'a>> for Span {
|
||||||
// Hash a span in a stable way. We can't directly hash the span's BytePos
|
// Hash a span in a stable way. We can't directly hash the span's BytePos
|
||||||
// fields (that would be similar to hashing pointers, since those are just
|
// fields (that would be similar to hashing pointers, since those are just
|
||||||
// offsets into the SourceMap). Instead, we hash the (file name, line, column)
|
// offsets into the SourceMap). Instead, we hash the (file name, line, column)
|
||||||
// triple, which stays the same even if the containing FileMap has moved
|
// triple, which stays the same even if the containing SourceFile has moved
|
||||||
// within the SourceMap.
|
// within the SourceMap.
|
||||||
// Also note that we are hashing byte offsets for the column, not unicode
|
// Also note that we are hashing byte offsets for the column, not unicode
|
||||||
// codepoint offsets. For the purpose of the hash that's sufficient.
|
// codepoint offsets. For the purpose of the hash that's sufficient.
|
||||||
|
|
|
@ -21,7 +21,7 @@ use syntax::feature_gate;
|
||||||
use syntax::parse::token;
|
use syntax::parse::token;
|
||||||
use syntax::symbol::{InternedString, LocalInternedString};
|
use syntax::symbol::{InternedString, LocalInternedString};
|
||||||
use syntax::tokenstream;
|
use syntax::tokenstream;
|
||||||
use syntax_pos::FileMap;
|
use syntax_pos::SourceFile;
|
||||||
|
|
||||||
use hir::def_id::{DefId, CrateNum, CRATE_DEF_INDEX};
|
use hir::def_id::{DefId, CrateNum, CRATE_DEF_INDEX};
|
||||||
|
|
||||||
|
@ -427,11 +427,11 @@ impl_stable_hash_for!(enum ::syntax_pos::FileName {
|
||||||
Custom(s)
|
Custom(s)
|
||||||
});
|
});
|
||||||
|
|
||||||
impl<'a> HashStable<StableHashingContext<'a>> for FileMap {
|
impl<'a> HashStable<StableHashingContext<'a>> for SourceFile {
|
||||||
fn hash_stable<W: StableHasherResult>(&self,
|
fn hash_stable<W: StableHasherResult>(&self,
|
||||||
hcx: &mut StableHashingContext<'a>,
|
hcx: &mut StableHashingContext<'a>,
|
||||||
hasher: &mut StableHasher<W>) {
|
hasher: &mut StableHasher<W>) {
|
||||||
let FileMap {
|
let SourceFile {
|
||||||
name: _, // We hash the smaller name_hash instead of this
|
name: _, // We hash the smaller name_hash instead of this
|
||||||
name_hash,
|
name_hash,
|
||||||
name_was_remapped,
|
name_was_remapped,
|
||||||
|
|
|
@ -27,7 +27,7 @@ use session::{CrateDisambiguator, Session};
|
||||||
use std::mem;
|
use std::mem;
|
||||||
use syntax::ast::NodeId;
|
use syntax::ast::NodeId;
|
||||||
use syntax::codemap::{SourceMap, StableFilemapId};
|
use syntax::codemap::{SourceMap, StableFilemapId};
|
||||||
use syntax_pos::{BytePos, Span, DUMMY_SP, FileMap};
|
use syntax_pos::{BytePos, Span, DUMMY_SP, SourceFile};
|
||||||
use syntax_pos::hygiene::{Mark, SyntaxContext, ExpnInfo};
|
use syntax_pos::hygiene::{Mark, SyntaxContext, ExpnInfo};
|
||||||
use ty;
|
use ty;
|
||||||
use ty::codec::{self as ty_codec, TyDecoder, TyEncoder};
|
use ty::codec::{self as ty_codec, TyDecoder, TyEncoder};
|
||||||
|
@ -63,10 +63,10 @@ pub struct OnDiskCache<'sess> {
|
||||||
cnum_map: Once<IndexVec<CrateNum, Option<CrateNum>>>,
|
cnum_map: Once<IndexVec<CrateNum, Option<CrateNum>>>,
|
||||||
|
|
||||||
codemap: &'sess SourceMap,
|
codemap: &'sess SourceMap,
|
||||||
file_index_to_stable_id: FxHashMap<FileMapIndex, StableFilemapId>,
|
file_index_to_stable_id: FxHashMap<SourceFileIndex, StableFilemapId>,
|
||||||
|
|
||||||
// These two fields caches that are populated lazily during decoding.
|
// These two fields caches that are populated lazily during decoding.
|
||||||
file_index_to_file: Lock<FxHashMap<FileMapIndex, Lrc<FileMap>>>,
|
file_index_to_file: Lock<FxHashMap<SourceFileIndex, Lrc<SourceFile>>>,
|
||||||
synthetic_expansion_infos: Lock<FxHashMap<AbsoluteBytePos, SyntaxContext>>,
|
synthetic_expansion_infos: Lock<FxHashMap<AbsoluteBytePos, SyntaxContext>>,
|
||||||
|
|
||||||
// A map from dep-node to the position of the cached query result in
|
// A map from dep-node to the position of the cached query result in
|
||||||
|
@ -83,7 +83,7 @@ pub struct OnDiskCache<'sess> {
|
||||||
// This type is used only for (de-)serialization.
|
// This type is used only for (de-)serialization.
|
||||||
#[derive(RustcEncodable, RustcDecodable)]
|
#[derive(RustcEncodable, RustcDecodable)]
|
||||||
struct Footer {
|
struct Footer {
|
||||||
file_index_to_stable_id: FxHashMap<FileMapIndex, StableFilemapId>,
|
file_index_to_stable_id: FxHashMap<SourceFileIndex, StableFilemapId>,
|
||||||
prev_cnums: Vec<(u32, String, CrateDisambiguator)>,
|
prev_cnums: Vec<(u32, String, CrateDisambiguator)>,
|
||||||
query_result_index: EncodedQueryResultIndex,
|
query_result_index: EncodedQueryResultIndex,
|
||||||
diagnostics_index: EncodedQueryResultIndex,
|
diagnostics_index: EncodedQueryResultIndex,
|
||||||
|
@ -96,7 +96,7 @@ type EncodedDiagnosticsIndex = Vec<(SerializedDepNodeIndex, AbsoluteBytePos)>;
|
||||||
type EncodedDiagnostics = Vec<Diagnostic>;
|
type EncodedDiagnostics = Vec<Diagnostic>;
|
||||||
|
|
||||||
#[derive(Copy, Clone, PartialEq, Eq, Hash, Debug, RustcEncodable, RustcDecodable)]
|
#[derive(Copy, Clone, PartialEq, Eq, Hash, Debug, RustcEncodable, RustcDecodable)]
|
||||||
struct FileMapIndex(u32);
|
struct SourceFileIndex(u32);
|
||||||
|
|
||||||
#[derive(Copy, Clone, Debug, Hash, Eq, PartialEq, RustcEncodable, RustcDecodable)]
|
#[derive(Copy, Clone, Debug, Hash, Eq, PartialEq, RustcEncodable, RustcDecodable)]
|
||||||
struct AbsoluteBytePos(u32);
|
struct AbsoluteBytePos(u32);
|
||||||
|
@ -173,14 +173,14 @@ impl<'sess> OnDiskCache<'sess> {
|
||||||
{
|
{
|
||||||
// Serializing the DepGraph should not modify it:
|
// Serializing the DepGraph should not modify it:
|
||||||
tcx.dep_graph.with_ignore(|| {
|
tcx.dep_graph.with_ignore(|| {
|
||||||
// Allocate FileMapIndices
|
// Allocate SourceFileIndices
|
||||||
let (file_to_file_index, file_index_to_stable_id) = {
|
let (file_to_file_index, file_index_to_stable_id) = {
|
||||||
let mut file_to_file_index = FxHashMap();
|
let mut file_to_file_index = FxHashMap();
|
||||||
let mut file_index_to_stable_id = FxHashMap();
|
let mut file_index_to_stable_id = FxHashMap();
|
||||||
|
|
||||||
for (index, file) in tcx.sess.codemap().files().iter().enumerate() {
|
for (index, file) in tcx.sess.codemap().files().iter().enumerate() {
|
||||||
let index = FileMapIndex(index as u32);
|
let index = SourceFileIndex(index as u32);
|
||||||
let file_ptr: *const FileMap = &**file as *const _;
|
let file_ptr: *const SourceFile = &**file as *const _;
|
||||||
file_to_file_index.insert(file_ptr, index);
|
file_to_file_index.insert(file_ptr, index);
|
||||||
file_index_to_stable_id.insert(index, StableFilemapId::new(&file));
|
file_index_to_stable_id.insert(index, StableFilemapId::new(&file));
|
||||||
}
|
}
|
||||||
|
@ -478,13 +478,13 @@ struct CacheDecoder<'a, 'tcx: 'a, 'x> {
|
||||||
codemap: &'x SourceMap,
|
codemap: &'x SourceMap,
|
||||||
cnum_map: &'x IndexVec<CrateNum, Option<CrateNum>>,
|
cnum_map: &'x IndexVec<CrateNum, Option<CrateNum>>,
|
||||||
synthetic_expansion_infos: &'x Lock<FxHashMap<AbsoluteBytePos, SyntaxContext>>,
|
synthetic_expansion_infos: &'x Lock<FxHashMap<AbsoluteBytePos, SyntaxContext>>,
|
||||||
file_index_to_file: &'x Lock<FxHashMap<FileMapIndex, Lrc<FileMap>>>,
|
file_index_to_file: &'x Lock<FxHashMap<SourceFileIndex, Lrc<SourceFile>>>,
|
||||||
file_index_to_stable_id: &'x FxHashMap<FileMapIndex, StableFilemapId>,
|
file_index_to_stable_id: &'x FxHashMap<SourceFileIndex, StableFilemapId>,
|
||||||
alloc_decoding_session: AllocDecodingSession<'x>,
|
alloc_decoding_session: AllocDecodingSession<'x>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a, 'tcx, 'x> CacheDecoder<'a, 'tcx, 'x> {
|
impl<'a, 'tcx, 'x> CacheDecoder<'a, 'tcx, 'x> {
|
||||||
fn file_index_to_file(&self, index: FileMapIndex) -> Lrc<FileMap> {
|
fn file_index_to_file(&self, index: SourceFileIndex) -> Lrc<SourceFile> {
|
||||||
let CacheDecoder {
|
let CacheDecoder {
|
||||||
ref file_index_to_file,
|
ref file_index_to_file,
|
||||||
ref file_index_to_stable_id,
|
ref file_index_to_stable_id,
|
||||||
|
@ -495,7 +495,7 @@ impl<'a, 'tcx, 'x> CacheDecoder<'a, 'tcx, 'x> {
|
||||||
file_index_to_file.borrow_mut().entry(index).or_insert_with(|| {
|
file_index_to_file.borrow_mut().entry(index).or_insert_with(|| {
|
||||||
let stable_id = file_index_to_stable_id[&index];
|
let stable_id = file_index_to_stable_id[&index];
|
||||||
codemap.filemap_by_stable_id(stable_id)
|
codemap.filemap_by_stable_id(stable_id)
|
||||||
.expect("Failed to lookup FileMap in new context.")
|
.expect("Failed to lookup SourceFile in new context.")
|
||||||
}).clone()
|
}).clone()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -617,7 +617,7 @@ impl<'a, 'tcx, 'x> SpecializedDecoder<Span> for CacheDecoder<'a, 'tcx, 'x> {
|
||||||
debug_assert_eq!(tag, TAG_VALID_SPAN);
|
debug_assert_eq!(tag, TAG_VALID_SPAN);
|
||||||
}
|
}
|
||||||
|
|
||||||
let file_lo_index = FileMapIndex::decode(self)?;
|
let file_lo_index = SourceFileIndex::decode(self)?;
|
||||||
let line_lo = usize::decode(self)?;
|
let line_lo = usize::decode(self)?;
|
||||||
let col_lo = BytePos::decode(self)?;
|
let col_lo = BytePos::decode(self)?;
|
||||||
let len = BytePos::decode(self)?;
|
let len = BytePos::decode(self)?;
|
||||||
|
@ -771,14 +771,14 @@ struct CacheEncoder<'enc, 'a, 'tcx, E>
|
||||||
interpret_allocs: FxHashMap<interpret::AllocId, usize>,
|
interpret_allocs: FxHashMap<interpret::AllocId, usize>,
|
||||||
interpret_allocs_inverse: Vec<interpret::AllocId>,
|
interpret_allocs_inverse: Vec<interpret::AllocId>,
|
||||||
codemap: CachingCodemapView<'tcx>,
|
codemap: CachingCodemapView<'tcx>,
|
||||||
file_to_file_index: FxHashMap<*const FileMap, FileMapIndex>,
|
file_to_file_index: FxHashMap<*const SourceFile, SourceFileIndex>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'enc, 'a, 'tcx, E> CacheEncoder<'enc, 'a, 'tcx, E>
|
impl<'enc, 'a, 'tcx, E> CacheEncoder<'enc, 'a, 'tcx, E>
|
||||||
where E: 'enc + ty_codec::TyEncoder
|
where E: 'enc + ty_codec::TyEncoder
|
||||||
{
|
{
|
||||||
fn filemap_index(&mut self, filemap: Lrc<FileMap>) -> FileMapIndex {
|
fn filemap_index(&mut self, filemap: Lrc<SourceFile>) -> SourceFileIndex {
|
||||||
self.file_to_file_index[&(&*filemap as *const FileMap)]
|
self.file_to_file_index[&(&*filemap as *const SourceFile)]
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Encode something with additional information that allows to do some
|
/// Encode something with additional information that allows to do some
|
||||||
|
|
|
@ -1745,7 +1745,7 @@ pub fn create_global_var_metadata(
|
||||||
pub fn extend_scope_to_file(
|
pub fn extend_scope_to_file(
|
||||||
cx: &CodegenCx<'ll, '_>,
|
cx: &CodegenCx<'ll, '_>,
|
||||||
scope_metadata: &'ll DIScope,
|
scope_metadata: &'ll DIScope,
|
||||||
file: &syntax_pos::FileMap,
|
file: &syntax_pos::SourceFile,
|
||||||
defining_crate: CrateNum,
|
defining_crate: CrateNum,
|
||||||
) -> &'ll DILexicalBlock {
|
) -> &'ll DILexicalBlock {
|
||||||
let file_metadata = file_metadata(cx, &file.name, defining_crate);
|
let file_metadata = file_metadata(cx, &file.name, defining_crate);
|
||||||
|
|
|
@ -10,7 +10,7 @@
|
||||||
|
|
||||||
use self::Destination::*;
|
use self::Destination::*;
|
||||||
|
|
||||||
use syntax_pos::{FileMap, Span, MultiSpan};
|
use syntax_pos::{SourceFile, Span, MultiSpan};
|
||||||
|
|
||||||
use {Level, CodeSuggestion, DiagnosticBuilder, SubDiagnostic, SourceMapperDyn, DiagnosticId};
|
use {Level, CodeSuggestion, DiagnosticBuilder, SubDiagnostic, SourceMapperDyn, DiagnosticId};
|
||||||
use snippet::{Annotation, AnnotationType, Line, MultilineAnnotation, StyledString, Style};
|
use snippet::{Annotation, AnnotationType, Line, MultilineAnnotation, StyledString, Style};
|
||||||
|
@ -127,7 +127,7 @@ pub struct EmitterWriter {
|
||||||
}
|
}
|
||||||
|
|
||||||
struct FileWithAnnotatedLines {
|
struct FileWithAnnotatedLines {
|
||||||
file: Lrc<FileMap>,
|
file: Lrc<SourceFile>,
|
||||||
lines: Vec<Line>,
|
lines: Vec<Line>,
|
||||||
multiline_depth: usize,
|
multiline_depth: usize,
|
||||||
}
|
}
|
||||||
|
@ -177,7 +177,7 @@ impl EmitterWriter {
|
||||||
|
|
||||||
fn preprocess_annotations(&mut self, msp: &MultiSpan) -> Vec<FileWithAnnotatedLines> {
|
fn preprocess_annotations(&mut self, msp: &MultiSpan) -> Vec<FileWithAnnotatedLines> {
|
||||||
fn add_annotation_to_file(file_vec: &mut Vec<FileWithAnnotatedLines>,
|
fn add_annotation_to_file(file_vec: &mut Vec<FileWithAnnotatedLines>,
|
||||||
file: Lrc<FileMap>,
|
file: Lrc<SourceFile>,
|
||||||
line_index: usize,
|
line_index: usize,
|
||||||
ann: Annotation) {
|
ann: Annotation) {
|
||||||
|
|
||||||
|
@ -307,7 +307,7 @@ impl EmitterWriter {
|
||||||
|
|
||||||
fn render_source_line(&self,
|
fn render_source_line(&self,
|
||||||
buffer: &mut StyledBuffer,
|
buffer: &mut StyledBuffer,
|
||||||
file: Lrc<FileMap>,
|
file: Lrc<SourceFile>,
|
||||||
line: &Line,
|
line: &Line,
|
||||||
width_offset: usize,
|
width_offset: usize,
|
||||||
code_offset: usize) -> Vec<(usize, Style)> {
|
code_offset: usize) -> Vec<(usize, Style)> {
|
||||||
|
|
|
@ -55,7 +55,7 @@ pub mod registry;
|
||||||
mod styled_buffer;
|
mod styled_buffer;
|
||||||
mod lock;
|
mod lock;
|
||||||
|
|
||||||
use syntax_pos::{BytePos, Loc, FileLinesResult, FileMap, FileName, MultiSpan, Span, NO_EXPANSION};
|
use syntax_pos::{BytePos, Loc, FileLinesResult, SourceFile, FileName, MultiSpan, Span, NO_EXPANSION};
|
||||||
|
|
||||||
#[derive(Copy, Clone, Debug, PartialEq, Hash, RustcEncodable, RustcDecodable)]
|
#[derive(Copy, Clone, Debug, PartialEq, Hash, RustcEncodable, RustcDecodable)]
|
||||||
pub enum Applicability {
|
pub enum Applicability {
|
||||||
|
@ -120,7 +120,7 @@ pub trait SourceMapper {
|
||||||
fn span_to_filename(&self, sp: Span) -> FileName;
|
fn span_to_filename(&self, sp: Span) -> FileName;
|
||||||
fn merge_spans(&self, sp_lhs: Span, sp_rhs: Span) -> Option<Span>;
|
fn merge_spans(&self, sp_lhs: Span, sp_rhs: Span) -> Option<Span>;
|
||||||
fn call_span_if_macro(&self, sp: Span) -> Span;
|
fn call_span_if_macro(&self, sp: Span) -> Span;
|
||||||
fn ensure_filemap_source_present(&self, file_map: Lrc<FileMap>) -> bool;
|
fn ensure_filemap_source_present(&self, file_map: Lrc<SourceFile>) -> bool;
|
||||||
fn doctest_offset_line(&self, line: usize) -> usize;
|
fn doctest_offset_line(&self, line: usize) -> usize;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -41,15 +41,15 @@ pub use rustc_data_structures::sync::MetadataRef;
|
||||||
|
|
||||||
pub struct MetadataBlob(pub MetadataRef);
|
pub struct MetadataBlob(pub MetadataRef);
|
||||||
|
|
||||||
/// Holds information about a syntax_pos::FileMap imported from another crate.
|
/// Holds information about a syntax_pos::SourceFile imported from another crate.
|
||||||
/// See `imported_filemaps()` for more information.
|
/// See `imported_filemaps()` for more information.
|
||||||
pub struct ImportedFileMap {
|
pub struct ImportedSourceFile {
|
||||||
/// This FileMap's byte-offset within the codemap of its original crate
|
/// This SourceFile's byte-offset within the codemap of its original crate
|
||||||
pub original_start_pos: syntax_pos::BytePos,
|
pub original_start_pos: syntax_pos::BytePos,
|
||||||
/// The end of this FileMap within the codemap of its original crate
|
/// The end of this SourceFile within the codemap of its original crate
|
||||||
pub original_end_pos: syntax_pos::BytePos,
|
pub original_end_pos: syntax_pos::BytePos,
|
||||||
/// The imported FileMap's representation within the local codemap
|
/// The imported SourceFile's representation within the local codemap
|
||||||
pub translated_filemap: Lrc<syntax_pos::FileMap>,
|
pub translated_filemap: Lrc<syntax_pos::SourceFile>,
|
||||||
}
|
}
|
||||||
|
|
||||||
pub struct CrateMetadata {
|
pub struct CrateMetadata {
|
||||||
|
@ -64,7 +64,7 @@ pub struct CrateMetadata {
|
||||||
pub cnum_map: CrateNumMap,
|
pub cnum_map: CrateNumMap,
|
||||||
pub cnum: CrateNum,
|
pub cnum: CrateNum,
|
||||||
pub dependencies: Lock<Vec<CrateNum>>,
|
pub dependencies: Lock<Vec<CrateNum>>,
|
||||||
pub codemap_import_info: RwLock<Vec<ImportedFileMap>>,
|
pub codemap_import_info: RwLock<Vec<ImportedSourceFile>>,
|
||||||
|
|
||||||
/// Used for decoding interpret::AllocIds in a cached & thread-safe manner.
|
/// Used for decoding interpret::AllocIds in a cached & thread-safe manner.
|
||||||
pub alloc_decoding_state: AllocDecodingState,
|
pub alloc_decoding_state: AllocDecodingState,
|
||||||
|
|
|
@ -1099,26 +1099,26 @@ impl<'a, 'tcx> CrateMetadata {
|
||||||
///
|
///
|
||||||
/// The import algorithm works analogous to how AST items are inlined from an
|
/// The import algorithm works analogous to how AST items are inlined from an
|
||||||
/// external crate's metadata:
|
/// external crate's metadata:
|
||||||
/// For every FileMap in the external codemap an 'inline' copy is created in the
|
/// For every SourceFile in the external codemap an 'inline' copy is created in the
|
||||||
/// local codemap. The correspondence relation between external and local
|
/// local codemap. The correspondence relation between external and local
|
||||||
/// FileMaps is recorded in the `ImportedFileMap` objects returned from this
|
/// SourceFiles is recorded in the `ImportedSourceFile` objects returned from this
|
||||||
/// function. When an item from an external crate is later inlined into this
|
/// function. When an item from an external crate is later inlined into this
|
||||||
/// crate, this correspondence information is used to translate the span
|
/// crate, this correspondence information is used to translate the span
|
||||||
/// information of the inlined item so that it refers the correct positions in
|
/// information of the inlined item so that it refers the correct positions in
|
||||||
/// the local codemap (see `<decoder::DecodeContext as SpecializedDecoder<Span>>`).
|
/// the local codemap (see `<decoder::DecodeContext as SpecializedDecoder<Span>>`).
|
||||||
///
|
///
|
||||||
/// The import algorithm in the function below will reuse FileMaps already
|
/// The import algorithm in the function below will reuse SourceFiles already
|
||||||
/// existing in the local codemap. For example, even if the FileMap of some
|
/// existing in the local codemap. For example, even if the SourceFile of some
|
||||||
/// source file of libstd gets imported many times, there will only ever be
|
/// source file of libstd gets imported many times, there will only ever be
|
||||||
/// one FileMap object for the corresponding file in the local codemap.
|
/// one SourceFile object for the corresponding file in the local codemap.
|
||||||
///
|
///
|
||||||
/// Note that imported FileMaps do not actually contain the source code of the
|
/// Note that imported SourceFiles do not actually contain the source code of the
|
||||||
/// file they represent, just information about length, line breaks, and
|
/// file they represent, just information about length, line breaks, and
|
||||||
/// multibyte characters. This information is enough to generate valid debuginfo
|
/// multibyte characters. This information is enough to generate valid debuginfo
|
||||||
/// for items inlined from other crates.
|
/// for items inlined from other crates.
|
||||||
pub fn imported_filemaps(&'a self,
|
pub fn imported_filemaps(&'a self,
|
||||||
local_codemap: &codemap::SourceMap)
|
local_codemap: &codemap::SourceMap)
|
||||||
-> ReadGuard<'a, Vec<cstore::ImportedFileMap>> {
|
-> ReadGuard<'a, Vec<cstore::ImportedSourceFile>> {
|
||||||
{
|
{
|
||||||
let filemaps = self.codemap_import_info.borrow();
|
let filemaps = self.codemap_import_info.borrow();
|
||||||
if !filemaps.is_empty() {
|
if !filemaps.is_empty() {
|
||||||
|
@ -1137,9 +1137,9 @@ impl<'a, 'tcx> CrateMetadata {
|
||||||
let external_codemap = self.root.codemap.decode(self);
|
let external_codemap = self.root.codemap.decode(self);
|
||||||
|
|
||||||
let imported_filemaps = external_codemap.map(|filemap_to_import| {
|
let imported_filemaps = external_codemap.map(|filemap_to_import| {
|
||||||
// We can't reuse an existing FileMap, so allocate a new one
|
// We can't reuse an existing SourceFile, so allocate a new one
|
||||||
// containing the information we need.
|
// containing the information we need.
|
||||||
let syntax_pos::FileMap { name,
|
let syntax_pos::SourceFile { name,
|
||||||
name_was_remapped,
|
name_was_remapped,
|
||||||
src_hash,
|
src_hash,
|
||||||
start_pos,
|
start_pos,
|
||||||
|
@ -1156,7 +1156,7 @@ impl<'a, 'tcx> CrateMetadata {
|
||||||
// position into frame of reference local to file.
|
// position into frame of reference local to file.
|
||||||
// `SourceMap::new_imported_filemap()` will then translate those
|
// `SourceMap::new_imported_filemap()` will then translate those
|
||||||
// coordinates to their new global frame of reference when the
|
// coordinates to their new global frame of reference when the
|
||||||
// offset of the FileMap is known.
|
// offset of the SourceFile is known.
|
||||||
for pos in &mut lines {
|
for pos in &mut lines {
|
||||||
*pos = *pos - start_pos;
|
*pos = *pos - start_pos;
|
||||||
}
|
}
|
||||||
|
@ -1182,7 +1182,7 @@ impl<'a, 'tcx> CrateMetadata {
|
||||||
local_version.name, start_pos, end_pos,
|
local_version.name, start_pos, end_pos,
|
||||||
local_version.start_pos, local_version.end_pos);
|
local_version.start_pos, local_version.end_pos);
|
||||||
|
|
||||||
cstore::ImportedFileMap {
|
cstore::ImportedSourceFile {
|
||||||
original_start_pos: start_pos,
|
original_start_pos: start_pos,
|
||||||
original_end_pos: end_pos,
|
original_end_pos: end_pos,
|
||||||
translated_filemap: local_version,
|
translated_filemap: local_version,
|
||||||
|
|
|
@ -42,7 +42,7 @@ use syntax::ast::{self, CRATE_NODE_ID};
|
||||||
use syntax::attr;
|
use syntax::attr;
|
||||||
use syntax::codemap::Spanned;
|
use syntax::codemap::Spanned;
|
||||||
use syntax::symbol::keywords;
|
use syntax::symbol::keywords;
|
||||||
use syntax_pos::{self, hygiene, FileName, FileMap, Span};
|
use syntax_pos::{self, hygiene, FileName, SourceFile, Span};
|
||||||
|
|
||||||
use rustc::hir::{self, PatKind};
|
use rustc::hir::{self, PatKind};
|
||||||
use rustc::hir::itemlikevisit::ItemLikeVisitor;
|
use rustc::hir::itemlikevisit::ItemLikeVisitor;
|
||||||
|
@ -62,7 +62,7 @@ pub struct EncodeContext<'a, 'tcx: 'a> {
|
||||||
interpret_allocs_inverse: Vec<interpret::AllocId>,
|
interpret_allocs_inverse: Vec<interpret::AllocId>,
|
||||||
|
|
||||||
// This is used to speed up Span encoding.
|
// This is used to speed up Span encoding.
|
||||||
filemap_cache: Lrc<FileMap>,
|
filemap_cache: Lrc<SourceFile>,
|
||||||
}
|
}
|
||||||
|
|
||||||
macro_rules! encoder_methods {
|
macro_rules! encoder_methods {
|
||||||
|
@ -337,7 +337,7 @@ impl<'a, 'tcx> EncodeContext<'a, 'tcx> {
|
||||||
self.lazy(definitions.def_path_table())
|
self.lazy(definitions.def_path_table())
|
||||||
}
|
}
|
||||||
|
|
||||||
fn encode_codemap(&mut self) -> LazySeq<syntax_pos::FileMap> {
|
fn encode_codemap(&mut self) -> LazySeq<syntax_pos::SourceFile> {
|
||||||
let codemap = self.tcx.sess.codemap();
|
let codemap = self.tcx.sess.codemap();
|
||||||
let all_filemaps = codemap.files();
|
let all_filemaps = codemap.files();
|
||||||
|
|
||||||
|
@ -350,7 +350,7 @@ impl<'a, 'tcx> EncodeContext<'a, 'tcx> {
|
||||||
!filemap.is_imported()
|
!filemap.is_imported()
|
||||||
})
|
})
|
||||||
.map(|filemap| {
|
.map(|filemap| {
|
||||||
// When exporting FileMaps, we expand all paths to absolute
|
// When exporting SourceFiles, we expand all paths to absolute
|
||||||
// paths because any relative paths are potentially relative to
|
// paths because any relative paths are potentially relative to
|
||||||
// a wrong directory.
|
// a wrong directory.
|
||||||
// However, if a path has been modified via
|
// However, if a path has been modified via
|
||||||
|
@ -361,7 +361,7 @@ impl<'a, 'tcx> EncodeContext<'a, 'tcx> {
|
||||||
FileName::Real(ref name) => {
|
FileName::Real(ref name) => {
|
||||||
if filemap.name_was_remapped ||
|
if filemap.name_was_remapped ||
|
||||||
(name.is_relative() && working_dir_was_remapped) {
|
(name.is_relative() && working_dir_was_remapped) {
|
||||||
// This path of this FileMap has been modified by
|
// This path of this SourceFile has been modified by
|
||||||
// path-remapping, so we use it verbatim (and avoid cloning
|
// path-remapping, so we use it verbatim (and avoid cloning
|
||||||
// the whole map in the process).
|
// the whole map in the process).
|
||||||
filemap.clone()
|
filemap.clone()
|
||||||
|
|
|
@ -204,7 +204,7 @@ pub struct CrateRoot {
|
||||||
pub lang_items_missing: LazySeq<lang_items::LangItem>,
|
pub lang_items_missing: LazySeq<lang_items::LangItem>,
|
||||||
pub native_libraries: LazySeq<NativeLibrary>,
|
pub native_libraries: LazySeq<NativeLibrary>,
|
||||||
pub foreign_modules: LazySeq<ForeignModule>,
|
pub foreign_modules: LazySeq<ForeignModule>,
|
||||||
pub codemap: LazySeq<syntax_pos::FileMap>,
|
pub codemap: LazySeq<syntax_pos::SourceFile>,
|
||||||
pub def_path_table: Lazy<hir::map::definitions::DefPathTable>,
|
pub def_path_table: Lazy<hir::map::definitions::DefPathTable>,
|
||||||
pub impls: LazySeq<TraitImpls>,
|
pub impls: LazySeq<TraitImpls>,
|
||||||
pub exported_symbols: EncodedExportedSymbols,
|
pub exported_symbols: EncodedExportedSymbols,
|
||||||
|
|
|
@ -603,7 +603,7 @@ impl Clean<Item> for doctree::Module {
|
||||||
// mod foo { ... }
|
// mod foo { ... }
|
||||||
self.where_outer
|
self.where_outer
|
||||||
} else {
|
} else {
|
||||||
// mod foo; (and a separate FileMap for the contents)
|
// mod foo; (and a separate SourceFile for the contents)
|
||||||
self.where_inner
|
self.where_inner
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
|
@ -12,7 +12,7 @@
|
||||||
//! from integer byte positions to the original source code location. Each bit
|
//! from integer byte positions to the original source code location. Each bit
|
||||||
//! of source parsed during crate parsing (typically files, in-memory strings,
|
//! of source parsed during crate parsing (typically files, in-memory strings,
|
||||||
//! or various bits of macro expansion) cover a continuous range of bytes in the
|
//! or various bits of macro expansion) cover a continuous range of bytes in the
|
||||||
//! SourceMap and are represented by FileMaps. Byte positions are stored in
|
//! SourceMap and are represented by SourceFiles. Byte positions are stored in
|
||||||
//! `spans` and used pervasively in the compiler. They are absolute positions
|
//! `spans` and used pervasively in the compiler. They are absolute positions
|
||||||
//! within the SourceMap, which upon request can be converted to line and column
|
//! within the SourceMap, which upon request can be converted to line and column
|
||||||
//! information, source code snippets, etc.
|
//! information, source code snippets, etc.
|
||||||
|
@ -62,7 +62,7 @@ pub fn dummy_spanned<T>(t: T) -> Spanned<T> {
|
||||||
}
|
}
|
||||||
|
|
||||||
// _____________________________________________________________________________
|
// _____________________________________________________________________________
|
||||||
// FileMap, MultiByteChar, FileName, FileLines
|
// SourceFile, MultiByteChar, FileName, FileLines
|
||||||
//
|
//
|
||||||
|
|
||||||
/// An abstraction over the fs operations used by the Parser.
|
/// An abstraction over the fs operations used by the Parser.
|
||||||
|
@ -102,14 +102,14 @@ impl FileLoader for RealFileLoader {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// This is a FileMap identifier that is used to correlate FileMaps between
|
// This is a SourceFile identifier that is used to correlate SourceFiles between
|
||||||
// subsequent compilation sessions (which is something we need to do during
|
// subsequent compilation sessions (which is something we need to do during
|
||||||
// incremental compilation).
|
// incremental compilation).
|
||||||
#[derive(Copy, Clone, PartialEq, Eq, Hash, RustcEncodable, RustcDecodable, Debug)]
|
#[derive(Copy, Clone, PartialEq, Eq, Hash, RustcEncodable, RustcDecodable, Debug)]
|
||||||
pub struct StableFilemapId(u128);
|
pub struct StableFilemapId(u128);
|
||||||
|
|
||||||
impl StableFilemapId {
|
impl StableFilemapId {
|
||||||
pub fn new(filemap: &FileMap) -> StableFilemapId {
|
pub fn new(filemap: &SourceFile) -> StableFilemapId {
|
||||||
let mut hasher = StableHasher::new();
|
let mut hasher = StableHasher::new();
|
||||||
|
|
||||||
filemap.name.hash(&mut hasher);
|
filemap.name.hash(&mut hasher);
|
||||||
|
@ -125,15 +125,15 @@ impl StableFilemapId {
|
||||||
//
|
//
|
||||||
|
|
||||||
pub(super) struct SourceMapFiles {
|
pub(super) struct SourceMapFiles {
|
||||||
pub(super) file_maps: Vec<Lrc<FileMap>>,
|
pub(super) file_maps: Vec<Lrc<SourceFile>>,
|
||||||
stable_id_to_filemap: FxHashMap<StableFilemapId, Lrc<FileMap>>
|
stable_id_to_filemap: FxHashMap<StableFilemapId, Lrc<SourceFile>>
|
||||||
}
|
}
|
||||||
|
|
||||||
pub struct SourceMap {
|
pub struct SourceMap {
|
||||||
pub(super) files: Lock<SourceMapFiles>,
|
pub(super) files: Lock<SourceMapFiles>,
|
||||||
file_loader: Box<dyn FileLoader + Sync + Send>,
|
file_loader: Box<dyn FileLoader + Sync + Send>,
|
||||||
// This is used to apply the file path remapping as specified via
|
// This is used to apply the file path remapping as specified via
|
||||||
// --remap-path-prefix to all FileMaps allocated within this SourceMap.
|
// --remap-path-prefix to all SourceFiles allocated within this SourceMap.
|
||||||
path_mapping: FilePathMapping,
|
path_mapping: FilePathMapping,
|
||||||
/// In case we are in a doctest, replace all file names with the PathBuf,
|
/// In case we are in a doctest, replace all file names with the PathBuf,
|
||||||
/// and add the given offsets to the line info
|
/// and add the given offsets to the line info
|
||||||
|
@ -184,7 +184,7 @@ impl SourceMap {
|
||||||
self.file_loader.file_exists(path)
|
self.file_loader.file_exists(path)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn load_file(&self, path: &Path) -> io::Result<Lrc<FileMap>> {
|
pub fn load_file(&self, path: &Path) -> io::Result<Lrc<SourceFile>> {
|
||||||
let src = self.file_loader.read_file(path)?;
|
let src = self.file_loader.read_file(path)?;
|
||||||
let filename = if let Some((ref name, _)) = self.doctest_offset {
|
let filename = if let Some((ref name, _)) = self.doctest_offset {
|
||||||
name.clone()
|
name.clone()
|
||||||
|
@ -194,11 +194,11 @@ impl SourceMap {
|
||||||
Ok(self.new_filemap(filename, src))
|
Ok(self.new_filemap(filename, src))
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn files(&self) -> LockGuard<Vec<Lrc<FileMap>>> {
|
pub fn files(&self) -> LockGuard<Vec<Lrc<SourceFile>>> {
|
||||||
LockGuard::map(self.files.borrow(), |files| &mut files.file_maps)
|
LockGuard::map(self.files.borrow(), |files| &mut files.file_maps)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn filemap_by_stable_id(&self, stable_id: StableFilemapId) -> Option<Lrc<FileMap>> {
|
pub fn filemap_by_stable_id(&self, stable_id: StableFilemapId) -> Option<Lrc<SourceFile>> {
|
||||||
self.files.borrow().stable_id_to_filemap.get(&stable_id).map(|fm| fm.clone())
|
self.files.borrow().stable_id_to_filemap.get(&stable_id).map(|fm| fm.clone())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -212,8 +212,8 @@ impl SourceMap {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Creates a new filemap.
|
/// Creates a new filemap.
|
||||||
/// This does not ensure that only one FileMap exists per file name.
|
/// This does not ensure that only one SourceFile exists per file name.
|
||||||
pub fn new_filemap(&self, filename: FileName, src: String) -> Lrc<FileMap> {
|
pub fn new_filemap(&self, filename: FileName, src: String) -> Lrc<SourceFile> {
|
||||||
let start_pos = self.next_start_pos();
|
let start_pos = self.next_start_pos();
|
||||||
|
|
||||||
// The path is used to determine the directory for loading submodules and
|
// The path is used to determine the directory for loading submodules and
|
||||||
|
@ -230,7 +230,7 @@ impl SourceMap {
|
||||||
},
|
},
|
||||||
other => (other, false),
|
other => (other, false),
|
||||||
};
|
};
|
||||||
let filemap = Lrc::new(FileMap::new(
|
let filemap = Lrc::new(SourceFile::new(
|
||||||
filename,
|
filename,
|
||||||
was_remapped,
|
was_remapped,
|
||||||
unmapped_path,
|
unmapped_path,
|
||||||
|
@ -246,7 +246,7 @@ impl SourceMap {
|
||||||
filemap
|
filemap
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Allocates a new FileMap representing a source file from an external
|
/// Allocates a new SourceFile representing a source file from an external
|
||||||
/// crate. The source code of such an "imported filemap" is not available,
|
/// crate. The source code of such an "imported filemap" is not available,
|
||||||
/// but we still know enough to generate accurate debuginfo location
|
/// but we still know enough to generate accurate debuginfo location
|
||||||
/// information for things inlined from other crates.
|
/// information for things inlined from other crates.
|
||||||
|
@ -260,7 +260,7 @@ impl SourceMap {
|
||||||
mut file_local_lines: Vec<BytePos>,
|
mut file_local_lines: Vec<BytePos>,
|
||||||
mut file_local_multibyte_chars: Vec<MultiByteChar>,
|
mut file_local_multibyte_chars: Vec<MultiByteChar>,
|
||||||
mut file_local_non_narrow_chars: Vec<NonNarrowChar>)
|
mut file_local_non_narrow_chars: Vec<NonNarrowChar>)
|
||||||
-> Lrc<FileMap> {
|
-> Lrc<SourceFile> {
|
||||||
let start_pos = self.next_start_pos();
|
let start_pos = self.next_start_pos();
|
||||||
|
|
||||||
let end_pos = Pos::from_usize(start_pos + source_len);
|
let end_pos = Pos::from_usize(start_pos + source_len);
|
||||||
|
@ -278,7 +278,7 @@ impl SourceMap {
|
||||||
*swc = *swc + start_pos;
|
*swc = *swc + start_pos;
|
||||||
}
|
}
|
||||||
|
|
||||||
let filemap = Lrc::new(FileMap {
|
let filemap = Lrc::new(SourceFile {
|
||||||
name: filename,
|
name: filename,
|
||||||
name_was_remapped,
|
name_was_remapped,
|
||||||
unmapped_path: None,
|
unmapped_path: None,
|
||||||
|
@ -326,7 +326,7 @@ impl SourceMap {
|
||||||
pub fn lookup_char_pos(&self, pos: BytePos) -> Loc {
|
pub fn lookup_char_pos(&self, pos: BytePos) -> Loc {
|
||||||
let chpos = self.bytepos_to_file_charpos(pos);
|
let chpos = self.bytepos_to_file_charpos(pos);
|
||||||
match self.lookup_line(pos) {
|
match self.lookup_line(pos) {
|
||||||
Ok(FileMapAndLine { fm: f, line: a }) => {
|
Ok(SourceFileAndLine { fm: f, line: a }) => {
|
||||||
let line = a + 1; // Line numbers start at 1
|
let line = a + 1; // Line numbers start at 1
|
||||||
let linebpos = f.lines[a];
|
let linebpos = f.lines[a];
|
||||||
let linechpos = self.bytepos_to_file_charpos(linebpos);
|
let linechpos = self.bytepos_to_file_charpos(linebpos);
|
||||||
|
@ -386,13 +386,13 @@ impl SourceMap {
|
||||||
}
|
}
|
||||||
|
|
||||||
// If the relevant filemap is empty, we don't return a line number.
|
// If the relevant filemap is empty, we don't return a line number.
|
||||||
pub fn lookup_line(&self, pos: BytePos) -> Result<FileMapAndLine, Lrc<FileMap>> {
|
pub fn lookup_line(&self, pos: BytePos) -> Result<SourceFileAndLine, Lrc<SourceFile>> {
|
||||||
let idx = self.lookup_filemap_idx(pos);
|
let idx = self.lookup_filemap_idx(pos);
|
||||||
|
|
||||||
let f = (*self.files.borrow().file_maps)[idx].clone();
|
let f = (*self.files.borrow().file_maps)[idx].clone();
|
||||||
|
|
||||||
match f.lookup_line(pos) {
|
match f.lookup_line(pos) {
|
||||||
Some(line) => Ok(FileMapAndLine { fm: f, line: line }),
|
Some(line) => Ok(SourceFileAndLine { fm: f, line: line }),
|
||||||
None => Err(f)
|
None => Err(f)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -463,7 +463,7 @@ impl SourceMap {
|
||||||
|
|
||||||
pub fn span_to_unmapped_path(&self, sp: Span) -> FileName {
|
pub fn span_to_unmapped_path(&self, sp: Span) -> FileName {
|
||||||
self.lookup_char_pos(sp.lo()).file.unmapped_path.clone()
|
self.lookup_char_pos(sp.lo()).file.unmapped_path.clone()
|
||||||
.expect("SourceMap::span_to_unmapped_path called for imported FileMap?")
|
.expect("SourceMap::span_to_unmapped_path called for imported SourceFile?")
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn is_multiline(&self, sp: Span) -> bool {
|
pub fn is_multiline(&self, sp: Span) -> bool {
|
||||||
|
@ -798,7 +798,7 @@ impl SourceMap {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn get_filemap(&self, filename: &FileName) -> Option<Lrc<FileMap>> {
|
pub fn get_filemap(&self, filename: &FileName) -> Option<Lrc<SourceFile>> {
|
||||||
for fm in self.files.borrow().file_maps.iter() {
|
for fm in self.files.borrow().file_maps.iter() {
|
||||||
if *filename == fm.name {
|
if *filename == fm.name {
|
||||||
return Some(fm.clone());
|
return Some(fm.clone());
|
||||||
|
@ -807,12 +807,12 @@ impl SourceMap {
|
||||||
None
|
None
|
||||||
}
|
}
|
||||||
|
|
||||||
/// For a global BytePos compute the local offset within the containing FileMap
|
/// For a global BytePos compute the local offset within the containing SourceFile
|
||||||
pub fn lookup_byte_offset(&self, bpos: BytePos) -> FileMapAndBytePos {
|
pub fn lookup_byte_offset(&self, bpos: BytePos) -> SourceFileAndBytePos {
|
||||||
let idx = self.lookup_filemap_idx(bpos);
|
let idx = self.lookup_filemap_idx(bpos);
|
||||||
let fm = (*self.files.borrow().file_maps)[idx].clone();
|
let fm = (*self.files.borrow().file_maps)[idx].clone();
|
||||||
let offset = bpos - fm.start_pos;
|
let offset = bpos - fm.start_pos;
|
||||||
FileMapAndBytePos {fm: fm, pos: offset}
|
SourceFileAndBytePos {fm: fm, pos: offset}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Converts an absolute BytePos to a CharPos relative to the filemap.
|
/// Converts an absolute BytePos to a CharPos relative to the filemap.
|
||||||
|
@ -820,7 +820,7 @@ impl SourceMap {
|
||||||
let idx = self.lookup_filemap_idx(bpos);
|
let idx = self.lookup_filemap_idx(bpos);
|
||||||
let map = &(*self.files.borrow().file_maps)[idx];
|
let map = &(*self.files.borrow().file_maps)[idx];
|
||||||
|
|
||||||
// The number of extra bytes due to multibyte chars in the FileMap
|
// The number of extra bytes due to multibyte chars in the SourceFile
|
||||||
let mut total_extra_bytes = 0;
|
let mut total_extra_bytes = 0;
|
||||||
|
|
||||||
for mbc in map.multibyte_chars.iter() {
|
for mbc in map.multibyte_chars.iter() {
|
||||||
|
@ -966,7 +966,7 @@ impl SourceMapper for SourceMap {
|
||||||
}
|
}
|
||||||
sp
|
sp
|
||||||
}
|
}
|
||||||
fn ensure_filemap_source_present(&self, file_map: Lrc<FileMap>) -> bool {
|
fn ensure_filemap_source_present(&self, file_map: Lrc<SourceFile>) -> bool {
|
||||||
file_map.add_external_src(
|
file_map.add_external_src(
|
||||||
|| match file_map.name {
|
|| match file_map.name {
|
||||||
FileName::Real(ref name) => self.file_loader.read_file(name).ok(),
|
FileName::Real(ref name) => self.file_loader.read_file(name).ok(),
|
||||||
|
@ -1192,7 +1192,7 @@ mod tests {
|
||||||
/// `substring` in `source_text`.
|
/// `substring` in `source_text`.
|
||||||
trait SourceMapExtension {
|
trait SourceMapExtension {
|
||||||
fn span_substr(&self,
|
fn span_substr(&self,
|
||||||
file: &Lrc<FileMap>,
|
file: &Lrc<SourceFile>,
|
||||||
source_text: &str,
|
source_text: &str,
|
||||||
substring: &str,
|
substring: &str,
|
||||||
n: usize)
|
n: usize)
|
||||||
|
@ -1201,7 +1201,7 @@ mod tests {
|
||||||
|
|
||||||
impl SourceMapExtension for SourceMap {
|
impl SourceMapExtension for SourceMap {
|
||||||
fn span_substr(&self,
|
fn span_substr(&self,
|
||||||
file: &Lrc<FileMap>,
|
file: &Lrc<SourceFile>,
|
||||||
source_text: &str,
|
source_text: &str,
|
||||||
substring: &str,
|
substring: &str,
|
||||||
n: usize)
|
n: usize)
|
||||||
|
|
|
@ -802,7 +802,7 @@ fn mk_stmts_let(cx: &ExtCtxt, sp: Span) -> Vec<ast::Stmt> {
|
||||||
// they happen to have a compiler on hand). Over all, the phase distinction
|
// they happen to have a compiler on hand). Over all, the phase distinction
|
||||||
// just makes quotes "hard to attribute". Possibly this could be fixed
|
// just makes quotes "hard to attribute". Possibly this could be fixed
|
||||||
// by recreating some of the original qq machinery in the tt regime
|
// by recreating some of the original qq machinery in the tt regime
|
||||||
// (pushing fake FileMaps onto the parser to account for original sites
|
// (pushing fake SourceFiles onto the parser to account for original sites
|
||||||
// of quotes, for example) but at this point it seems not likely to be
|
// of quotes, for example) but at this point it seems not likely to be
|
||||||
// worth the hassle.
|
// worth the hassle.
|
||||||
|
|
||||||
|
|
|
@ -340,7 +340,7 @@ impl DiagnosticSpan {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl DiagnosticSpanLine {
|
impl DiagnosticSpanLine {
|
||||||
fn line_from_filemap(fm: &syntax_pos::FileMap,
|
fn line_from_filemap(fm: &syntax_pos::SourceFile,
|
||||||
index: usize,
|
index: usize,
|
||||||
h_start: usize,
|
h_start: usize,
|
||||||
h_end: usize)
|
h_end: usize)
|
||||||
|
|
|
@ -49,7 +49,7 @@ pub struct StringReader<'a> {
|
||||||
pub pos: BytePos,
|
pub pos: BytePos,
|
||||||
/// The current character (which has been read from self.pos)
|
/// The current character (which has been read from self.pos)
|
||||||
pub ch: Option<char>,
|
pub ch: Option<char>,
|
||||||
pub filemap: Lrc<syntax_pos::FileMap>,
|
pub filemap: Lrc<syntax_pos::SourceFile>,
|
||||||
/// Stop reading src at this index.
|
/// Stop reading src at this index.
|
||||||
pub end_src_index: usize,
|
pub end_src_index: usize,
|
||||||
// cached:
|
// cached:
|
||||||
|
@ -180,7 +180,7 @@ impl<'a> StringReader<'a> {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// For comments.rs, which hackily pokes into next_pos and ch
|
/// For comments.rs, which hackily pokes into next_pos and ch
|
||||||
fn new_raw(sess: &'a ParseSess, filemap: Lrc<syntax_pos::FileMap>, override_span: Option<Span>)
|
fn new_raw(sess: &'a ParseSess, filemap: Lrc<syntax_pos::SourceFile>, override_span: Option<Span>)
|
||||||
-> Self
|
-> Self
|
||||||
{
|
{
|
||||||
let mut sr = StringReader::new_raw_internal(sess, filemap, override_span);
|
let mut sr = StringReader::new_raw_internal(sess, filemap, override_span);
|
||||||
|
@ -189,7 +189,7 @@ impl<'a> StringReader<'a> {
|
||||||
sr
|
sr
|
||||||
}
|
}
|
||||||
|
|
||||||
fn new_raw_internal(sess: &'a ParseSess, filemap: Lrc<syntax_pos::FileMap>,
|
fn new_raw_internal(sess: &'a ParseSess, filemap: Lrc<syntax_pos::SourceFile>,
|
||||||
override_span: Option<Span>) -> Self
|
override_span: Option<Span>) -> Self
|
||||||
{
|
{
|
||||||
if filemap.src.is_none() {
|
if filemap.src.is_none() {
|
||||||
|
@ -221,7 +221,7 @@ impl<'a> StringReader<'a> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn new(sess: &'a ParseSess, filemap: Lrc<syntax_pos::FileMap>, override_span: Option<Span>)
|
pub fn new(sess: &'a ParseSess, filemap: Lrc<syntax_pos::SourceFile>, override_span: Option<Span>)
|
||||||
-> Self
|
-> Self
|
||||||
{
|
{
|
||||||
let mut sr = StringReader::new_raw(sess, filemap, override_span);
|
let mut sr = StringReader::new_raw(sess, filemap, override_span);
|
||||||
|
@ -468,7 +468,7 @@ impl<'a> StringReader<'a> {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Advance the StringReader by one character. If a newline is
|
/// Advance the StringReader by one character. If a newline is
|
||||||
/// discovered, add it to the FileMap's list of line start offsets.
|
/// discovered, add it to the SourceFile's list of line start offsets.
|
||||||
crate fn bump(&mut self) {
|
crate fn bump(&mut self) {
|
||||||
let next_src_index = self.src_index(self.next_pos);
|
let next_src_index = self.src_index(self.next_pos);
|
||||||
if next_src_index < self.end_src_index {
|
if next_src_index < self.end_src_index {
|
||||||
|
|
|
@ -14,7 +14,7 @@ use rustc_data_structures::sync::{Lrc, Lock};
|
||||||
use ast::{self, CrateConfig, NodeId};
|
use ast::{self, CrateConfig, NodeId};
|
||||||
use early_buffered_lints::{BufferedEarlyLint, BufferedEarlyLintId};
|
use early_buffered_lints::{BufferedEarlyLint, BufferedEarlyLintId};
|
||||||
use codemap::{SourceMap, FilePathMapping};
|
use codemap::{SourceMap, FilePathMapping};
|
||||||
use syntax_pos::{Span, FileMap, FileName, MultiSpan};
|
use syntax_pos::{Span, SourceFile, FileName, MultiSpan};
|
||||||
use errors::{Handler, ColorConfig, DiagnosticBuilder};
|
use errors::{Handler, ColorConfig, DiagnosticBuilder};
|
||||||
use feature_gate::UnstableFeatures;
|
use feature_gate::UnstableFeatures;
|
||||||
use parse::parser::Parser;
|
use parse::parser::Parser;
|
||||||
|
@ -203,7 +203,7 @@ crate fn new_sub_parser_from_file<'a>(sess: &'a ParseSess,
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Given a filemap and config, return a parser
|
/// Given a filemap and config, return a parser
|
||||||
fn filemap_to_parser(sess: & ParseSess, filemap: Lrc<FileMap>) -> Parser {
|
fn filemap_to_parser(sess: & ParseSess, filemap: Lrc<SourceFile>) -> Parser {
|
||||||
let end_pos = filemap.end_pos;
|
let end_pos = filemap.end_pos;
|
||||||
let mut parser = stream_to_parser(sess, filemap_to_stream(sess, filemap, None));
|
let mut parser = stream_to_parser(sess, filemap_to_stream(sess, filemap, None));
|
||||||
|
|
||||||
|
@ -226,7 +226,7 @@ pub fn new_parser_from_tts(sess: &ParseSess, tts: Vec<TokenTree>) -> Parser {
|
||||||
/// Given a session and a path and an optional span (for error reporting),
|
/// Given a session and a path and an optional span (for error reporting),
|
||||||
/// add the path to the session's codemap and return the new filemap.
|
/// add the path to the session's codemap and return the new filemap.
|
||||||
fn file_to_filemap(sess: &ParseSess, path: &Path, spanopt: Option<Span>)
|
fn file_to_filemap(sess: &ParseSess, path: &Path, spanopt: Option<Span>)
|
||||||
-> Lrc<FileMap> {
|
-> Lrc<SourceFile> {
|
||||||
match sess.codemap().load_file(path) {
|
match sess.codemap().load_file(path) {
|
||||||
Ok(filemap) => filemap,
|
Ok(filemap) => filemap,
|
||||||
Err(e) => {
|
Err(e) => {
|
||||||
|
@ -240,7 +240,7 @@ fn file_to_filemap(sess: &ParseSess, path: &Path, spanopt: Option<Span>)
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Given a filemap, produce a sequence of token-trees
|
/// Given a filemap, produce a sequence of token-trees
|
||||||
pub fn filemap_to_stream(sess: &ParseSess, filemap: Lrc<FileMap>, override_span: Option<Span>)
|
pub fn filemap_to_stream(sess: &ParseSess, filemap: Lrc<SourceFile>, override_span: Option<Span>)
|
||||||
-> TokenStream {
|
-> TokenStream {
|
||||||
let mut srdr = lexer::StringReader::new(sess, filemap, override_span);
|
let mut srdr = lexer::StringReader::new(sess, filemap, override_span);
|
||||||
srdr.real_token();
|
srdr.real_token();
|
||||||
|
|
|
@ -20,7 +20,7 @@ use std::slice;
|
||||||
use std::mem;
|
use std::mem;
|
||||||
use std::vec;
|
use std::vec;
|
||||||
use attr::{self, HasAttrs};
|
use attr::{self, HasAttrs};
|
||||||
use syntax_pos::{self, DUMMY_SP, NO_EXPANSION, Span, FileMap, BytePos};
|
use syntax_pos::{self, DUMMY_SP, NO_EXPANSION, Span, SourceFile, BytePos};
|
||||||
|
|
||||||
use codemap::{self, SourceMap, ExpnInfo, MacroAttribute, dummy_spanned};
|
use codemap::{self, SourceMap, ExpnInfo, MacroAttribute, dummy_spanned};
|
||||||
use errors;
|
use errors;
|
||||||
|
|
|
@ -12,7 +12,7 @@ use unicode_width::UnicodeWidthChar;
|
||||||
use super::*;
|
use super::*;
|
||||||
|
|
||||||
/// Find all newlines, multi-byte characters, and non-narrow characters in a
|
/// Find all newlines, multi-byte characters, and non-narrow characters in a
|
||||||
/// FileMap.
|
/// SourceFile.
|
||||||
///
|
///
|
||||||
/// This function will use an SSE2 enhanced implementation if hardware support
|
/// This function will use an SSE2 enhanced implementation if hardware support
|
||||||
/// is detected at runtime.
|
/// is detected at runtime.
|
||||||
|
|
|
@ -163,7 +163,7 @@ impl FileName {
|
||||||
|
|
||||||
/// Spans represent a region of code, used for error reporting. Positions in spans
|
/// Spans represent a region of code, used for error reporting. Positions in spans
|
||||||
/// are *absolute* positions from the beginning of the codemap, not positions
|
/// are *absolute* positions from the beginning of the codemap, not positions
|
||||||
/// relative to FileMaps. Methods on the SourceMap can be used to relate spans back
|
/// relative to SourceFiles. Methods on the SourceMap can be used to relate spans back
|
||||||
/// to the original source.
|
/// to the original source.
|
||||||
/// You must be careful if the span crosses more than one file - you will not be
|
/// You must be careful if the span crosses more than one file - you will not be
|
||||||
/// able to use many of the functions on spans in codemap and you cannot assume
|
/// able to use many of the functions on spans in codemap and you cannot assume
|
||||||
|
@ -675,7 +675,7 @@ impl From<Vec<Span>> for MultiSpan {
|
||||||
|
|
||||||
pub const NO_EXPANSION: SyntaxContext = SyntaxContext::empty();
|
pub const NO_EXPANSION: SyntaxContext = SyntaxContext::empty();
|
||||||
|
|
||||||
/// Identifies an offset of a multi-byte character in a FileMap
|
/// Identifies an offset of a multi-byte character in a SourceFile
|
||||||
#[derive(Copy, Clone, RustcEncodable, RustcDecodable, Eq, PartialEq, Debug)]
|
#[derive(Copy, Clone, RustcEncodable, RustcDecodable, Eq, PartialEq, Debug)]
|
||||||
pub struct MultiByteChar {
|
pub struct MultiByteChar {
|
||||||
/// The absolute offset of the character in the SourceMap
|
/// The absolute offset of the character in the SourceMap
|
||||||
|
@ -684,7 +684,7 @@ pub struct MultiByteChar {
|
||||||
pub bytes: u8,
|
pub bytes: u8,
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Identifies an offset of a non-narrow character in a FileMap
|
/// Identifies an offset of a non-narrow character in a SourceFile
|
||||||
#[derive(Copy, Clone, RustcEncodable, RustcDecodable, Eq, PartialEq, Debug)]
|
#[derive(Copy, Clone, RustcEncodable, RustcDecodable, Eq, PartialEq, Debug)]
|
||||||
pub enum NonNarrowChar {
|
pub enum NonNarrowChar {
|
||||||
/// Represents a zero-width character
|
/// Represents a zero-width character
|
||||||
|
@ -748,7 +748,7 @@ impl Sub<BytePos> for NonNarrowChar {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// The state of the lazy external source loading mechanism of a FileMap.
|
/// The state of the lazy external source loading mechanism of a SourceFile.
|
||||||
#[derive(PartialEq, Eq, Clone)]
|
#[derive(PartialEq, Eq, Clone)]
|
||||||
pub enum ExternalSource {
|
pub enum ExternalSource {
|
||||||
/// The external source has been loaded already.
|
/// The external source has been loaded already.
|
||||||
|
@ -757,7 +757,7 @@ pub enum ExternalSource {
|
||||||
AbsentOk,
|
AbsentOk,
|
||||||
/// A failed attempt has been made to load the external source.
|
/// A failed attempt has been made to load the external source.
|
||||||
AbsentErr,
|
AbsentErr,
|
||||||
/// No external source has to be loaded, since the FileMap represents a local crate.
|
/// No external source has to be loaded, since the SourceFile represents a local crate.
|
||||||
Unneeded,
|
Unneeded,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -779,7 +779,7 @@ impl ExternalSource {
|
||||||
|
|
||||||
/// A single source in the SourceMap.
|
/// A single source in the SourceMap.
|
||||||
#[derive(Clone)]
|
#[derive(Clone)]
|
||||||
pub struct FileMap {
|
pub struct SourceFile {
|
||||||
/// The name of the file that the source came from, source that doesn't
|
/// The name of the file that the source came from, source that doesn't
|
||||||
/// originate from files has names between angle brackets by convention,
|
/// originate from files has names between angle brackets by convention,
|
||||||
/// e.g. `<anon>`
|
/// e.g. `<anon>`
|
||||||
|
@ -787,9 +787,9 @@ pub struct FileMap {
|
||||||
/// True if the `name` field above has been modified by --remap-path-prefix
|
/// True if the `name` field above has been modified by --remap-path-prefix
|
||||||
pub name_was_remapped: bool,
|
pub name_was_remapped: bool,
|
||||||
/// The unmapped path of the file that the source came from.
|
/// The unmapped path of the file that the source came from.
|
||||||
/// Set to `None` if the FileMap was imported from an external crate.
|
/// Set to `None` if the SourceFile was imported from an external crate.
|
||||||
pub unmapped_path: Option<FileName>,
|
pub unmapped_path: Option<FileName>,
|
||||||
/// Indicates which crate this FileMap was imported from.
|
/// Indicates which crate this SourceFile was imported from.
|
||||||
pub crate_of_origin: u32,
|
pub crate_of_origin: u32,
|
||||||
/// The complete source code
|
/// The complete source code
|
||||||
pub src: Option<Lrc<String>>,
|
pub src: Option<Lrc<String>>,
|
||||||
|
@ -812,9 +812,9 @@ pub struct FileMap {
|
||||||
pub name_hash: u128,
|
pub name_hash: u128,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Encodable for FileMap {
|
impl Encodable for SourceFile {
|
||||||
fn encode<S: Encoder>(&self, s: &mut S) -> Result<(), S::Error> {
|
fn encode<S: Encoder>(&self, s: &mut S) -> Result<(), S::Error> {
|
||||||
s.emit_struct("FileMap", 8, |s| {
|
s.emit_struct("SourceFile", 8, |s| {
|
||||||
s.emit_struct_field("name", 0, |s| self.name.encode(s))?;
|
s.emit_struct_field("name", 0, |s| self.name.encode(s))?;
|
||||||
s.emit_struct_field("name_was_remapped", 1, |s| self.name_was_remapped.encode(s))?;
|
s.emit_struct_field("name_was_remapped", 1, |s| self.name_was_remapped.encode(s))?;
|
||||||
s.emit_struct_field("src_hash", 2, |s| self.src_hash.encode(s))?;
|
s.emit_struct_field("src_hash", 2, |s| self.src_hash.encode(s))?;
|
||||||
|
@ -879,10 +879,10 @@ impl Encodable for FileMap {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Decodable for FileMap {
|
impl Decodable for SourceFile {
|
||||||
fn decode<D: Decoder>(d: &mut D) -> Result<FileMap, D::Error> {
|
fn decode<D: Decoder>(d: &mut D) -> Result<SourceFile, D::Error> {
|
||||||
|
|
||||||
d.read_struct("FileMap", 8, |d| {
|
d.read_struct("SourceFile", 8, |d| {
|
||||||
let name: FileName = d.read_struct_field("name", 0, |d| Decodable::decode(d))?;
|
let name: FileName = d.read_struct_field("name", 0, |d| Decodable::decode(d))?;
|
||||||
let name_was_remapped: bool =
|
let name_was_remapped: bool =
|
||||||
d.read_struct_field("name_was_remapped", 1, |d| Decodable::decode(d))?;
|
d.read_struct_field("name_was_remapped", 1, |d| Decodable::decode(d))?;
|
||||||
|
@ -925,7 +925,7 @@ impl Decodable for FileMap {
|
||||||
d.read_struct_field("non_narrow_chars", 8, |d| Decodable::decode(d))?;
|
d.read_struct_field("non_narrow_chars", 8, |d| Decodable::decode(d))?;
|
||||||
let name_hash: u128 =
|
let name_hash: u128 =
|
||||||
d.read_struct_field("name_hash", 9, |d| Decodable::decode(d))?;
|
d.read_struct_field("name_hash", 9, |d| Decodable::decode(d))?;
|
||||||
Ok(FileMap {
|
Ok(SourceFile {
|
||||||
name,
|
name,
|
||||||
name_was_remapped,
|
name_was_remapped,
|
||||||
unmapped_path: None,
|
unmapped_path: None,
|
||||||
|
@ -947,18 +947,18 @@ impl Decodable for FileMap {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl fmt::Debug for FileMap {
|
impl fmt::Debug for SourceFile {
|
||||||
fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
|
fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
|
||||||
write!(fmt, "FileMap({})", self.name)
|
write!(fmt, "SourceFile({})", self.name)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl FileMap {
|
impl SourceFile {
|
||||||
pub fn new(name: FileName,
|
pub fn new(name: FileName,
|
||||||
name_was_remapped: bool,
|
name_was_remapped: bool,
|
||||||
unmapped_path: FileName,
|
unmapped_path: FileName,
|
||||||
mut src: String,
|
mut src: String,
|
||||||
start_pos: BytePos) -> FileMap {
|
start_pos: BytePos) -> SourceFile {
|
||||||
remove_bom(&mut src);
|
remove_bom(&mut src);
|
||||||
|
|
||||||
let src_hash = {
|
let src_hash = {
|
||||||
|
@ -976,7 +976,7 @@ impl FileMap {
|
||||||
let (lines, multibyte_chars, non_narrow_chars) =
|
let (lines, multibyte_chars, non_narrow_chars) =
|
||||||
analyze_filemap::analyze_filemap(&src[..], start_pos);
|
analyze_filemap::analyze_filemap(&src[..], start_pos);
|
||||||
|
|
||||||
FileMap {
|
SourceFile {
|
||||||
name,
|
name,
|
||||||
name_was_remapped,
|
name_was_remapped,
|
||||||
unmapped_path: Some(unmapped_path),
|
unmapped_path: Some(unmapped_path),
|
||||||
|
@ -1081,7 +1081,7 @@ impl FileMap {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Find the line containing the given position. The return value is the
|
/// Find the line containing the given position. The return value is the
|
||||||
/// index into the `lines` array of this FileMap, not the 1-based line
|
/// index into the `lines` array of this SourceFile, not the 1-based line
|
||||||
/// number. If the filemap is empty or the position is located before the
|
/// number. If the filemap is empty or the position is located before the
|
||||||
/// first line, None is returned.
|
/// first line, None is returned.
|
||||||
pub fn lookup_line(&self, pos: BytePos) -> Option<usize> {
|
pub fn lookup_line(&self, pos: BytePos) -> Option<usize> {
|
||||||
|
@ -1226,14 +1226,14 @@ impl Sub for CharPos {
|
||||||
}
|
}
|
||||||
|
|
||||||
// _____________________________________________________________________________
|
// _____________________________________________________________________________
|
||||||
// Loc, LocWithOpt, FileMapAndLine, FileMapAndBytePos
|
// Loc, LocWithOpt, SourceFileAndLine, SourceFileAndBytePos
|
||||||
//
|
//
|
||||||
|
|
||||||
/// A source code location used for error reporting
|
/// A source code location used for error reporting
|
||||||
#[derive(Debug, Clone)]
|
#[derive(Debug, Clone)]
|
||||||
pub struct Loc {
|
pub struct Loc {
|
||||||
/// Information about the original source
|
/// Information about the original source
|
||||||
pub file: Lrc<FileMap>,
|
pub file: Lrc<SourceFile>,
|
||||||
/// The (1-based) line number
|
/// The (1-based) line number
|
||||||
pub line: usize,
|
pub line: usize,
|
||||||
/// The (0-based) column offset
|
/// The (0-based) column offset
|
||||||
|
@ -1250,14 +1250,14 @@ pub struct LocWithOpt {
|
||||||
pub filename: FileName,
|
pub filename: FileName,
|
||||||
pub line: usize,
|
pub line: usize,
|
||||||
pub col: CharPos,
|
pub col: CharPos,
|
||||||
pub file: Option<Lrc<FileMap>>,
|
pub file: Option<Lrc<SourceFile>>,
|
||||||
}
|
}
|
||||||
|
|
||||||
// used to be structural records. Better names, anyone?
|
// used to be structural records. Better names, anyone?
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
pub struct FileMapAndLine { pub fm: Lrc<FileMap>, pub line: usize }
|
pub struct SourceFileAndLine { pub fm: Lrc<SourceFile>, pub line: usize }
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
pub struct FileMapAndBytePos { pub fm: Lrc<FileMap>, pub pos: BytePos }
|
pub struct SourceFileAndBytePos { pub fm: Lrc<SourceFile>, pub pos: BytePos }
|
||||||
|
|
||||||
#[derive(Copy, Clone, Debug, PartialEq, Eq)]
|
#[derive(Copy, Clone, Debug, PartialEq, Eq)]
|
||||||
pub struct LineInfo {
|
pub struct LineInfo {
|
||||||
|
@ -1272,7 +1272,7 @@ pub struct LineInfo {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub struct FileLines {
|
pub struct FileLines {
|
||||||
pub file: Lrc<FileMap>,
|
pub file: Lrc<SourceFile>,
|
||||||
pub lines: Vec<LineInfo>
|
pub lines: Vec<LineInfo>
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -13,7 +13,7 @@
|
||||||
|
|
||||||
// revisions:cfail1 cfail2
|
// revisions:cfail1 cfail2
|
||||||
|
|
||||||
// Note that we specify -g so that the FileMaps actually get referenced by the
|
// Note that we specify -g so that the SourceFiles actually get referenced by the
|
||||||
// incr. comp. cache:
|
// incr. comp. cache:
|
||||||
// compile-flags: -Z query-dep-graph -g
|
// compile-flags: -Z query-dep-graph -g
|
||||||
// compile-pass
|
// compile-pass
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue