Skip to content

Commit d6dcbcd

Browse files
committed
mv FileMap SourceFile
1 parent c655473 commit d6dcbcd

File tree

22 files changed

+126
-126
lines changed

22 files changed

+126
-126
lines changed

src/libproc_macro/lib.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ use syntax::errors::DiagnosticBuilder;
6363
use syntax::parse::{self, token};
6464
use syntax::symbol::Symbol;
6565
use syntax::tokenstream;
66-
use syntax_pos::{FileMap, Pos, FileName};
66+
use syntax_pos::{Pos, FileName};
6767

6868
/// The main type provided by this crate, representing an abstract stream of
6969
/// tokens, or, more specifically, a sequence of token trees.
@@ -308,7 +308,7 @@ impl Span {
308308
#[unstable(feature = "proc_macro_span", issue = "38356")]
309309
pub fn source_file(&self) -> SourceFile {
310310
SourceFile {
311-
filemap: __internal::lookup_char_pos(self.0.lo()).file,
311+
source_file: __internal::lookup_char_pos(self.0.lo()).file,
312312
}
313313
}
314314

@@ -419,7 +419,7 @@ impl !Sync for LineColumn {}
419419
#[unstable(feature = "proc_macro_span", issue = "38356")]
420420
#[derive(Clone)]
421421
pub struct SourceFile {
422-
filemap: Lrc<FileMap>,
422+
source_file: Lrc<syntax_pos::SourceFile>,
423423
}
424424

425425
#[unstable(feature = "proc_macro_span", issue = "38356")]

src/librustc/ich/caching_codemap_view.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,15 +10,15 @@
1010

1111
use rustc_data_structures::sync::Lrc;
1212
use syntax::codemap::SourceMap;
13-
use syntax_pos::{BytePos, FileMap};
13+
use syntax_pos::{BytePos, SourceFile};
1414

1515
#[derive(Clone)]
1616
struct CacheEntry {
1717
time_stamp: usize,
1818
line_number: usize,
1919
line_start: BytePos,
2020
line_end: BytePos,
21-
file: Lrc<FileMap>,
21+
file: Lrc<SourceFile>,
2222
file_index: usize,
2323
}
2424

@@ -51,7 +51,7 @@ impl<'cm> CachingCodemapView<'cm> {
5151

5252
pub fn byte_pos_to_line_and_col(&mut self,
5353
pos: BytePos)
54-
-> Option<(Lrc<FileMap>, usize, BytePos)> {
54+
-> Option<(Lrc<SourceFile>, usize, BytePos)> {
5555
self.time_stamp += 1;
5656

5757
// Check if the position is in one of the cached lines

src/librustc/ich/hcx.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -309,7 +309,7 @@ impl<'a> HashStable<StableHashingContext<'a>> for Span {
309309
// Hash a span in a stable way. We can't directly hash the span's BytePos
310310
// fields (that would be similar to hashing pointers, since those are just
311311
// offsets into the SourceMap). Instead, we hash the (file name, line, column)
312-
// triple, which stays the same even if the containing FileMap has moved
312+
// triple, which stays the same even if the containing SourceFile has moved
313313
// within the SourceMap.
314314
// Also note that we are hashing byte offsets for the column, not unicode
315315
// codepoint offsets. For the purpose of the hash that's sufficient.

src/librustc/ich/impls_syntax.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ use syntax::feature_gate;
2121
use syntax::parse::token;
2222
use syntax::symbol::{InternedString, LocalInternedString};
2323
use syntax::tokenstream;
24-
use syntax_pos::FileMap;
24+
use syntax_pos::SourceFile;
2525

2626
use hir::def_id::{DefId, CrateNum, CRATE_DEF_INDEX};
2727

@@ -427,11 +427,11 @@ impl_stable_hash_for!(enum ::syntax_pos::FileName {
427427
Custom(s)
428428
});
429429

430-
impl<'a> HashStable<StableHashingContext<'a>> for FileMap {
430+
impl<'a> HashStable<StableHashingContext<'a>> for SourceFile {
431431
fn hash_stable<W: StableHasherResult>(&self,
432432
hcx: &mut StableHashingContext<'a>,
433433
hasher: &mut StableHasher<W>) {
434-
let FileMap {
434+
let SourceFile {
435435
name: _, // We hash the smaller name_hash instead of this
436436
name_hash,
437437
name_was_remapped,

src/librustc/ty/query/on_disk_cache.rs

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ use session::{CrateDisambiguator, Session};
2727
use std::mem;
2828
use syntax::ast::NodeId;
2929
use syntax::codemap::{SourceMap, StableFilemapId};
30-
use syntax_pos::{BytePos, Span, DUMMY_SP, FileMap};
30+
use syntax_pos::{BytePos, Span, DUMMY_SP, SourceFile};
3131
use syntax_pos::hygiene::{Mark, SyntaxContext, ExpnInfo};
3232
use ty;
3333
use ty::codec::{self as ty_codec, TyDecoder, TyEncoder};
@@ -63,10 +63,10 @@ pub struct OnDiskCache<'sess> {
6363
cnum_map: Once<IndexVec<CrateNum, Option<CrateNum>>>,
6464

6565
codemap: &'sess SourceMap,
66-
file_index_to_stable_id: FxHashMap<FileMapIndex, StableFilemapId>,
66+
file_index_to_stable_id: FxHashMap<SourceFileIndex, StableFilemapId>,
6767

6868
// These two fields caches that are populated lazily during decoding.
69-
file_index_to_file: Lock<FxHashMap<FileMapIndex, Lrc<FileMap>>>,
69+
file_index_to_file: Lock<FxHashMap<SourceFileIndex, Lrc<SourceFile>>>,
7070
synthetic_expansion_infos: Lock<FxHashMap<AbsoluteBytePos, SyntaxContext>>,
7171

7272
// A map from dep-node to the position of the cached query result in
@@ -83,7 +83,7 @@ pub struct OnDiskCache<'sess> {
8383
// This type is used only for (de-)serialization.
8484
#[derive(RustcEncodable, RustcDecodable)]
8585
struct Footer {
86-
file_index_to_stable_id: FxHashMap<FileMapIndex, StableFilemapId>,
86+
file_index_to_stable_id: FxHashMap<SourceFileIndex, StableFilemapId>,
8787
prev_cnums: Vec<(u32, String, CrateDisambiguator)>,
8888
query_result_index: EncodedQueryResultIndex,
8989
diagnostics_index: EncodedQueryResultIndex,
@@ -96,7 +96,7 @@ type EncodedDiagnosticsIndex = Vec<(SerializedDepNodeIndex, AbsoluteBytePos)>;
9696
type EncodedDiagnostics = Vec<Diagnostic>;
9797

9898
#[derive(Copy, Clone, PartialEq, Eq, Hash, Debug, RustcEncodable, RustcDecodable)]
99-
struct FileMapIndex(u32);
99+
struct SourceFileIndex(u32);
100100

101101
#[derive(Copy, Clone, Debug, Hash, Eq, PartialEq, RustcEncodable, RustcDecodable)]
102102
struct AbsoluteBytePos(u32);
@@ -173,14 +173,14 @@ impl<'sess> OnDiskCache<'sess> {
173173
{
174174
// Serializing the DepGraph should not modify it:
175175
tcx.dep_graph.with_ignore(|| {
176-
// Allocate FileMapIndices
176+
// Allocate SourceFileIndices
177177
let (file_to_file_index, file_index_to_stable_id) = {
178178
let mut file_to_file_index = FxHashMap();
179179
let mut file_index_to_stable_id = FxHashMap();
180180

181181
for (index, file) in tcx.sess.codemap().files().iter().enumerate() {
182-
let index = FileMapIndex(index as u32);
183-
let file_ptr: *const FileMap = &**file as *const _;
182+
let index = SourceFileIndex(index as u32);
183+
let file_ptr: *const SourceFile = &**file as *const _;
184184
file_to_file_index.insert(file_ptr, index);
185185
file_index_to_stable_id.insert(index, StableFilemapId::new(&file));
186186
}
@@ -478,13 +478,13 @@ struct CacheDecoder<'a, 'tcx: 'a, 'x> {
478478
codemap: &'x SourceMap,
479479
cnum_map: &'x IndexVec<CrateNum, Option<CrateNum>>,
480480
synthetic_expansion_infos: &'x Lock<FxHashMap<AbsoluteBytePos, SyntaxContext>>,
481-
file_index_to_file: &'x Lock<FxHashMap<FileMapIndex, Lrc<FileMap>>>,
482-
file_index_to_stable_id: &'x FxHashMap<FileMapIndex, StableFilemapId>,
481+
file_index_to_file: &'x Lock<FxHashMap<SourceFileIndex, Lrc<SourceFile>>>,
482+
file_index_to_stable_id: &'x FxHashMap<SourceFileIndex, StableFilemapId>,
483483
alloc_decoding_session: AllocDecodingSession<'x>,
484484
}
485485

486486
impl<'a, 'tcx, 'x> CacheDecoder<'a, 'tcx, 'x> {
487-
fn file_index_to_file(&self, index: FileMapIndex) -> Lrc<FileMap> {
487+
fn file_index_to_file(&self, index: SourceFileIndex) -> Lrc<SourceFile> {
488488
let CacheDecoder {
489489
ref file_index_to_file,
490490
ref file_index_to_stable_id,
@@ -495,7 +495,7 @@ impl<'a, 'tcx, 'x> CacheDecoder<'a, 'tcx, 'x> {
495495
file_index_to_file.borrow_mut().entry(index).or_insert_with(|| {
496496
let stable_id = file_index_to_stable_id[&index];
497497
codemap.filemap_by_stable_id(stable_id)
498-
.expect("Failed to lookup FileMap in new context.")
498+
.expect("Failed to lookup SourceFile in new context.")
499499
}).clone()
500500
}
501501
}
@@ -617,7 +617,7 @@ impl<'a, 'tcx, 'x> SpecializedDecoder<Span> for CacheDecoder<'a, 'tcx, 'x> {
617617
debug_assert_eq!(tag, TAG_VALID_SPAN);
618618
}
619619

620-
let file_lo_index = FileMapIndex::decode(self)?;
620+
let file_lo_index = SourceFileIndex::decode(self)?;
621621
let line_lo = usize::decode(self)?;
622622
let col_lo = BytePos::decode(self)?;
623623
let len = BytePos::decode(self)?;
@@ -771,14 +771,14 @@ struct CacheEncoder<'enc, 'a, 'tcx, E>
771771
interpret_allocs: FxHashMap<interpret::AllocId, usize>,
772772
interpret_allocs_inverse: Vec<interpret::AllocId>,
773773
codemap: CachingCodemapView<'tcx>,
774-
file_to_file_index: FxHashMap<*const FileMap, FileMapIndex>,
774+
file_to_file_index: FxHashMap<*const SourceFile, SourceFileIndex>,
775775
}
776776

777777
impl<'enc, 'a, 'tcx, E> CacheEncoder<'enc, 'a, 'tcx, E>
778778
where E: 'enc + ty_codec::TyEncoder
779779
{
780-
fn filemap_index(&mut self, filemap: Lrc<FileMap>) -> FileMapIndex {
781-
self.file_to_file_index[&(&*filemap as *const FileMap)]
780+
fn filemap_index(&mut self, filemap: Lrc<SourceFile>) -> SourceFileIndex {
781+
self.file_to_file_index[&(&*filemap as *const SourceFile)]
782782
}
783783

784784
/// Encode something with additional information that allows to do some

src/librustc_codegen_llvm/debuginfo/metadata.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1745,7 +1745,7 @@ pub fn create_global_var_metadata(
17451745
pub fn extend_scope_to_file(
17461746
cx: &CodegenCx<'ll, '_>,
17471747
scope_metadata: &'ll DIScope,
1748-
file: &syntax_pos::FileMap,
1748+
file: &syntax_pos::SourceFile,
17491749
defining_crate: CrateNum,
17501750
) -> &'ll DILexicalBlock {
17511751
let file_metadata = file_metadata(cx, &file.name, defining_crate);

src/librustc_errors/emitter.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010

1111
use self::Destination::*;
1212

13-
use syntax_pos::{FileMap, Span, MultiSpan};
13+
use syntax_pos::{SourceFile, Span, MultiSpan};
1414

1515
use {Level, CodeSuggestion, DiagnosticBuilder, SubDiagnostic, SourceMapperDyn, DiagnosticId};
1616
use snippet::{Annotation, AnnotationType, Line, MultilineAnnotation, StyledString, Style};
@@ -127,7 +127,7 @@ pub struct EmitterWriter {
127127
}
128128

129129
struct FileWithAnnotatedLines {
130-
file: Lrc<FileMap>,
130+
file: Lrc<SourceFile>,
131131
lines: Vec<Line>,
132132
multiline_depth: usize,
133133
}
@@ -177,7 +177,7 @@ impl EmitterWriter {
177177

178178
fn preprocess_annotations(&mut self, msp: &MultiSpan) -> Vec<FileWithAnnotatedLines> {
179179
fn add_annotation_to_file(file_vec: &mut Vec<FileWithAnnotatedLines>,
180-
file: Lrc<FileMap>,
180+
file: Lrc<SourceFile>,
181181
line_index: usize,
182182
ann: Annotation) {
183183

@@ -307,7 +307,7 @@ impl EmitterWriter {
307307

308308
fn render_source_line(&self,
309309
buffer: &mut StyledBuffer,
310-
file: Lrc<FileMap>,
310+
file: Lrc<SourceFile>,
311311
line: &Line,
312312
width_offset: usize,
313313
code_offset: usize) -> Vec<(usize, Style)> {

src/librustc_errors/lib.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ pub mod registry;
5555
mod styled_buffer;
5656
mod lock;
5757

58-
use syntax_pos::{BytePos, Loc, FileLinesResult, FileMap, FileName, MultiSpan, Span, NO_EXPANSION};
58+
use syntax_pos::{BytePos, Loc, FileLinesResult, SourceFile, FileName, MultiSpan, Span, NO_EXPANSION};
5959

6060
#[derive(Copy, Clone, Debug, PartialEq, Hash, RustcEncodable, RustcDecodable)]
6161
pub enum Applicability {
@@ -120,7 +120,7 @@ pub trait SourceMapper {
120120
fn span_to_filename(&self, sp: Span) -> FileName;
121121
fn merge_spans(&self, sp_lhs: Span, sp_rhs: Span) -> Option<Span>;
122122
fn call_span_if_macro(&self, sp: Span) -> Span;
123-
fn ensure_filemap_source_present(&self, file_map: Lrc<FileMap>) -> bool;
123+
fn ensure_filemap_source_present(&self, file_map: Lrc<SourceFile>) -> bool;
124124
fn doctest_offset_line(&self, line: usize) -> usize;
125125
}
126126

src/librustc_metadata/cstore.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -41,15 +41,15 @@ pub use rustc_data_structures::sync::MetadataRef;
4141

4242
pub struct MetadataBlob(pub MetadataRef);
4343

44-
/// Holds information about a syntax_pos::FileMap imported from another crate.
44+
/// Holds information about a syntax_pos::SourceFile imported from another crate.
4545
/// See `imported_filemaps()` for more information.
46-
pub struct ImportedFileMap {
47-
/// This FileMap's byte-offset within the codemap of its original crate
46+
pub struct ImportedSourceFile {
47+
/// This SourceFile's byte-offset within the codemap of its original crate
4848
pub original_start_pos: syntax_pos::BytePos,
49-
/// The end of this FileMap within the codemap of its original crate
49+
/// The end of this SourceFile within the codemap of its original crate
5050
pub original_end_pos: syntax_pos::BytePos,
51-
/// The imported FileMap's representation within the local codemap
52-
pub translated_filemap: Lrc<syntax_pos::FileMap>,
51+
/// The imported SourceFile's representation within the local codemap
52+
pub translated_filemap: Lrc<syntax_pos::SourceFile>,
5353
}
5454

5555
pub struct CrateMetadata {
@@ -64,7 +64,7 @@ pub struct CrateMetadata {
6464
pub cnum_map: CrateNumMap,
6565
pub cnum: CrateNum,
6666
pub dependencies: Lock<Vec<CrateNum>>,
67-
pub codemap_import_info: RwLock<Vec<ImportedFileMap>>,
67+
pub codemap_import_info: RwLock<Vec<ImportedSourceFile>>,
6868

6969
/// Used for decoding interpret::AllocIds in a cached & thread-safe manner.
7070
pub alloc_decoding_state: AllocDecodingState,

src/librustc_metadata/decoder.rs

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1099,26 +1099,26 @@ impl<'a, 'tcx> CrateMetadata {
10991099
///
11001100
/// The import algorithm works analogous to how AST items are inlined from an
11011101
/// external crate's metadata:
1102-
/// For every FileMap in the external codemap an 'inline' copy is created in the
1102+
/// For every SourceFile in the external codemap an 'inline' copy is created in the
11031103
/// local codemap. The correspondence relation between external and local
1104-
/// FileMaps is recorded in the `ImportedFileMap` objects returned from this
1104+
/// SourceFiles is recorded in the `ImportedSourceFile` objects returned from this
11051105
/// function. When an item from an external crate is later inlined into this
11061106
/// crate, this correspondence information is used to translate the span
11071107
/// information of the inlined item so that it refers the correct positions in
11081108
/// the local codemap (see `<decoder::DecodeContext as SpecializedDecoder<Span>>`).
11091109
///
1110-
/// The import algorithm in the function below will reuse FileMaps already
1111-
/// existing in the local codemap. For example, even if the FileMap of some
1110+
/// The import algorithm in the function below will reuse SourceFiles already
1111+
/// existing in the local codemap. For example, even if the SourceFile of some
11121112
/// source file of libstd gets imported many times, there will only ever be
1113-
/// one FileMap object for the corresponding file in the local codemap.
1113+
/// one SourceFile object for the corresponding file in the local codemap.
11141114
///
1115-
/// Note that imported FileMaps do not actually contain the source code of the
1115+
/// Note that imported SourceFiles do not actually contain the source code of the
11161116
/// file they represent, just information about length, line breaks, and
11171117
/// multibyte characters. This information is enough to generate valid debuginfo
11181118
/// for items inlined from other crates.
11191119
pub fn imported_filemaps(&'a self,
11201120
local_codemap: &codemap::SourceMap)
1121-
-> ReadGuard<'a, Vec<cstore::ImportedFileMap>> {
1121+
-> ReadGuard<'a, Vec<cstore::ImportedSourceFile>> {
11221122
{
11231123
let filemaps = self.codemap_import_info.borrow();
11241124
if !filemaps.is_empty() {
@@ -1137,9 +1137,9 @@ impl<'a, 'tcx> CrateMetadata {
11371137
let external_codemap = self.root.codemap.decode(self);
11381138

11391139
let imported_filemaps = external_codemap.map(|filemap_to_import| {
1140-
// We can't reuse an existing FileMap, so allocate a new one
1140+
// We can't reuse an existing SourceFile, so allocate a new one
11411141
// containing the information we need.
1142-
let syntax_pos::FileMap { name,
1142+
let syntax_pos::SourceFile { name,
11431143
name_was_remapped,
11441144
src_hash,
11451145
start_pos,
@@ -1156,7 +1156,7 @@ impl<'a, 'tcx> CrateMetadata {
11561156
// position into frame of reference local to file.
11571157
// `SourceMap::new_imported_filemap()` will then translate those
11581158
// coordinates to their new global frame of reference when the
1159-
// offset of the FileMap is known.
1159+
// offset of the SourceFile is known.
11601160
for pos in &mut lines {
11611161
*pos = *pos - start_pos;
11621162
}
@@ -1182,7 +1182,7 @@ impl<'a, 'tcx> CrateMetadata {
11821182
local_version.name, start_pos, end_pos,
11831183
local_version.start_pos, local_version.end_pos);
11841184

1185-
cstore::ImportedFileMap {
1185+
cstore::ImportedSourceFile {
11861186
original_start_pos: start_pos,
11871187
original_end_pos: end_pos,
11881188
translated_filemap: local_version,

src/librustc_metadata/encoder.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ use syntax::ast::{self, CRATE_NODE_ID};
4242
use syntax::attr;
4343
use syntax::codemap::Spanned;
4444
use syntax::symbol::keywords;
45-
use syntax_pos::{self, hygiene, FileName, FileMap, Span};
45+
use syntax_pos::{self, hygiene, FileName, SourceFile, Span};
4646

4747
use rustc::hir::{self, PatKind};
4848
use rustc::hir::itemlikevisit::ItemLikeVisitor;
@@ -62,7 +62,7 @@ pub struct EncodeContext<'a, 'tcx: 'a> {
6262
interpret_allocs_inverse: Vec<interpret::AllocId>,
6363

6464
// This is used to speed up Span encoding.
65-
filemap_cache: Lrc<FileMap>,
65+
filemap_cache: Lrc<SourceFile>,
6666
}
6767

6868
macro_rules! encoder_methods {
@@ -337,7 +337,7 @@ impl<'a, 'tcx> EncodeContext<'a, 'tcx> {
337337
self.lazy(definitions.def_path_table())
338338
}
339339

340-
fn encode_codemap(&mut self) -> LazySeq<syntax_pos::FileMap> {
340+
fn encode_codemap(&mut self) -> LazySeq<syntax_pos::SourceFile> {
341341
let codemap = self.tcx.sess.codemap();
342342
let all_filemaps = codemap.files();
343343

@@ -350,7 +350,7 @@ impl<'a, 'tcx> EncodeContext<'a, 'tcx> {
350350
!filemap.is_imported()
351351
})
352352
.map(|filemap| {
353-
// When exporting FileMaps, we expand all paths to absolute
353+
// When exporting SourceFiles, we expand all paths to absolute
354354
// paths because any relative paths are potentially relative to
355355
// a wrong directory.
356356
// However, if a path has been modified via
@@ -361,7 +361,7 @@ impl<'a, 'tcx> EncodeContext<'a, 'tcx> {
361361
FileName::Real(ref name) => {
362362
if filemap.name_was_remapped ||
363363
(name.is_relative() && working_dir_was_remapped) {
364-
// This path of this FileMap has been modified by
364+
// This path of this SourceFile has been modified by
365365
// path-remapping, so we use it verbatim (and avoid cloning
366366
// the whole map in the process).
367367
filemap.clone()

0 commit comments

Comments
 (0)