Skip to content

Commit cbd0595

Browse files
committed
mv filemap source_file
1 parent d6dcbcd commit cbd0595

File tree

25 files changed

+209
-209
lines changed

25 files changed

+209
-209
lines changed

src/libproc_macro/lib.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -440,9 +440,9 @@ impl SourceFile {
440440
/// [`is_real`]: #method.is_real
441441
#[unstable(feature = "proc_macro_span", issue = "38356")]
442442
pub fn path(&self) -> PathBuf {
443-
match self.filemap.name {
443+
match self.source_file.name {
444444
FileName::Real(ref path) => path.clone(),
445-
_ => PathBuf::from(self.filemap.name.to_string())
445+
_ => PathBuf::from(self.source_file.name.to_string())
446446
}
447447
}
448448

@@ -453,7 +453,7 @@ impl SourceFile {
453453
// This is a hack until intercrate spans are implemented and we can have real source files
454454
// for spans generated in external macros.
455455
// https://github.com/rust-lang/rust/pull/43604#issuecomment-333334368
456-
self.filemap.is_real_file()
456+
self.source_file.is_real_file()
457457
}
458458
}
459459

@@ -471,7 +471,7 @@ impl fmt::Debug for SourceFile {
471471
#[unstable(feature = "proc_macro_span", issue = "38356")]
472472
impl PartialEq for SourceFile {
473473
fn eq(&self, other: &Self) -> bool {
474-
Lrc::ptr_eq(&self.filemap, &other.filemap)
474+
Lrc::ptr_eq(&self.source_file, &other.source_file)
475475
}
476476
}
477477

src/librustc/hir/map/collector.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -158,8 +158,8 @@ impl<'a, 'hir> NodeCollector<'a, 'hir> {
158158
let mut source_file_names: Vec<_> = codemap
159159
.files()
160160
.iter()
161-
.filter(|filemap| CrateNum::from_u32(filemap.crate_of_origin) == LOCAL_CRATE)
162-
.map(|filemap| filemap.name_hash)
161+
.filter(|source_file| CrateNum::from_u32(source_file.crate_of_origin) == LOCAL_CRATE)
162+
.map(|source_file| source_file.name_hash)
163163
.collect();
164164

165165
source_file_names.sort_unstable();

src/librustc/ich/caching_codemap_view.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ impl<'cm> CachingCodemapView<'cm> {
7979
if pos < cache_entry.file.start_pos || pos >= cache_entry.file.end_pos {
8080
let file_valid;
8181
if self.codemap.files().len() > 0 {
82-
let file_index = self.codemap.lookup_filemap_idx(pos);
82+
let file_index = self.codemap.lookup_source_file_idx(pos);
8383
let file = self.codemap.files()[file_index].clone();
8484

8585
if pos >= file.start_pos && pos < file.end_pos {

src/librustc/ich/impls_syntax.rs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -458,13 +458,13 @@ impl<'a> HashStable<StableHashingContext<'a>> for SourceFile {
458458

459459
src_hash.hash_stable(hcx, hasher);
460460

461-
// We only hash the relative position within this filemap
461+
// We only hash the relative position within this source_file
462462
lines.len().hash_stable(hcx, hasher);
463463
for &line in lines.iter() {
464464
stable_byte_pos(line, start_pos).hash_stable(hcx, hasher);
465465
}
466466

467-
// We only hash the relative position within this filemap
467+
// We only hash the relative position within this source_file
468468
multibyte_chars.len().hash_stable(hcx, hasher);
469469
for &char_pos in multibyte_chars.iter() {
470470
stable_multibyte_char(char_pos, start_pos).hash_stable(hcx, hasher);
@@ -478,29 +478,29 @@ impl<'a> HashStable<StableHashingContext<'a>> for SourceFile {
478478
}
479479

480480
fn stable_byte_pos(pos: ::syntax_pos::BytePos,
481-
filemap_start: ::syntax_pos::BytePos)
481+
source_file_start: ::syntax_pos::BytePos)
482482
-> u32 {
483-
pos.0 - filemap_start.0
483+
pos.0 - source_file_start.0
484484
}
485485

486486
fn stable_multibyte_char(mbc: ::syntax_pos::MultiByteChar,
487-
filemap_start: ::syntax_pos::BytePos)
487+
source_file_start: ::syntax_pos::BytePos)
488488
-> (u32, u32) {
489489
let ::syntax_pos::MultiByteChar {
490490
pos,
491491
bytes,
492492
} = mbc;
493493

494-
(pos.0 - filemap_start.0, bytes as u32)
494+
(pos.0 - source_file_start.0, bytes as u32)
495495
}
496496

497497
fn stable_non_narrow_char(swc: ::syntax_pos::NonNarrowChar,
498-
filemap_start: ::syntax_pos::BytePos)
498+
source_file_start: ::syntax_pos::BytePos)
499499
-> (u32, u32) {
500500
let pos = swc.pos();
501501
let width = swc.width();
502502

503-
(pos.0 - filemap_start.0, width as u32)
503+
(pos.0 - source_file_start.0, width as u32)
504504
}
505505

506506

src/librustc/ty/query/on_disk_cache.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -494,7 +494,7 @@ impl<'a, 'tcx, 'x> CacheDecoder<'a, 'tcx, 'x> {
494494

495495
file_index_to_file.borrow_mut().entry(index).or_insert_with(|| {
496496
let stable_id = file_index_to_stable_id[&index];
497-
codemap.filemap_by_stable_id(stable_id)
497+
codemap.source_file_by_stable_id(stable_id)
498498
.expect("Failed to lookup SourceFile in new context.")
499499
}).clone()
500500
}
@@ -777,8 +777,8 @@ struct CacheEncoder<'enc, 'a, 'tcx, E>
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<SourceFile>) -> SourceFileIndex {
781-
self.file_to_file_index[&(&*filemap as *const SourceFile)]
780+
fn source_file_index(&mut self, source_file: Lrc<SourceFile>) -> SourceFileIndex {
781+
self.file_to_file_index[&(&*source_file as *const SourceFile)]
782782
}
783783

784784
/// Encode something with additional information that allows to do some
@@ -850,10 +850,10 @@ impl<'enc, 'a, 'tcx, E> SpecializedEncoder<Span> for CacheEncoder<'enc, 'a, 'tcx
850850

851851
let len = span_data.hi - span_data.lo;
852852

853-
let filemap_index = self.filemap_index(file_lo);
853+
let source_file_index = self.source_file_index(file_lo);
854854

855855
TAG_VALID_SPAN.encode(self)?;
856-
filemap_index.encode(self)?;
856+
source_file_index.encode(self)?;
857857
line_lo.encode(self)?;
858858
col_lo.encode(self)?;
859859
len.encode(self)?;

src/librustc_driver/pretty.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -916,7 +916,7 @@ pub fn fold_crate(sess: &Session, krate: ast::Crate, ppm: PpMode) -> ast::Crate
916916
fn get_source(input: &Input, sess: &Session) -> (Vec<u8>, FileName) {
917917
let src_name = driver::source_name(input);
918918
let src = sess.codemap()
919-
.get_filemap(&src_name)
919+
.get_source_file(&src_name)
920920
.unwrap()
921921
.src
922922
.as_ref()

src/librustc_errors/emitter.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1021,7 +1021,7 @@ impl EmitterWriter {
10211021
// Print out the annotate source lines that correspond with the error
10221022
for annotated_file in annotated_files {
10231023
// we can't annotate anything if the source is unavailable.
1024-
if !cm.ensure_filemap_source_present(annotated_file.file.clone()) {
1024+
if !cm.ensure_source_file_source_present(annotated_file.file.clone()) {
10251025
continue;
10261026
}
10271027

src/librustc_errors/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -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<SourceFile>) -> bool;
123+
fn ensure_source_file_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: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,14 +42,14 @@ pub use rustc_data_structures::sync::MetadataRef;
4242
pub struct MetadataBlob(pub MetadataRef);
4343

4444
/// Holds information about a syntax_pos::SourceFile imported from another crate.
45-
/// See `imported_filemaps()` for more information.
45+
/// See `imported_source_files()` for more information.
4646
pub struct ImportedSourceFile {
4747
/// This SourceFile's byte-offset within the codemap of its original crate
4848
pub original_start_pos: syntax_pos::BytePos,
4949
/// The end of this SourceFile within the codemap of its original crate
5050
pub original_end_pos: syntax_pos::BytePos,
5151
/// The imported SourceFile's representation within the local codemap
52-
pub translated_filemap: Lrc<syntax_pos::SourceFile>,
52+
pub translated_source_file: Lrc<syntax_pos::SourceFile>,
5353
}
5454

5555
pub struct CrateMetadata {

src/librustc_metadata/cstore_impl.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ use syntax::ast;
4040
use syntax::attr;
4141
use syntax::codemap;
4242
use syntax::edition::Edition;
43-
use syntax::parse::filemap_to_stream;
43+
use syntax::parse::source_file_to_stream;
4444
use syntax::symbol::Symbol;
4545
use syntax_pos::{Span, NO_EXPANSION, FileName};
4646
use rustc_data_structures::indexed_set::IdxSetBuf;
@@ -463,9 +463,9 @@ impl cstore::CStore {
463463
let (name, def) = data.get_macro(id.index);
464464
let source_name = FileName::Macros(name.to_string());
465465

466-
let filemap = sess.parse_sess.codemap().new_filemap(source_name, def.body);
467-
let local_span = Span::new(filemap.start_pos, filemap.end_pos, NO_EXPANSION);
468-
let body = filemap_to_stream(&sess.parse_sess, filemap, None);
466+
let source_file = sess.parse_sess.codemap().new_source_file(source_name, def.body);
467+
let local_span = Span::new(source_file.start_pos, source_file.end_pos, NO_EXPANSION);
468+
let body = source_file_to_stream(&sess.parse_sess, source_file, None);
469469

470470
// Mark the attrs as used
471471
let attrs = data.get_item_attrs(id.index, sess);

src/librustc_metadata/decoder.rs

Lines changed: 32 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -50,8 +50,8 @@ pub struct DecodeContext<'a, 'tcx: 'a> {
5050
sess: Option<&'a Session>,
5151
tcx: Option<TyCtxt<'a, 'tcx, 'tcx>>,
5252

53-
// Cache the last used filemap for translating spans as an optimization.
54-
last_filemap_index: usize,
53+
// Cache the last used source_file for translating spans as an optimization.
54+
last_source_file_index: usize,
5555

5656
lazy_state: LazyState,
5757

@@ -73,7 +73,7 @@ pub trait Metadata<'a, 'tcx>: Copy {
7373
cdata: self.cdata(),
7474
sess: self.sess().or(tcx.map(|tcx| tcx.sess)),
7575
tcx,
76-
last_filemap_index: 0,
76+
last_source_file_index: 0,
7777
lazy_state: LazyState::NoNode,
7878
alloc_decoding_session: self.cdata().map(|cdata| {
7979
cdata.alloc_decoding_state.new_decoding_session()
@@ -314,43 +314,43 @@ impl<'a, 'tcx> SpecializedDecoder<Span> for DecodeContext<'a, 'tcx> {
314314
bug!("Cannot decode Span without Session.")
315315
};
316316

317-
let imported_filemaps = self.cdata().imported_filemaps(&sess.codemap());
318-
let filemap = {
317+
let imported_source_files = self.cdata().imported_source_files(&sess.codemap());
318+
let source_file = {
319319
// Optimize for the case that most spans within a translated item
320-
// originate from the same filemap.
321-
let last_filemap = &imported_filemaps[self.last_filemap_index];
320+
// originate from the same source_file.
321+
let last_source_file = &imported_source_files[self.last_source_file_index];
322322

323-
if lo >= last_filemap.original_start_pos &&
324-
lo <= last_filemap.original_end_pos {
325-
last_filemap
323+
if lo >= last_source_file.original_start_pos &&
324+
lo <= last_source_file.original_end_pos {
325+
last_source_file
326326
} else {
327327
let mut a = 0;
328-
let mut b = imported_filemaps.len();
328+
let mut b = imported_source_files.len();
329329

330330
while b - a > 1 {
331331
let m = (a + b) / 2;
332-
if imported_filemaps[m].original_start_pos > lo {
332+
if imported_source_files[m].original_start_pos > lo {
333333
b = m;
334334
} else {
335335
a = m;
336336
}
337337
}
338338

339-
self.last_filemap_index = a;
340-
&imported_filemaps[a]
339+
self.last_source_file_index = a;
340+
&imported_source_files[a]
341341
}
342342
};
343343

344344
// Make sure our binary search above is correct.
345-
debug_assert!(lo >= filemap.original_start_pos &&
346-
lo <= filemap.original_end_pos);
345+
debug_assert!(lo >= source_file.original_start_pos &&
346+
lo <= source_file.original_end_pos);
347347

348348
// Make sure we correctly filtered out invalid spans during encoding
349-
debug_assert!(hi >= filemap.original_start_pos &&
350-
hi <= filemap.original_end_pos);
349+
debug_assert!(hi >= source_file.original_start_pos &&
350+
hi <= source_file.original_end_pos);
351351

352-
let lo = (lo + filemap.translated_filemap.start_pos) - filemap.original_start_pos;
353-
let hi = (hi + filemap.translated_filemap.start_pos) - filemap.original_start_pos;
352+
let lo = (lo + source_file.translated_source_file.start_pos) - source_file.original_start_pos;
353+
let hi = (hi + source_file.translated_source_file.start_pos) - source_file.original_start_pos;
354354

355355
Ok(Span::new(lo, hi, NO_EXPANSION))
356356
}
@@ -1116,13 +1116,13 @@ impl<'a, 'tcx> CrateMetadata {
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.
1119-
pub fn imported_filemaps(&'a self,
1119+
pub fn imported_source_files(&'a self,
11201120
local_codemap: &codemap::SourceMap)
11211121
-> ReadGuard<'a, Vec<cstore::ImportedSourceFile>> {
11221122
{
1123-
let filemaps = self.codemap_import_info.borrow();
1124-
if !filemaps.is_empty() {
1125-
return filemaps;
1123+
let source_files = self.codemap_import_info.borrow();
1124+
if !source_files.is_empty() {
1125+
return source_files;
11261126
}
11271127
}
11281128

@@ -1136,7 +1136,7 @@ impl<'a, 'tcx> CrateMetadata {
11361136

11371137
let external_codemap = self.root.codemap.decode(self);
11381138

1139-
let imported_filemaps = external_codemap.map(|filemap_to_import| {
1139+
let imported_source_files = external_codemap.map(|source_file_to_import| {
11401140
// We can't reuse an existing SourceFile, so allocate a new one
11411141
// containing the information we need.
11421142
let syntax_pos::SourceFile { name,
@@ -1148,13 +1148,13 @@ impl<'a, 'tcx> CrateMetadata {
11481148
mut multibyte_chars,
11491149
mut non_narrow_chars,
11501150
name_hash,
1151-
.. } = filemap_to_import;
1151+
.. } = source_file_to_import;
11521152

11531153
let source_length = (end_pos - start_pos).to_usize();
11541154

11551155
// Translate line-start positions and multibyte character
11561156
// position into frame of reference local to file.
1157-
// `SourceMap::new_imported_filemap()` will then translate those
1157+
// `SourceMap::new_imported_source_file()` will then translate those
11581158
// coordinates to their new global frame of reference when the
11591159
// offset of the SourceFile is known.
11601160
for pos in &mut lines {
@@ -1167,7 +1167,7 @@ impl<'a, 'tcx> CrateMetadata {
11671167
*swc = *swc - start_pos;
11681168
}
11691169

1170-
let local_version = local_codemap.new_imported_filemap(name,
1170+
let local_version = local_codemap.new_imported_source_file(name,
11711171
name_was_remapped,
11721172
self.cnum.as_u32(),
11731173
src_hash,
@@ -1176,20 +1176,20 @@ impl<'a, 'tcx> CrateMetadata {
11761176
lines,
11771177
multibyte_chars,
11781178
non_narrow_chars);
1179-
debug!("CrateMetaData::imported_filemaps alloc \
1180-
filemap {:?} original (start_pos {:?} end_pos {:?}) \
1179+
debug!("CrateMetaData::imported_source_files alloc \
1180+
source_file {:?} original (start_pos {:?} end_pos {:?}) \
11811181
translated (start_pos {:?} end_pos {:?})",
11821182
local_version.name, start_pos, end_pos,
11831183
local_version.start_pos, local_version.end_pos);
11841184

11851185
cstore::ImportedSourceFile {
11861186
original_start_pos: start_pos,
11871187
original_end_pos: end_pos,
1188-
translated_filemap: local_version,
1188+
translated_source_file: local_version,
11891189
}
11901190
}).collect();
11911191

1192-
*codemap_import_info = imported_filemaps;
1192+
*codemap_import_info = imported_source_files;
11931193
drop(codemap_import_info);
11941194

11951195
// This shouldn't borrow twice, but there is no way to downgrade RefMut to Ref.

0 commit comments

Comments
 (0)