Skip to content

Commit fb2446a

Browse files
committed
Auto merge of #55190 - dlavati:51574_rename_codemap_filemap, r=petrochenkov
Rename other occs of (Code/File)Map to Source(Map/File) #51574 Additional renamings for #51574.
2 parents d586d5d + 6c9f6a1 commit fb2446a

File tree

13 files changed

+210
-209
lines changed

13 files changed

+210
-209
lines changed

src/librustc/ich/mod.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,10 @@
1111
//! ICH - Incremental Compilation Hash
1212
1313
crate use rustc_data_structures::fingerprint::Fingerprint;
14-
pub use self::caching_codemap_view::CachingSourceMapView;
14+
pub use self::caching_source_map_view::CachingSourceMapView;
1515
pub use self::hcx::{StableHashingContextProvider, StableHashingContext, NodeIdHashingMode,
1616
hash_stable_trait_impls};
17-
mod caching_codemap_view;
17+
mod caching_source_map_view;
1818
mod hcx;
1919

2020
mod impls_cstore;

src/librustc/ty/query/on_disk_cache.rs

+5-5
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ use rustc_serialize::{Decodable, Decoder, Encodable, Encoder, opaque,
2525
use session::{CrateDisambiguator, Session};
2626
use std::mem;
2727
use syntax::ast::NodeId;
28-
use syntax::source_map::{SourceMap, StableFilemapId};
28+
use syntax::source_map::{SourceMap, StableSourceFileId};
2929
use syntax_pos::{BytePos, Span, DUMMY_SP, SourceFile};
3030
use syntax_pos::hygiene::{Mark, SyntaxContext, ExpnInfo};
3131
use ty;
@@ -62,7 +62,7 @@ pub struct OnDiskCache<'sess> {
6262
cnum_map: Once<IndexVec<CrateNum, Option<CrateNum>>>,
6363

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

6767
// These two fields caches that are populated lazily during decoding.
6868
file_index_to_file: Lock<FxHashMap<SourceFileIndex, Lrc<SourceFile>>>,
@@ -82,7 +82,7 @@ pub struct OnDiskCache<'sess> {
8282
// This type is used only for (de-)serialization.
8383
#[derive(RustcEncodable, RustcDecodable)]
8484
struct Footer {
85-
file_index_to_stable_id: FxHashMap<SourceFileIndex, StableFilemapId>,
85+
file_index_to_stable_id: FxHashMap<SourceFileIndex, StableSourceFileId>,
8686
prev_cnums: Vec<(u32, String, CrateDisambiguator)>,
8787
query_result_index: EncodedQueryResultIndex,
8888
diagnostics_index: EncodedQueryResultIndex,
@@ -181,7 +181,7 @@ impl<'sess> OnDiskCache<'sess> {
181181
let index = SourceFileIndex(index as u32);
182182
let file_ptr: *const SourceFile = &**file as *const _;
183183
file_to_file_index.insert(file_ptr, index);
184-
file_index_to_stable_id.insert(index, StableFilemapId::new(&file));
184+
file_index_to_stable_id.insert(index, StableSourceFileId::new(&file));
185185
}
186186

187187
(file_to_file_index, file_index_to_stable_id)
@@ -473,7 +473,7 @@ struct CacheDecoder<'a, 'tcx: 'a, 'x> {
473473
cnum_map: &'x IndexVec<CrateNum, Option<CrateNum>>,
474474
synthetic_expansion_infos: &'x Lock<FxHashMap<AbsoluteBytePos, SyntaxContext>>,
475475
file_index_to_file: &'x Lock<FxHashMap<SourceFileIndex, Lrc<SourceFile>>>,
476-
file_index_to_stable_id: &'x FxHashMap<SourceFileIndex, StableFilemapId>,
476+
file_index_to_stable_id: &'x FxHashMap<SourceFileIndex, StableSourceFileId>,
477477
alloc_decoding_session: AllocDecodingSession<'x>,
478478
}
479479

src/librustc_errors/emitter.rs

+28-28
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ impl ColorConfig {
120120

121121
pub struct EmitterWriter {
122122
dst: Destination,
123-
cm: Option<Lrc<SourceMapperDyn>>,
123+
sm: Option<Lrc<SourceMapperDyn>>,
124124
short_message: bool,
125125
teach: bool,
126126
ui_testing: bool,
@@ -134,28 +134,28 @@ struct FileWithAnnotatedLines {
134134

135135
impl EmitterWriter {
136136
pub fn stderr(color_config: ColorConfig,
137-
code_map: Option<Lrc<SourceMapperDyn>>,
137+
source_map: Option<Lrc<SourceMapperDyn>>,
138138
short_message: bool,
139139
teach: bool)
140140
-> EmitterWriter {
141141
let dst = Destination::from_stderr(color_config);
142142
EmitterWriter {
143143
dst,
144-
cm: code_map,
144+
sm: source_map,
145145
short_message,
146146
teach,
147147
ui_testing: false,
148148
}
149149
}
150150

151151
pub fn new(dst: Box<dyn Write + Send>,
152-
code_map: Option<Lrc<SourceMapperDyn>>,
152+
source_map: Option<Lrc<SourceMapperDyn>>,
153153
short_message: bool,
154154
teach: bool)
155155
-> EmitterWriter {
156156
EmitterWriter {
157157
dst: Raw(dst),
158-
cm: code_map,
158+
sm: source_map,
159159
short_message,
160160
teach,
161161
ui_testing: false,
@@ -214,14 +214,14 @@ impl EmitterWriter {
214214
let mut output = vec![];
215215
let mut multiline_annotations = vec![];
216216

217-
if let Some(ref cm) = self.cm {
217+
if let Some(ref sm) = self.sm {
218218
for span_label in msp.span_labels() {
219219
if span_label.span.is_dummy() {
220220
continue;
221221
}
222222

223-
let lo = cm.lookup_char_pos(span_label.span.lo());
224-
let mut hi = cm.lookup_char_pos(span_label.span.hi());
223+
let lo = sm.lookup_char_pos(span_label.span.lo());
224+
let mut hi = sm.lookup_char_pos(span_label.span.hi());
225225

226226
// Watch out for "empty spans". If we get a span like 6..6, we
227227
// want to just display a `^` at 6, so convert that to
@@ -724,10 +724,10 @@ impl EmitterWriter {
724724

725725
fn get_multispan_max_line_num(&mut self, msp: &MultiSpan) -> usize {
726726
let mut max = 0;
727-
if let Some(ref cm) = self.cm {
727+
if let Some(ref sm) = self.sm {
728728
for primary_span in msp.primary_spans() {
729729
if !primary_span.is_dummy() {
730-
let hi = cm.lookup_char_pos(primary_span.hi());
730+
let hi = sm.lookup_char_pos(primary_span.hi());
731731
if hi.line > max {
732732
max = hi.line;
733733
}
@@ -736,7 +736,7 @@ impl EmitterWriter {
736736
if !self.short_message {
737737
for span_label in msp.span_labels() {
738738
if !span_label.span.is_dummy() {
739-
let hi = cm.lookup_char_pos(span_label.span.hi());
739+
let hi = sm.lookup_char_pos(span_label.span.hi());
740740
if hi.line > max {
741741
max = hi.line;
742742
}
@@ -768,7 +768,7 @@ impl EmitterWriter {
768768
always_backtrace: bool) -> bool {
769769
let mut spans_updated = false;
770770

771-
if let Some(ref cm) = self.cm {
771+
if let Some(ref sm) = self.sm {
772772
let mut before_after: Vec<(Span, Span)> = vec![];
773773
let mut new_labels: Vec<(Span, String)> = vec![];
774774

@@ -777,7 +777,7 @@ impl EmitterWriter {
777777
if sp.is_dummy() {
778778
continue;
779779
}
780-
let call_sp = cm.call_span_if_macro(*sp);
780+
let call_sp = sm.call_span_if_macro(*sp);
781781
if call_sp != *sp && !always_backtrace {
782782
before_after.push((*sp, call_sp));
783783
}
@@ -802,7 +802,7 @@ impl EmitterWriter {
802802
})));
803803
}
804804
// Check to make sure we're not in any <*macros>
805-
if !cm.span_to_filename(def_site).is_macros() &&
805+
if !sm.span_to_filename(def_site).is_macros() &&
806806
!trace.macro_decl_name.starts_with("desugaring of ") &&
807807
!trace.macro_decl_name.starts_with("#[") ||
808808
always_backtrace {
@@ -829,7 +829,7 @@ impl EmitterWriter {
829829
if sp_label.span.is_dummy() {
830830
continue;
831831
}
832-
if cm.span_to_filename(sp_label.span.clone()).is_macros() &&
832+
if sm.span_to_filename(sp_label.span.clone()).is_macros() &&
833833
!always_backtrace
834834
{
835835
let v = sp_label.span.macro_backtrace();
@@ -1000,10 +1000,10 @@ impl EmitterWriter {
10001000
let mut annotated_files = self.preprocess_annotations(msp);
10011001

10021002
// Make sure our primary file comes first
1003-
let (primary_lo, cm) = if let (Some(cm), Some(ref primary_span)) =
1004-
(self.cm.as_ref(), msp.primary_span().as_ref()) {
1003+
let (primary_lo, sm) = if let (Some(sm), Some(ref primary_span)) =
1004+
(self.sm.as_ref(), msp.primary_span().as_ref()) {
10051005
if !primary_span.is_dummy() {
1006-
(cm.lookup_char_pos(primary_span.lo()), cm)
1006+
(sm.lookup_char_pos(primary_span.lo()), sm)
10071007
} else {
10081008
emit_to_destination(&buffer.render(), level, &mut self.dst, self.short_message)?;
10091009
return Ok(());
@@ -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_source_file_source_present(annotated_file.file.clone()) {
1024+
if !sm.ensure_source_file_source_present(annotated_file.file.clone()) {
10251025
continue;
10261026
}
10271027

@@ -1038,7 +1038,7 @@ impl EmitterWriter {
10381038
buffer.append(buffer_msg_line_offset,
10391039
&format!("{}:{}:{}",
10401040
loc.file.name,
1041-
cm.doctest_offset_line(loc.line),
1041+
sm.doctest_offset_line(loc.line),
10421042
loc.col.0 + 1),
10431043
Style::LineAndColumn);
10441044
for _ in 0..max_line_num_len {
@@ -1048,7 +1048,7 @@ impl EmitterWriter {
10481048
buffer.prepend(0,
10491049
&format!("{}:{}:{}: ",
10501050
loc.file.name,
1051-
cm.doctest_offset_line(loc.line),
1051+
sm.doctest_offset_line(loc.line),
10521052
loc.col.0 + 1),
10531053
Style::LineAndColumn);
10541054
}
@@ -1069,7 +1069,7 @@ impl EmitterWriter {
10691069
};
10701070
format!("{}:{}{}",
10711071
annotated_file.file.name,
1072-
cm.doctest_offset_line(first_line.line_index),
1072+
sm.doctest_offset_line(first_line.line_index),
10731073
col)
10741074
} else {
10751075
annotated_file.file.name.to_string()
@@ -1194,7 +1194,7 @@ impl EmitterWriter {
11941194
level: &Level,
11951195
max_line_num_len: usize)
11961196
-> io::Result<()> {
1197-
if let Some(ref cm) = self.cm {
1197+
if let Some(ref sm) = self.sm {
11981198
let mut buffer = StyledBuffer::new();
11991199

12001200
// Render the suggestion message
@@ -1210,7 +1210,7 @@ impl EmitterWriter {
12101210
Some(Style::HeaderMsg));
12111211

12121212
// Render the replacements for each suggestion
1213-
let suggestions = suggestion.splice_lines(&**cm);
1213+
let suggestions = suggestion.splice_lines(&**sm);
12141214

12151215
let mut row_num = 2;
12161216
for &(ref complete, ref parts) in suggestions.iter().take(MAX_SUGGESTIONS) {
@@ -1221,11 +1221,11 @@ impl EmitterWriter {
12211221
&& parts[0].snippet.trim() == complete.trim())
12221222
&& complete.lines().count() == 1;
12231223

1224-
let lines = cm.span_to_lines(parts[0].span).unwrap();
1224+
let lines = sm.span_to_lines(parts[0].span).unwrap();
12251225

12261226
assert!(!lines.lines.is_empty());
12271227

1228-
let line_start = cm.lookup_char_pos(parts[0].span.lo()).line;
1228+
let line_start = sm.lookup_char_pos(parts[0].span.lo()).line;
12291229
draw_col_separator_no_space(&mut buffer, 1, max_line_num_len + 1);
12301230
let mut line_pos = 0;
12311231
let mut lines = complete.lines();
@@ -1250,8 +1250,8 @@ impl EmitterWriter {
12501250
if show_underline {
12511251
draw_col_separator(&mut buffer, row_num, max_line_num_len + 1);
12521252
for part in parts {
1253-
let span_start_pos = cm.lookup_char_pos(part.span.lo()).col_display;
1254-
let span_end_pos = cm.lookup_char_pos(part.span.hi()).col_display;
1253+
let span_start_pos = sm.lookup_char_pos(part.span.lo()).col_display;
1254+
let span_end_pos = sm.lookup_char_pos(part.span.hi()).col_display;
12551255

12561256
// Do not underline the leading...
12571257
let start = part.snippet.len()

src/librustc_errors/lib.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ pub trait SourceMapper {
129129
fn span_to_filename(&self, sp: Span) -> FileName;
130130
fn merge_spans(&self, sp_lhs: Span, sp_rhs: Span) -> Option<Span>;
131131
fn call_span_if_macro(&self, sp: Span) -> Span;
132-
fn ensure_source_file_source_present(&self, file_map: Lrc<SourceFile>) -> bool;
132+
fn ensure_source_file_source_present(&self, source_file: Lrc<SourceFile>) -> bool;
133133
fn doctest_offset_line(&self, line: usize) -> usize;
134134
}
135135

src/libsyntax/json.rs

+9-9
Original file line numberDiff line numberDiff line change
@@ -36,19 +36,19 @@ use rustc_serialize::json::{as_json, as_pretty_json};
3636
pub struct JsonEmitter {
3737
dst: Box<dyn Write + Send>,
3838
registry: Option<Registry>,
39-
cm: Lrc<dyn SourceMapper + sync::Send + sync::Sync>,
39+
sm: Lrc<dyn SourceMapper + sync::Send + sync::Sync>,
4040
pretty: bool,
4141
ui_testing: bool,
4242
}
4343

4444
impl JsonEmitter {
4545
pub fn stderr(registry: Option<Registry>,
46-
code_map: Lrc<SourceMap>,
46+
source_map: Lrc<SourceMap>,
4747
pretty: bool) -> JsonEmitter {
4848
JsonEmitter {
4949
dst: Box::new(io::stderr()),
5050
registry,
51-
cm: code_map,
51+
sm: source_map,
5252
pretty,
5353
ui_testing: false,
5454
}
@@ -62,12 +62,12 @@ impl JsonEmitter {
6262

6363
pub fn new(dst: Box<dyn Write + Send>,
6464
registry: Option<Registry>,
65-
code_map: Lrc<SourceMap>,
65+
source_map: Lrc<SourceMap>,
6666
pretty: bool) -> JsonEmitter {
6767
JsonEmitter {
6868
dst,
6969
registry,
70-
cm: code_map,
70+
sm: source_map,
7171
pretty,
7272
ui_testing: false,
7373
}
@@ -199,7 +199,7 @@ impl Diagnostic {
199199
}
200200
let buf = BufWriter::default();
201201
let output = buf.clone();
202-
EmitterWriter::new(Box::new(buf), Some(je.cm.clone()), false, false)
202+
EmitterWriter::new(Box::new(buf), Some(je.sm.clone()), false, false)
203203
.ui_testing(je.ui_testing).emit(db);
204204
let output = Arc::try_unwrap(output.0).unwrap().into_inner().unwrap();
205205
let output = String::from_utf8(output).unwrap();
@@ -269,8 +269,8 @@ impl DiagnosticSpan {
269269
mut backtrace: vec::IntoIter<MacroBacktrace>,
270270
je: &JsonEmitter)
271271
-> DiagnosticSpan {
272-
let start = je.cm.lookup_char_pos(span.lo());
273-
let end = je.cm.lookup_char_pos(span.hi());
272+
let start = je.sm.lookup_char_pos(span.lo());
273+
let end = je.sm.lookup_char_pos(span.hi());
274274
let backtrace_step = backtrace.next().map(|bt| {
275275
let call_site =
276276
Self::from_span_full(bt.call_site,
@@ -356,7 +356,7 @@ impl DiagnosticSpanLine {
356356
/// of `span` gets a DiagnosticSpanLine, with the highlight indicating the
357357
/// `span` within the line.
358358
fn from_span(span: Span, je: &JsonEmitter) -> Vec<DiagnosticSpanLine> {
359-
je.cm.span_to_lines(span)
359+
je.sm.span_to_lines(span)
360360
.map(|lines| {
361361
let fm = &*lines.file;
362362
lines.lines

0 commit comments

Comments
 (0)