Skip to content

Commit a8154c7

Browse files
committed
mv codemap source_map
1 parent f332b16 commit a8154c7

File tree

28 files changed

+130
-130
lines changed

28 files changed

+130
-130
lines changed

src/librustc/hir/map/collector.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ impl<'a, 'hir> NodeCollector<'a, 'hir> {
122122
pub(super) fn finalize_and_compute_crate_hash(mut self,
123123
crate_disambiguator: CrateDisambiguator,
124124
cstore: &dyn CrateStore,
125-
codemap: &SourceMap,
125+
source_map: &SourceMap,
126126
commandline_args_hash: u64)
127127
-> (Vec<MapEntry<'hir>>, Svh) {
128128
self
@@ -155,7 +155,7 @@ impl<'a, 'hir> NodeCollector<'a, 'hir> {
155155
// If we included the full mapping in the SVH, we could only have
156156
// reproducible builds by compiling from the same directory. So we just
157157
// hash the result of the mapping instead of the mapping itself.
158-
let mut source_file_names: Vec<_> = codemap
158+
let mut source_file_names: Vec<_> = source_map
159159
.files()
160160
.iter()
161161
.filter(|source_file| CrateNum::from_u32(source_file.crate_of_origin) == LOCAL_CRATE)

src/librustc/ich/caching_codemap_view.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -24,14 +24,14 @@ struct CacheEntry {
2424

2525
#[derive(Clone)]
2626
pub struct CachingCodemapView<'cm> {
27-
codemap: &'cm SourceMap,
27+
source_map: &'cm SourceMap,
2828
line_cache: [CacheEntry; 3],
2929
time_stamp: usize,
3030
}
3131

3232
impl<'cm> CachingCodemapView<'cm> {
33-
pub fn new(codemap: &'cm SourceMap) -> CachingCodemapView<'cm> {
34-
let files = codemap.files();
33+
pub fn new(source_map: &'cm SourceMap) -> CachingCodemapView<'cm> {
34+
let files = source_map.files();
3535
let first_file = files[0].clone();
3636
let entry = CacheEntry {
3737
time_stamp: 0,
@@ -43,7 +43,7 @@ impl<'cm> CachingCodemapView<'cm> {
4343
};
4444

4545
CachingCodemapView {
46-
codemap,
46+
source_map,
4747
line_cache: [entry.clone(), entry.clone(), entry.clone()],
4848
time_stamp: 0,
4949
}
@@ -78,9 +78,9 @@ impl<'cm> CachingCodemapView<'cm> {
7878
// If the entry doesn't point to the correct file, fix it up
7979
if pos < cache_entry.file.start_pos || pos >= cache_entry.file.end_pos {
8080
let file_valid;
81-
if self.codemap.files().len() > 0 {
82-
let file_index = self.codemap.lookup_source_file_idx(pos);
83-
let file = self.codemap.files()[file_index].clone();
81+
if self.source_map.files().len() > 0 {
82+
let file_index = self.source_map.lookup_source_file_idx(pos);
83+
let file = self.source_map.files()[file_index].clone();
8484

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

src/librustc/ich/hcx.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -58,8 +58,8 @@ pub struct StableHashingContext<'a> {
5858

5959
// Very often, we are hashing something that does not need the
6060
// CachingCodemapView, so we initialize it lazily.
61-
raw_codemap: &'a SourceMap,
62-
caching_codemap: Option<CachingCodemapView<'a>>,
61+
raw_source_map: &'a SourceMap,
62+
caching_source_map: Option<CachingCodemapView<'a>>,
6363

6464
pub(super) alloc_id_recursion_tracker: FxHashSet<AllocId>,
6565
}
@@ -100,8 +100,8 @@ impl<'a> StableHashingContext<'a> {
100100
body_resolver: BodyResolver(krate),
101101
definitions,
102102
cstore,
103-
caching_codemap: None,
104-
raw_codemap: sess.source_map(),
103+
caching_source_map: None,
104+
raw_source_map: sess.source_map(),
105105
hash_spans: hash_spans_initial,
106106
hash_bodies: true,
107107
node_id_hashing_mode: NodeIdHashingMode::HashDefPath,
@@ -170,12 +170,12 @@ impl<'a> StableHashingContext<'a> {
170170

171171
#[inline]
172172
pub fn source_map(&mut self) -> &mut CachingCodemapView<'a> {
173-
match self.caching_codemap {
173+
match self.caching_source_map {
174174
Some(ref mut cm) => {
175175
cm
176176
}
177177
ref mut none => {
178-
*none = Some(CachingCodemapView::new(self.raw_codemap));
178+
*none = Some(CachingCodemapView::new(self.raw_source_map));
179179
none.as_mut().unwrap()
180180
}
181181
}

src/librustc/session/mod.rs

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -978,7 +978,7 @@ pub fn build_session(
978978
) -> Session {
979979
let file_path_mapping = sopts.file_path_mapping();
980980

981-
build_session_with_codemap(
981+
build_session_with_source_map(
982982
sopts,
983983
local_crate_source_file,
984984
registry,
@@ -987,11 +987,11 @@ pub fn build_session(
987987
)
988988
}
989989

990-
pub fn build_session_with_codemap(
990+
pub fn build_session_with_source_map(
991991
sopts: config::Options,
992992
local_crate_source_file: Option<PathBuf>,
993993
registry: errors::registry::Registry,
994-
codemap: Lrc<source_map::SourceMap>,
994+
source_map: Lrc<source_map::SourceMap>,
995995
emitter_dest: Option<Box<dyn Write + Send>>,
996996
) -> Session {
997997
// FIXME: This is not general enough to make the warning lint completely override
@@ -1018,35 +1018,35 @@ pub fn build_session_with_codemap(
10181018
(config::ErrorOutputType::HumanReadable(color_config), None) => Box::new(
10191019
EmitterWriter::stderr(
10201020
color_config,
1021-
Some(codemap.clone()),
1021+
Some(source_map.clone()),
10221022
false,
10231023
sopts.debugging_opts.teach,
10241024
).ui_testing(sopts.debugging_opts.ui_testing),
10251025
),
10261026
(config::ErrorOutputType::HumanReadable(_), Some(dst)) => Box::new(
1027-
EmitterWriter::new(dst, Some(codemap.clone()), false, false)
1027+
EmitterWriter::new(dst, Some(source_map.clone()), false, false)
10281028
.ui_testing(sopts.debugging_opts.ui_testing),
10291029
),
10301030
(config::ErrorOutputType::Json(pretty), None) => Box::new(
10311031
JsonEmitter::stderr(
10321032
Some(registry),
1033-
codemap.clone(),
1033+
source_map.clone(),
10341034
pretty,
10351035
).ui_testing(sopts.debugging_opts.ui_testing),
10361036
),
10371037
(config::ErrorOutputType::Json(pretty), Some(dst)) => Box::new(
10381038
JsonEmitter::new(
10391039
dst,
10401040
Some(registry),
1041-
codemap.clone(),
1041+
source_map.clone(),
10421042
pretty,
10431043
).ui_testing(sopts.debugging_opts.ui_testing),
10441044
),
10451045
(config::ErrorOutputType::Short(color_config), None) => Box::new(
1046-
EmitterWriter::stderr(color_config, Some(codemap.clone()), true, false),
1046+
EmitterWriter::stderr(color_config, Some(source_map.clone()), true, false),
10471047
),
10481048
(config::ErrorOutputType::Short(_), Some(dst)) => {
1049-
Box::new(EmitterWriter::new(dst, Some(codemap.clone()), true, false))
1049+
Box::new(EmitterWriter::new(dst, Some(source_map.clone()), true, false))
10501050
}
10511051
};
10521052

@@ -1061,14 +1061,14 @@ pub fn build_session_with_codemap(
10611061
},
10621062
);
10631063

1064-
build_session_(sopts, local_crate_source_file, diagnostic_handler, codemap)
1064+
build_session_(sopts, local_crate_source_file, diagnostic_handler, source_map)
10651065
}
10661066

10671067
pub fn build_session_(
10681068
sopts: config::Options,
10691069
local_crate_source_file: Option<PathBuf>,
10701070
span_diagnostic: errors::Handler,
1071-
codemap: Lrc<source_map::SourceMap>,
1071+
source_map: Lrc<source_map::SourceMap>,
10721072
) -> Session {
10731073
let host_triple = TargetTriple::from_triple(config::host_triple());
10741074
let host = match Target::search(&host_triple) {
@@ -1081,7 +1081,7 @@ pub fn build_session_(
10811081
};
10821082
let target_cfg = config::build_target_config(&sopts, &span_diagnostic);
10831083

1084-
let p_s = parse::ParseSess::with_span_handler(span_diagnostic, codemap);
1084+
let p_s = parse::ParseSess::with_span_handler(span_diagnostic, source_map);
10851085
let default_sysroot = match sopts.maybe_sysroot {
10861086
Some(_) => None,
10871087
None => Some(filesearch::get_or_default_sysroot()),

src/librustc/ty/query/on_disk_cache.rs

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ pub struct OnDiskCache<'sess> {
6262
prev_cnums: Vec<(u32, String, CrateDisambiguator)>,
6363
cnum_map: Once<IndexVec<CrateNum, Option<CrateNum>>>,
6464

65-
codemap: &'sess SourceMap,
65+
source_map: &'sess SourceMap,
6666
file_index_to_stable_id: FxHashMap<SourceFileIndex, StableFilemapId>,
6767

6868
// These two fields caches that are populated lazily during decoding.
@@ -140,7 +140,7 @@ impl<'sess> OnDiskCache<'sess> {
140140
file_index_to_file: Lock::new(FxHashMap()),
141141
prev_cnums: footer.prev_cnums,
142142
cnum_map: Once::new(),
143-
codemap: sess.source_map(),
143+
source_map: sess.source_map(),
144144
current_diagnostics: Lock::new(FxHashMap()),
145145
query_result_index: footer.query_result_index.into_iter().collect(),
146146
prev_diagnostics_index: footer.diagnostics_index.into_iter().collect(),
@@ -149,14 +149,14 @@ impl<'sess> OnDiskCache<'sess> {
149149
}
150150
}
151151

152-
pub fn new_empty(codemap: &'sess SourceMap) -> OnDiskCache<'sess> {
152+
pub fn new_empty(source_map: &'sess SourceMap) -> OnDiskCache<'sess> {
153153
OnDiskCache {
154154
serialized_data: Vec::new(),
155155
file_index_to_stable_id: FxHashMap(),
156156
file_index_to_file: Lock::new(FxHashMap()),
157157
prev_cnums: vec![],
158158
cnum_map: Once::new(),
159-
codemap,
159+
source_map,
160160
current_diagnostics: Lock::new(FxHashMap()),
161161
query_result_index: FxHashMap(),
162162
prev_diagnostics_index: FxHashMap(),
@@ -196,7 +196,7 @@ impl<'sess> OnDiskCache<'sess> {
196196
expn_info_shorthands: FxHashMap(),
197197
interpret_allocs: FxHashMap(),
198198
interpret_allocs_inverse: Vec::new(),
199-
codemap: CachingCodemapView::new(tcx.sess.source_map()),
199+
source_map: CachingCodemapView::new(tcx.sess.source_map()),
200200
file_to_file_index,
201201
};
202202

@@ -413,7 +413,7 @@ impl<'sess> OnDiskCache<'sess> {
413413
let mut decoder = CacheDecoder {
414414
tcx,
415415
opaque: opaque::Decoder::new(&self.serialized_data[..], pos.to_usize()),
416-
codemap: self.codemap,
416+
source_map: self.source_map,
417417
cnum_map: self.cnum_map.get(),
418418
file_index_to_file: &self.file_index_to_file,
419419
file_index_to_stable_id: &self.file_index_to_stable_id,
@@ -475,7 +475,7 @@ impl<'sess> OnDiskCache<'sess> {
475475
struct CacheDecoder<'a, 'tcx: 'a, 'x> {
476476
tcx: TyCtxt<'a, 'tcx, 'tcx>,
477477
opaque: opaque::Decoder<'x>,
478-
codemap: &'x SourceMap,
478+
source_map: &'x SourceMap,
479479
cnum_map: &'x IndexVec<CrateNum, Option<CrateNum>>,
480480
synthetic_expansion_infos: &'x Lock<FxHashMap<AbsoluteBytePos, SyntaxContext>>,
481481
file_index_to_file: &'x Lock<FxHashMap<SourceFileIndex, Lrc<SourceFile>>>,
@@ -488,13 +488,13 @@ impl<'a, 'tcx, 'x> CacheDecoder<'a, 'tcx, 'x> {
488488
let CacheDecoder {
489489
ref file_index_to_file,
490490
ref file_index_to_stable_id,
491-
ref codemap,
491+
ref source_map,
492492
..
493493
} = *self;
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.source_file_by_stable_id(stable_id)
497+
source_map.source_file_by_stable_id(stable_id)
498498
.expect("Failed to lookup SourceFile in new context.")
499499
}).clone()
500500
}
@@ -770,7 +770,7 @@ struct CacheEncoder<'enc, 'a, 'tcx, E>
770770
expn_info_shorthands: FxHashMap<Mark, AbsoluteBytePos>,
771771
interpret_allocs: FxHashMap<interpret::AllocId, usize>,
772772
interpret_allocs_inverse: Vec<interpret::AllocId>,
773-
codemap: CachingCodemapView<'tcx>,
773+
source_map: CachingCodemapView<'tcx>,
774774
file_to_file_index: FxHashMap<*const SourceFile, SourceFileIndex>,
775775
}
776776

@@ -836,7 +836,7 @@ impl<'enc, 'a, 'tcx, E> SpecializedEncoder<Span> for CacheEncoder<'enc, 'a, 'tcx
836836
return TAG_INVALID_SPAN.encode(self);
837837
}
838838

839-
let (file_lo, line_lo, col_lo) = match self.codemap
839+
let (file_lo, line_lo, col_lo) = match self.source_map
840840
.byte_pos_to_line_and_col(span_data.lo) {
841841
Some(pos) => pos,
842842
None => {

src/librustc_driver/lib.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -522,9 +522,9 @@ fn run_compiler_with_pool<'a>(
522522
};
523523

524524
let loader = file_loader.unwrap_or(box RealFileLoader);
525-
let codemap = Lrc::new(SourceMap::with_file_loader(loader, sopts.file_path_mapping()));
526-
let mut sess = session::build_session_with_codemap(
527-
sopts, input_file_path.clone(), descriptions, codemap, emitter_dest,
525+
let source_map = Lrc::new(SourceMap::with_file_loader(loader, sopts.file_path_mapping()));
526+
let mut sess = session::build_session_with_source_map(
527+
sopts, input_file_path.clone(), descriptions, source_map, emitter_dest,
528528
);
529529

530530
if let Some(err) = input_err {

src/librustc_metadata/creader.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -245,7 +245,7 @@ impl<'a> CrateLoader<'a> {
245245
cnum_map,
246246
cnum,
247247
dependencies: Lock::new(dependencies),
248-
codemap_import_info: RwLock::new(vec![]),
248+
source_map_import_info: RwLock::new(vec![]),
249249
alloc_decoding_state: AllocDecodingState::new(interpret_alloc_index),
250250
dep_kind: Lock::new(dep_kind),
251251
source: cstore::CrateSource {

src/librustc_metadata/cstore.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -44,11 +44,11 @@ pub struct MetadataBlob(pub MetadataRef);
4444
/// Holds information about a syntax_pos::SourceFile imported from another crate.
4545
/// See `imported_source_files()` for more information.
4646
pub struct ImportedSourceFile {
47-
/// This SourceFile's byte-offset within the codemap of its original crate
47+
/// This SourceFile's byte-offset within the source_map of its original crate
4848
pub original_start_pos: syntax_pos::BytePos,
49-
/// The end of this SourceFile within the codemap of its original crate
49+
/// The end of this SourceFile within the source_map of its original crate
5050
pub original_end_pos: syntax_pos::BytePos,
51-
/// The imported SourceFile's representation within the local codemap
51+
/// The imported SourceFile's representation within the local source_map
5252
pub translated_source_file: Lrc<syntax_pos::SourceFile>,
5353
}
5454

@@ -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<ImportedSourceFile>>,
67+
pub source_map_import_info: RwLock<Vec<ImportedSourceFile>>,
6868

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

0 commit comments

Comments
 (0)