diff options
| author | Donato Sciarra <sciarp@gmail.com> | 2018-08-18 12:13:52 +0200 |
|---|---|---|
| committer | Donato Sciarra <sciarp@gmail.com> | 2018-08-19 23:00:59 +0200 |
| commit | d6dcbcd4e11a1b787a9db1fa43a49907e8bccecf (patch) | |
| tree | 37af96f2adba41bfc3ff98e45006918de702d44c /src | |
| parent | c65547337831babea8d9052b960649309263df36 (diff) | |
| download | rust-d6dcbcd4e11a1b787a9db1fa43a49907e8bccecf.tar.gz rust-d6dcbcd4e11a1b787a9db1fa43a49907e8bccecf.zip | |
mv FileMap SourceFile
Diffstat (limited to 'src')
| -rw-r--r-- | src/libproc_macro/lib.rs | 6 | ||||
| -rw-r--r-- | src/librustc/ich/caching_codemap_view.rs | 6 | ||||
| -rw-r--r-- | src/librustc/ich/hcx.rs | 2 | ||||
| -rw-r--r-- | src/librustc/ich/impls_syntax.rs | 6 | ||||
| -rw-r--r-- | src/librustc/ty/query/on_disk_cache.rs | 32 | ||||
| -rw-r--r-- | src/librustc_codegen_llvm/debuginfo/metadata.rs | 2 | ||||
| -rw-r--r-- | src/librustc_errors/emitter.rs | 8 | ||||
| -rw-r--r-- | src/librustc_errors/lib.rs | 4 | ||||
| -rw-r--r-- | src/librustc_metadata/cstore.rs | 14 | ||||
| -rw-r--r-- | src/librustc_metadata/decoder.rs | 22 | ||||
| -rw-r--r-- | src/librustc_metadata/encoder.rs | 10 | ||||
| -rw-r--r-- | src/librustc_metadata/schema.rs | 2 | ||||
| -rw-r--r-- | src/librustdoc/clean/mod.rs | 2 | ||||
| -rw-r--r-- | src/libsyntax/codemap.rs | 56 | ||||
| -rw-r--r-- | src/libsyntax/ext/quote.rs | 2 | ||||
| -rw-r--r-- | src/libsyntax/json.rs | 2 | ||||
| -rw-r--r-- | src/libsyntax/parse/lexer/mod.rs | 10 | ||||
| -rw-r--r-- | src/libsyntax/parse/mod.rs | 8 | ||||
| -rw-r--r-- | src/libsyntax/test.rs | 2 | ||||
| -rw-r--r-- | src/libsyntax_pos/analyze_filemap.rs | 2 | ||||
| -rw-r--r-- | src/libsyntax_pos/lib.rs | 52 | ||||
| -rw-r--r-- | src/test/incremental/remove_source_file/main.rs | 2 |
22 files changed, 126 insertions, 126 deletions
diff --git a/src/libproc_macro/lib.rs b/src/libproc_macro/lib.rs index b54054752ea..50a613f86c2 100644 --- a/src/libproc_macro/lib.rs +++ b/src/libproc_macro/lib.rs @@ -63,7 +63,7 @@ use syntax::errors::DiagnosticBuilder; use syntax::parse::{self, token}; use syntax::symbol::Symbol; 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 /// tokens, or, more specifically, a sequence of token trees. @@ -308,7 +308,7 @@ impl Span { #[unstable(feature = "proc_macro_span", issue = "38356")] pub fn source_file(&self) -> 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")] #[derive(Clone)] pub struct SourceFile { - filemap: Lrc<FileMap>, + source_file: Lrc<syntax_pos::SourceFile>, } #[unstable(feature = "proc_macro_span", issue = "38356")] diff --git a/src/librustc/ich/caching_codemap_view.rs b/src/librustc/ich/caching_codemap_view.rs index 769c4cfe9fa..d8999e1e00f 100644 --- a/src/librustc/ich/caching_codemap_view.rs +++ b/src/librustc/ich/caching_codemap_view.rs @@ -10,7 +10,7 @@ use rustc_data_structures::sync::Lrc; use syntax::codemap::SourceMap; -use syntax_pos::{BytePos, FileMap}; +use syntax_pos::{BytePos, SourceFile}; #[derive(Clone)] struct CacheEntry { @@ -18,7 +18,7 @@ struct CacheEntry { line_number: usize, line_start: BytePos, line_end: BytePos, - file: Lrc<FileMap>, + file: Lrc<SourceFile>, file_index: usize, } @@ -51,7 +51,7 @@ impl<'cm> CachingCodemapView<'cm> { pub fn byte_pos_to_line_and_col(&mut self, pos: BytePos) - -> Option<(Lrc<FileMap>, usize, BytePos)> { + -> Option<(Lrc<SourceFile>, usize, BytePos)> { self.time_stamp += 1; // Check if the position is in one of the cached lines diff --git a/src/librustc/ich/hcx.rs b/src/librustc/ich/hcx.rs index 91fbb1cc0fd..5260d94168f 100644 --- a/src/librustc/ich/hcx.rs +++ b/src/librustc/ich/hcx.rs @@ -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 // fields (that would be similar to hashing pointers, since those are just // 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. // Also note that we are hashing byte offsets for the column, not unicode // codepoint offsets. For the purpose of the hash that's sufficient. diff --git a/src/librustc/ich/impls_syntax.rs b/src/librustc/ich/impls_syntax.rs index d086d3bd28d..fd35713cc6f 100644 --- a/src/librustc/ich/impls_syntax.rs +++ b/src/librustc/ich/impls_syntax.rs @@ -21,7 +21,7 @@ use syntax::feature_gate; use syntax::parse::token; use syntax::symbol::{InternedString, LocalInternedString}; use syntax::tokenstream; -use syntax_pos::FileMap; +use syntax_pos::SourceFile; use hir::def_id::{DefId, CrateNum, CRATE_DEF_INDEX}; @@ -427,11 +427,11 @@ impl_stable_hash_for!(enum ::syntax_pos::FileName { Custom(s) }); -impl<'a> HashStable<StableHashingContext<'a>> for FileMap { +impl<'a> HashStable<StableHashingContext<'a>> for SourceFile { fn hash_stable<W: StableHasherResult>(&self, hcx: &mut StableHashingContext<'a>, hasher: &mut StableHasher<W>) { - let FileMap { + let SourceFile { name: _, // We hash the smaller name_hash instead of this name_hash, name_was_remapped, diff --git a/src/librustc/ty/query/on_disk_cache.rs b/src/librustc/ty/query/on_disk_cache.rs index 1f0f6bee777..2e5be214604 100644 --- a/src/librustc/ty/query/on_disk_cache.rs +++ b/src/librustc/ty/query/on_disk_cache.rs @@ -27,7 +27,7 @@ use session::{CrateDisambiguator, Session}; use std::mem; use syntax::ast::NodeId; 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 ty; use ty::codec::{self as ty_codec, TyDecoder, TyEncoder}; @@ -63,10 +63,10 @@ pub struct OnDiskCache<'sess> { cnum_map: Once<IndexVec<CrateNum, Option<CrateNum>>>, 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. - 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>>, // 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. #[derive(RustcEncodable, RustcDecodable)] struct Footer { - file_index_to_stable_id: FxHashMap<FileMapIndex, StableFilemapId>, + file_index_to_stable_id: FxHashMap<SourceFileIndex, StableFilemapId>, prev_cnums: Vec<(u32, String, CrateDisambiguator)>, query_result_index: EncodedQueryResultIndex, diagnostics_index: EncodedQueryResultIndex, @@ -96,7 +96,7 @@ type EncodedDiagnosticsIndex = Vec<(SerializedDepNodeIndex, AbsoluteBytePos)>; type EncodedDiagnostics = Vec<Diagnostic>; #[derive(Copy, Clone, PartialEq, Eq, Hash, Debug, RustcEncodable, RustcDecodable)] -struct FileMapIndex(u32); +struct SourceFileIndex(u32); #[derive(Copy, Clone, Debug, Hash, Eq, PartialEq, RustcEncodable, RustcDecodable)] struct AbsoluteBytePos(u32); @@ -173,14 +173,14 @@ impl<'sess> OnDiskCache<'sess> { { // Serializing the DepGraph should not modify it: tcx.dep_graph.with_ignore(|| { - // Allocate FileMapIndices + // Allocate SourceFileIndices let (file_to_file_index, file_index_to_stable_id) = { let mut file_to_file_index = FxHashMap(); let mut file_index_to_stable_id = FxHashMap(); for (index, file) in tcx.sess.codemap().files().iter().enumerate() { - let index = FileMapIndex(index as u32); - let file_ptr: *const FileMap = &**file as *const _; + let index = SourceFileIndex(index as u32); + let file_ptr: *const SourceFile = &**file as *const _; file_to_file_index.insert(file_ptr, index); file_index_to_stable_id.insert(index, StableFilemapId::new(&file)); } @@ -478,13 +478,13 @@ struct CacheDecoder<'a, 'tcx: 'a, 'x> { codemap: &'x SourceMap, cnum_map: &'x IndexVec<CrateNum, Option<CrateNum>>, synthetic_expansion_infos: &'x Lock<FxHashMap<AbsoluteBytePos, SyntaxContext>>, - file_index_to_file: &'x Lock<FxHashMap<FileMapIndex, Lrc<FileMap>>>, - file_index_to_stable_id: &'x FxHashMap<FileMapIndex, StableFilemapId>, + file_index_to_file: &'x Lock<FxHashMap<SourceFileIndex, Lrc<SourceFile>>>, + file_index_to_stable_id: &'x FxHashMap<SourceFileIndex, StableFilemapId>, alloc_decoding_session: AllocDecodingSession<'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 { ref file_index_to_file, 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(|| { let stable_id = file_index_to_stable_id[&index]; codemap.filemap_by_stable_id(stable_id) - .expect("Failed to lookup FileMap in new context.") + .expect("Failed to lookup SourceFile in new context.") }).clone() } } @@ -617,7 +617,7 @@ impl<'a, 'tcx, 'x> SpecializedDecoder<Span> for CacheDecoder<'a, 'tcx, 'x> { 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 col_lo = 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_inverse: Vec<interpret::AllocId>, 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> where E: 'enc + ty_codec::TyEncoder { - fn filemap_index(&mut self, filemap: Lrc<FileMap>) -> FileMapIndex { - self.file_to_file_index[&(&*filemap as *const FileMap)] + fn filemap_index(&mut self, filemap: Lrc<SourceFile>) -> SourceFileIndex { + self.file_to_file_index[&(&*filemap as *const SourceFile)] } /// Encode something with additional information that allows to do some diff --git a/src/librustc_codegen_llvm/debuginfo/metadata.rs b/src/librustc_codegen_llvm/debuginfo/metadata.rs index 223fa75723c..cac2ae0302e 100644 --- a/src/librustc_codegen_llvm/debuginfo/metadata.rs +++ b/src/librustc_codegen_llvm/debuginfo/metadata.rs @@ -1745,7 +1745,7 @@ pub fn create_global_var_metadata( pub fn extend_scope_to_file( cx: &CodegenCx<'ll, '_>, scope_metadata: &'ll DIScope, - file: &syntax_pos::FileMap, + file: &syntax_pos::SourceFile, defining_crate: CrateNum, ) -> &'ll DILexicalBlock { let file_metadata = file_metadata(cx, &file.name, defining_crate); diff --git a/src/librustc_errors/emitter.rs b/src/librustc_errors/emitter.rs index 0a3e4d3ad25..ce3a19677f2 100644 --- a/src/librustc_errors/emitter.rs +++ b/src/librustc_errors/emitter.rs @@ -10,7 +10,7 @@ use self::Destination::*; -use syntax_pos::{FileMap, Span, MultiSpan}; +use syntax_pos::{SourceFile, Span, MultiSpan}; use {Level, CodeSuggestion, DiagnosticBuilder, SubDiagnostic, SourceMapperDyn, DiagnosticId}; use snippet::{Annotation, AnnotationType, Line, MultilineAnnotation, StyledString, Style}; @@ -127,7 +127,7 @@ pub struct EmitterWriter { } struct FileWithAnnotatedLines { - file: Lrc<FileMap>, + file: Lrc<SourceFile>, lines: Vec<Line>, multiline_depth: usize, } @@ -177,7 +177,7 @@ impl EmitterWriter { fn preprocess_annotations(&mut self, msp: &MultiSpan) -> Vec<FileWithAnnotatedLines> { fn add_annotation_to_file(file_vec: &mut Vec<FileWithAnnotatedLines>, - file: Lrc<FileMap>, + file: Lrc<SourceFile>, line_index: usize, ann: Annotation) { @@ -307,7 +307,7 @@ impl EmitterWriter { fn render_source_line(&self, buffer: &mut StyledBuffer, - file: Lrc<FileMap>, + file: Lrc<SourceFile>, line: &Line, width_offset: usize, code_offset: usize) -> Vec<(usize, Style)> { diff --git a/src/librustc_errors/lib.rs b/src/librustc_errors/lib.rs index 40d7a122d30..597b3216490 100644 --- a/src/librustc_errors/lib.rs +++ b/src/librustc_errors/lib.rs @@ -55,7 +55,7 @@ pub mod registry; mod styled_buffer; 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)] pub enum Applicability { @@ -120,7 +120,7 @@ pub trait SourceMapper { fn span_to_filename(&self, sp: Span) -> FileName; fn merge_spans(&self, sp_lhs: Span, sp_rhs: Span) -> Option<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; } diff --git a/src/librustc_metadata/cstore.rs b/src/librustc_metadata/cstore.rs index 2d3e3080c89..2c95bd82432 100644 --- a/src/librustc_metadata/cstore.rs +++ b/src/librustc_metadata/cstore.rs @@ -41,15 +41,15 @@ pub use rustc_data_structures::sync::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. -pub struct ImportedFileMap { - /// This FileMap's byte-offset within the codemap of its original crate +pub struct ImportedSourceFile { + /// This SourceFile's byte-offset within the codemap of its original crate 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, - /// The imported FileMap's representation within the local codemap - pub translated_filemap: Lrc<syntax_pos::FileMap>, + /// The imported SourceFile's representation within the local codemap + pub translated_filemap: Lrc<syntax_pos::SourceFile>, } pub struct CrateMetadata { @@ -64,7 +64,7 @@ pub struct CrateMetadata { pub cnum_map: CrateNumMap, pub cnum: 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. pub alloc_decoding_state: AllocDecodingState, diff --git a/src/librustc_metadata/decoder.rs b/src/librustc_metadata/decoder.rs index 4a17c5845fd..00ed71c8891 100644 --- a/src/librustc_metadata/decoder.rs +++ b/src/librustc_metadata/decoder.rs @@ -1099,26 +1099,26 @@ impl<'a, 'tcx> CrateMetadata { /// /// The import algorithm works analogous to how AST items are inlined from an /// 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 - /// 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 /// crate, this correspondence information is used to translate the span /// information of the inlined item so that it refers the correct positions in /// the local codemap (see `<decoder::DecodeContext as SpecializedDecoder<Span>>`). /// - /// The import algorithm in the function below will reuse FileMaps already - /// existing in the local codemap. For example, even if the FileMap of some + /// The import algorithm in the function below will reuse SourceFiles already + /// 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 - /// 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 /// multibyte characters. This information is enough to generate valid debuginfo /// for items inlined from other crates. pub fn imported_filemaps(&'a self, local_codemap: &codemap::SourceMap) - -> ReadGuard<'a, Vec<cstore::ImportedFileMap>> { + -> ReadGuard<'a, Vec<cstore::ImportedSourceFile>> { { let filemaps = self.codemap_import_info.borrow(); if !filemaps.is_empty() { @@ -1137,9 +1137,9 @@ impl<'a, 'tcx> CrateMetadata { let external_codemap = self.root.codemap.decode(self); 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. - let syntax_pos::FileMap { name, + let syntax_pos::SourceFile { name, name_was_remapped, src_hash, start_pos, @@ -1156,7 +1156,7 @@ impl<'a, 'tcx> CrateMetadata { // position into frame of reference local to file. // `SourceMap::new_imported_filemap()` will then translate those // 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 { *pos = *pos - start_pos; } @@ -1182,7 +1182,7 @@ impl<'a, 'tcx> CrateMetadata { local_version.name, start_pos, end_pos, local_version.start_pos, local_version.end_pos); - cstore::ImportedFileMap { + cstore::ImportedSourceFile { original_start_pos: start_pos, original_end_pos: end_pos, translated_filemap: local_version, diff --git a/src/librustc_metadata/encoder.rs b/src/librustc_metadata/encoder.rs index 02a41e68f68..925d765ca31 100644 --- a/src/librustc_metadata/encoder.rs +++ b/src/librustc_metadata/encoder.rs @@ -42,7 +42,7 @@ use syntax::ast::{self, CRATE_NODE_ID}; use syntax::attr; use syntax::codemap::Spanned; 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::itemlikevisit::ItemLikeVisitor; @@ -62,7 +62,7 @@ pub struct EncodeContext<'a, 'tcx: 'a> { interpret_allocs_inverse: Vec<interpret::AllocId>, // This is used to speed up Span encoding. - filemap_cache: Lrc<FileMap>, + filemap_cache: Lrc<SourceFile>, } macro_rules! encoder_methods { @@ -337,7 +337,7 @@ impl<'a, 'tcx> EncodeContext<'a, 'tcx> { 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 all_filemaps = codemap.files(); @@ -350,7 +350,7 @@ impl<'a, 'tcx> EncodeContext<'a, 'tcx> { !filemap.is_imported() }) .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 // a wrong directory. // However, if a path has been modified via @@ -361,7 +361,7 @@ impl<'a, 'tcx> EncodeContext<'a, 'tcx> { FileName::Real(ref name) => { if filemap.name_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 // the whole map in the process). filemap.clone() diff --git a/src/librustc_metadata/schema.rs b/src/librustc_metadata/schema.rs index 781652e1985..520273487a9 100644 --- a/src/librustc_metadata/schema.rs +++ b/src/librustc_metadata/schema.rs @@ -204,7 +204,7 @@ pub struct CrateRoot { pub lang_items_missing: LazySeq<lang_items::LangItem>, pub native_libraries: LazySeq<NativeLibrary>, 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 impls: LazySeq<TraitImpls>, pub exported_symbols: EncodedExportedSymbols, diff --git a/src/librustdoc/clean/mod.rs b/src/librustdoc/clean/mod.rs index ad774f98602..9e852a077bc 100644 --- a/src/librustdoc/clean/mod.rs +++ b/src/librustdoc/clean/mod.rs @@ -603,7 +603,7 @@ impl Clean<Item> for doctree::Module { // mod foo { ... } self.where_outer } else { - // mod foo; (and a separate FileMap for the contents) + // mod foo; (and a separate SourceFile for the contents) self.where_inner } }; diff --git a/src/libsyntax/codemap.rs b/src/libsyntax/codemap.rs index 8175e2495c5..c9a9fbf4d7b 100644 --- a/src/libsyntax/codemap.rs +++ b/src/libsyntax/codemap.rs @@ -12,7 +12,7 @@ //! from integer byte positions to the original source code location. Each bit //! 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 -//! 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 //! within the SourceMap, which upon request can be converted to line and column //! 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. @@ -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 // incremental compilation). #[derive(Copy, Clone, PartialEq, Eq, Hash, RustcEncodable, RustcDecodable, Debug)] pub struct StableFilemapId(u128); impl StableFilemapId { - pub fn new(filemap: &FileMap) -> StableFilemapId { + pub fn new(filemap: &SourceFile) -> StableFilemapId { let mut hasher = StableHasher::new(); filemap.name.hash(&mut hasher); @@ -125,15 +125,15 @@ impl StableFilemapId { // pub(super) struct SourceMapFiles { - pub(super) file_maps: Vec<Lrc<FileMap>>, - stable_id_to_filemap: FxHashMap<StableFilemapId, Lrc<FileMap>> + pub(super) file_maps: Vec<Lrc<SourceFile>>, + stable_id_to_filemap: FxHashMap<StableFilemapId, Lrc<SourceFile>> } pub struct SourceMap { pub(super) files: Lock<SourceMapFiles>, file_loader: Box<dyn FileLoader + Sync + Send>, // 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, /// In case we are in a doctest, replace all file names with the PathBuf, /// and add the given offsets to the line info @@ -184,7 +184,7 @@ impl SourceMap { 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 filename = if let Some((ref name, _)) = self.doctest_offset { name.clone() @@ -194,11 +194,11 @@ impl SourceMap { 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) } - 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()) } @@ -212,8 +212,8 @@ impl SourceMap { } /// Creates a new filemap. - /// This does not ensure that only one FileMap exists per file name. - pub fn new_filemap(&self, filename: FileName, src: String) -> Lrc<FileMap> { + /// This does not ensure that only one SourceFile exists per file name. + pub fn new_filemap(&self, filename: FileName, src: String) -> Lrc<SourceFile> { let start_pos = self.next_start_pos(); // The path is used to determine the directory for loading submodules and @@ -230,7 +230,7 @@ impl SourceMap { }, other => (other, false), }; - let filemap = Lrc::new(FileMap::new( + let filemap = Lrc::new(SourceFile::new( filename, was_remapped, unmapped_path, @@ -246,7 +246,7 @@ impl SourceMap { 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, /// but we still know enough to generate accurate debuginfo location /// information for things inlined from other crates. @@ -260,7 +260,7 @@ impl SourceMap { mut file_local_lines: Vec<BytePos>, mut file_local_multibyte_chars: Vec<MultiByteChar>, mut file_local_non_narrow_chars: Vec<NonNarrowChar>) - -> Lrc<FileMap> { + -> Lrc<SourceFile> { let start_pos = self.next_start_pos(); let end_pos = Pos::from_usize(start_pos + source_len); @@ -278,7 +278,7 @@ impl SourceMap { *swc = *swc + start_pos; } - let filemap = Lrc::new(FileMap { + let filemap = Lrc::new(SourceFile { name: filename, name_was_remapped, unmapped_path: None, @@ -326,7 +326,7 @@ impl SourceMap { pub fn lookup_char_pos(&self, pos: BytePos) -> Loc { let chpos = self.bytepos_to_file_charpos(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 linebpos = f.lines[a]; 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. - 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 f = (*self.files.borrow().file_maps)[idx].clone(); match f.lookup_line(pos) { - Some(line) => Ok(FileMapAndLine { fm: f, line: line }), + Some(line) => Ok(SourceFileAndLine { fm: f, line: line }), None => Err(f) } } @@ -463,7 +463,7 @@ impl SourceMap { pub fn span_to_unmapped_path(&self, sp: Span) -> FileName { 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 { @@ -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() { if *filename == fm.name { return Some(fm.clone()); @@ -807,12 +807,12 @@ impl SourceMap { None } - /// For a global BytePos compute the local offset within the containing FileMap - pub fn lookup_byte_offset(&self, bpos: BytePos) -> FileMapAndBytePos { + /// For a global BytePos compute the local offset within the containing SourceFile + pub fn lookup_byte_offset(&self, bpos: BytePos) -> SourceFileAndBytePos { let idx = self.lookup_filemap_idx(bpos); let fm = (*self.files.borrow().file_maps)[idx].clone(); 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. @@ -820,7 +820,7 @@ impl SourceMap { let idx = self.lookup_filemap_idx(bpos); 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; for mbc in map.multibyte_chars.iter() { @@ -966,7 +966,7 @@ impl SourceMapper for SourceMap { } 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( || match file_map.name { FileName::Real(ref name) => self.file_loader.read_file(name).ok(), @@ -1192,7 +1192,7 @@ mod tests { /// `substring` in `source_text`. trait SourceMapExtension { fn span_substr(&self, - file: &Lrc<FileMap>, + file: &Lrc<SourceFile>, source_text: &str, substring: &str, n: usize) @@ -1201,7 +1201,7 @@ mod tests { impl SourceMapExtension for SourceMap { fn span_substr(&self, - file: &Lrc<FileMap>, + file: &Lrc<SourceFile>, source_text: &str, substring: &str, n: usize) diff --git a/src/libsyntax/ext/quote.rs b/src/libsyntax/ext/quote.rs index bc891700fc1..a4b19681164 100644 --- a/src/libsyntax/ext/quote.rs +++ b/src/libsyntax/ext/quote.rs @@ -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 // just makes quotes "hard to attribute". Possibly this could be fixed // 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 // worth the hassle. diff --git a/src/libsyntax/json.rs b/src/libsyntax/json.rs index 22de184938f..a090083f608 100644 --- a/src/libsyntax/json.rs +++ b/src/libsyntax/json.rs @@ -340,7 +340,7 @@ impl DiagnosticSpan { } impl DiagnosticSpanLine { - fn line_from_filemap(fm: &syntax_pos::FileMap, + fn line_from_filemap(fm: &syntax_pos::SourceFile, index: usize, h_start: usize, h_end: usize) diff --git a/src/libsyntax/parse/lexer/mod.rs b/src/libsyntax/parse/lexer/mod.rs index c1919434e37..654ac692338 100644 --- a/src/libsyntax/parse/lexer/mod.rs +++ b/src/libsyntax/parse/lexer/mod.rs @@ -49,7 +49,7 @@ pub struct StringReader<'a> { pub pos: BytePos, /// The current character (which has been read from self.pos) pub ch: Option<char>, - pub filemap: Lrc<syntax_pos::FileMap>, + pub filemap: Lrc<syntax_pos::SourceFile>, /// Stop reading src at this index. pub end_src_index: usize, // cached: @@ -180,7 +180,7 @@ impl<'a> StringReader<'a> { } /// 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 { let mut sr = StringReader::new_raw_internal(sess, filemap, override_span); @@ -189,7 +189,7 @@ impl<'a> StringReader<'a> { 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 { 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 { 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 - /// 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) { let next_src_index = self.src_index(self.next_pos); if next_src_index < self.end_src_index { diff --git a/src/libsyntax/parse/mod.rs b/src/libsyntax/parse/mod.rs index d43cbf38064..65bab94c6bc 100644 --- a/src/libsyntax/parse/mod.rs +++ b/src/libsyntax/parse/mod.rs @@ -14,7 +14,7 @@ use rustc_data_structures::sync::{Lrc, Lock}; use ast::{self, CrateConfig, NodeId}; use early_buffered_lints::{BufferedEarlyLint, BufferedEarlyLintId}; use codemap::{SourceMap, FilePathMapping}; -use syntax_pos::{Span, FileMap, FileName, MultiSpan}; +use syntax_pos::{Span, SourceFile, FileName, MultiSpan}; use errors::{Handler, ColorConfig, DiagnosticBuilder}; use feature_gate::UnstableFeatures; 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 -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 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), /// add the path to the session's codemap and return the new filemap. fn file_to_filemap(sess: &ParseSess, path: &Path, spanopt: Option<Span>) - -> Lrc<FileMap> { + -> Lrc<SourceFile> { match sess.codemap().load_file(path) { Ok(filemap) => filemap, 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 -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 { let mut srdr = lexer::StringReader::new(sess, filemap, override_span); srdr.real_token(); diff --git a/src/libsyntax/test.rs b/src/libsyntax/test.rs index 633de812a87..b85fbae587a 100644 --- a/src/libsyntax/test.rs +++ b/src/libsyntax/test.rs @@ -20,7 +20,7 @@ use std::slice; use std::mem; use std::vec; 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 errors; diff --git a/src/libsyntax_pos/analyze_filemap.rs b/src/libsyntax_pos/analyze_filemap.rs index c7c0263e459..6ae1ada51fd 100644 --- a/src/libsyntax_pos/analyze_filemap.rs +++ b/src/libsyntax_pos/analyze_filemap.rs @@ -12,7 +12,7 @@ use unicode_width::UnicodeWidthChar; use super::*; /// 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 /// is detected at runtime. diff --git a/src/libsyntax_pos/lib.rs b/src/libsyntax_pos/lib.rs index fec7551a208..5ab44b025e2 100644 --- a/src/libsyntax_pos/lib.rs +++ b/src/libsyntax_pos/lib.rs @@ -163,7 +163,7 @@ impl FileName { /// Spans represent a region of code, used for error reporting. Positions in spans /// 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. /// 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 @@ -675,7 +675,7 @@ impl From<Vec<Span>> for MultiSpan { 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)] pub struct MultiByteChar { /// The absolute offset of the character in the SourceMap @@ -684,7 +684,7 @@ pub struct MultiByteChar { 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)] pub enum NonNarrowChar { /// 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)] pub enum ExternalSource { /// The external source has been loaded already. @@ -757,7 +757,7 @@ pub enum ExternalSource { AbsentOk, /// A failed attempt has been made to load the external source. 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, } @@ -779,7 +779,7 @@ impl ExternalSource { /// A single source in the SourceMap. #[derive(Clone)] -pub struct FileMap { +pub struct SourceFile { /// The name of the file that the source came from, source that doesn't /// originate from files has names between angle brackets by convention, /// e.g. `<anon>` @@ -787,9 +787,9 @@ pub struct FileMap { /// True if the `name` field above has been modified by --remap-path-prefix pub name_was_remapped: bool, /// 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>, - /// Indicates which crate this FileMap was imported from. + /// Indicates which crate this SourceFile was imported from. pub crate_of_origin: u32, /// The complete source code pub src: Option<Lrc<String>>, @@ -812,9 +812,9 @@ pub struct FileMap { pub name_hash: u128, } -impl Encodable for FileMap { +impl Encodable for SourceFile { 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_was_remapped", 1, |s| self.name_was_remapped.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 { - fn decode<D: Decoder>(d: &mut D) -> Result<FileMap, D::Error> { +impl Decodable for SourceFile { + 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_was_remapped: bool = 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))?; let name_hash: u128 = d.read_struct_field("name_hash", 9, |d| Decodable::decode(d))?; - Ok(FileMap { + Ok(SourceFile { name, name_was_remapped, 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 { - write!(fmt, "FileMap({})", self.name) + write!(fmt, "SourceFile({})", self.name) } } -impl FileMap { +impl SourceFile { pub fn new(name: FileName, name_was_remapped: bool, unmapped_path: FileName, mut src: String, - start_pos: BytePos) -> FileMap { + start_pos: BytePos) -> SourceFile { remove_bom(&mut src); let src_hash = { @@ -976,7 +976,7 @@ impl FileMap { let (lines, multibyte_chars, non_narrow_chars) = analyze_filemap::analyze_filemap(&src[..], start_pos); - FileMap { + SourceFile { name, name_was_remapped, unmapped_path: Some(unmapped_path), @@ -1081,7 +1081,7 @@ impl FileMap { } /// 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 /// first line, None is returned. 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 #[derive(Debug, Clone)] pub struct Loc { /// Information about the original source - pub file: Lrc<FileMap>, + pub file: Lrc<SourceFile>, /// The (1-based) line number pub line: usize, /// The (0-based) column offset @@ -1250,14 +1250,14 @@ pub struct LocWithOpt { pub filename: FileName, pub line: usize, pub col: CharPos, - pub file: Option<Lrc<FileMap>>, + pub file: Option<Lrc<SourceFile>>, } // used to be structural records. Better names, anyone? #[derive(Debug)] -pub struct FileMapAndLine { pub fm: Lrc<FileMap>, pub line: usize } +pub struct SourceFileAndLine { pub fm: Lrc<SourceFile>, pub line: usize } #[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)] pub struct LineInfo { @@ -1272,7 +1272,7 @@ pub struct LineInfo { } pub struct FileLines { - pub file: Lrc<FileMap>, + pub file: Lrc<SourceFile>, pub lines: Vec<LineInfo> } diff --git a/src/test/incremental/remove_source_file/main.rs b/src/test/incremental/remove_source_file/main.rs index a8c3f70f47b..75fe6d9511c 100644 --- a/src/test/incremental/remove_source_file/main.rs +++ b/src/test/incremental/remove_source_file/main.rs @@ -13,7 +13,7 @@ // 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: // compile-flags: -Z query-dep-graph -g // compile-pass |
