Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rename other occs of (Code/File)Map to Source(Map/File) #51574 #55190

Merged
merged 1 commit into from
Oct 30, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/librustc/ich/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@
//! ICH - Incremental Compilation Hash

crate use rustc_data_structures::fingerprint::Fingerprint;
pub use self::caching_codemap_view::CachingSourceMapView;
pub use self::caching_source_map_view::CachingSourceMapView;
pub use self::hcx::{StableHashingContextProvider, StableHashingContext, NodeIdHashingMode,
hash_stable_trait_impls};
mod caching_codemap_view;
mod caching_source_map_view;
mod hcx;

mod impls_cstore;
Expand Down
10 changes: 5 additions & 5 deletions src/librustc/ty/query/on_disk_cache.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ use rustc_serialize::{Decodable, Decoder, Encodable, Encoder, opaque,
use session::{CrateDisambiguator, Session};
use std::mem;
use syntax::ast::NodeId;
use syntax::source_map::{SourceMap, StableFilemapId};
use syntax::source_map::{SourceMap, StableSourceFileId};
use syntax_pos::{BytePos, Span, DUMMY_SP, SourceFile};
use syntax_pos::hygiene::{Mark, SyntaxContext, ExpnInfo};
use ty;
Expand Down Expand Up @@ -62,7 +62,7 @@ pub struct OnDiskCache<'sess> {
cnum_map: Once<IndexVec<CrateNum, Option<CrateNum>>>,

source_map: &'sess SourceMap,
file_index_to_stable_id: FxHashMap<SourceFileIndex, StableFilemapId>,
file_index_to_stable_id: FxHashMap<SourceFileIndex, StableSourceFileId>,

// These two fields caches that are populated lazily during decoding.
file_index_to_file: Lock<FxHashMap<SourceFileIndex, Lrc<SourceFile>>>,
Expand All @@ -82,7 +82,7 @@ pub struct OnDiskCache<'sess> {
// This type is used only for (de-)serialization.
#[derive(RustcEncodable, RustcDecodable)]
struct Footer {
file_index_to_stable_id: FxHashMap<SourceFileIndex, StableFilemapId>,
file_index_to_stable_id: FxHashMap<SourceFileIndex, StableSourceFileId>,
prev_cnums: Vec<(u32, String, CrateDisambiguator)>,
query_result_index: EncodedQueryResultIndex,
diagnostics_index: EncodedQueryResultIndex,
Expand Down Expand Up @@ -181,7 +181,7 @@ impl<'sess> OnDiskCache<'sess> {
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));
file_index_to_stable_id.insert(index, StableSourceFileId::new(&file));
}

(file_to_file_index, file_index_to_stable_id)
Expand Down Expand Up @@ -473,7 +473,7 @@ struct CacheDecoder<'a, 'tcx: 'a, 'x> {
cnum_map: &'x IndexVec<CrateNum, Option<CrateNum>>,
synthetic_expansion_infos: &'x Lock<FxHashMap<AbsoluteBytePos, SyntaxContext>>,
file_index_to_file: &'x Lock<FxHashMap<SourceFileIndex, Lrc<SourceFile>>>,
file_index_to_stable_id: &'x FxHashMap<SourceFileIndex, StableFilemapId>,
file_index_to_stable_id: &'x FxHashMap<SourceFileIndex, StableSourceFileId>,
alloc_decoding_session: AllocDecodingSession<'x>,
}

Expand Down
56 changes: 28 additions & 28 deletions src/librustc_errors/emitter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ impl ColorConfig {

pub struct EmitterWriter {
dst: Destination,
cm: Option<Lrc<SourceMapperDyn>>,
sm: Option<Lrc<SourceMapperDyn>>,
short_message: bool,
teach: bool,
ui_testing: bool,
Expand All @@ -134,28 +134,28 @@ struct FileWithAnnotatedLines {

impl EmitterWriter {
pub fn stderr(color_config: ColorConfig,
code_map: Option<Lrc<SourceMapperDyn>>,
source_map: Option<Lrc<SourceMapperDyn>>,
short_message: bool,
teach: bool)
-> EmitterWriter {
let dst = Destination::from_stderr(color_config);
EmitterWriter {
dst,
cm: code_map,
sm: source_map,
short_message,
teach,
ui_testing: false,
}
}

pub fn new(dst: Box<dyn Write + Send>,
code_map: Option<Lrc<SourceMapperDyn>>,
source_map: Option<Lrc<SourceMapperDyn>>,
short_message: bool,
teach: bool)
-> EmitterWriter {
EmitterWriter {
dst: Raw(dst),
cm: code_map,
sm: source_map,
short_message,
teach,
ui_testing: false,
Expand Down Expand Up @@ -214,14 +214,14 @@ impl EmitterWriter {
let mut output = vec![];
let mut multiline_annotations = vec![];

if let Some(ref cm) = self.cm {
if let Some(ref sm) = self.sm {
for span_label in msp.span_labels() {
if span_label.span.is_dummy() {
continue;
}

let lo = cm.lookup_char_pos(span_label.span.lo());
let mut hi = cm.lookup_char_pos(span_label.span.hi());
let lo = sm.lookup_char_pos(span_label.span.lo());
let mut hi = sm.lookup_char_pos(span_label.span.hi());

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

fn get_multispan_max_line_num(&mut self, msp: &MultiSpan) -> usize {
let mut max = 0;
if let Some(ref cm) = self.cm {
if let Some(ref sm) = self.sm {
for primary_span in msp.primary_spans() {
if !primary_span.is_dummy() {
let hi = cm.lookup_char_pos(primary_span.hi());
let hi = sm.lookup_char_pos(primary_span.hi());
if hi.line > max {
max = hi.line;
}
Expand All @@ -736,7 +736,7 @@ impl EmitterWriter {
if !self.short_message {
for span_label in msp.span_labels() {
if !span_label.span.is_dummy() {
let hi = cm.lookup_char_pos(span_label.span.hi());
let hi = sm.lookup_char_pos(span_label.span.hi());
if hi.line > max {
max = hi.line;
}
Expand Down Expand Up @@ -768,7 +768,7 @@ impl EmitterWriter {
always_backtrace: bool) -> bool {
let mut spans_updated = false;

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

Expand All @@ -777,7 +777,7 @@ impl EmitterWriter {
if sp.is_dummy() {
continue;
}
let call_sp = cm.call_span_if_macro(*sp);
let call_sp = sm.call_span_if_macro(*sp);
if call_sp != *sp && !always_backtrace {
before_after.push((*sp, call_sp));
}
Expand All @@ -802,7 +802,7 @@ impl EmitterWriter {
})));
}
// Check to make sure we're not in any <*macros>
if !cm.span_to_filename(def_site).is_macros() &&
if !sm.span_to_filename(def_site).is_macros() &&
!trace.macro_decl_name.starts_with("desugaring of ") &&
!trace.macro_decl_name.starts_with("#[") ||
always_backtrace {
Expand All @@ -829,7 +829,7 @@ impl EmitterWriter {
if sp_label.span.is_dummy() {
continue;
}
if cm.span_to_filename(sp_label.span.clone()).is_macros() &&
if sm.span_to_filename(sp_label.span.clone()).is_macros() &&
!always_backtrace
{
let v = sp_label.span.macro_backtrace();
Expand Down Expand Up @@ -1000,10 +1000,10 @@ impl EmitterWriter {
let mut annotated_files = self.preprocess_annotations(msp);

// Make sure our primary file comes first
let (primary_lo, cm) = if let (Some(cm), Some(ref primary_span)) =
(self.cm.as_ref(), msp.primary_span().as_ref()) {
let (primary_lo, sm) = if let (Some(sm), Some(ref primary_span)) =
(self.sm.as_ref(), msp.primary_span().as_ref()) {
if !primary_span.is_dummy() {
(cm.lookup_char_pos(primary_span.lo()), cm)
(sm.lookup_char_pos(primary_span.lo()), sm)
} else {
emit_to_destination(&buffer.render(), level, &mut self.dst, self.short_message)?;
return Ok(());
Expand All @@ -1021,7 +1021,7 @@ impl EmitterWriter {
// Print out the annotate source lines that correspond with the error
for annotated_file in annotated_files {
// we can't annotate anything if the source is unavailable.
if !cm.ensure_source_file_source_present(annotated_file.file.clone()) {
if !sm.ensure_source_file_source_present(annotated_file.file.clone()) {
continue;
}

Expand All @@ -1038,7 +1038,7 @@ impl EmitterWriter {
buffer.append(buffer_msg_line_offset,
&format!("{}:{}:{}",
loc.file.name,
cm.doctest_offset_line(loc.line),
sm.doctest_offset_line(loc.line),
loc.col.0 + 1),
Style::LineAndColumn);
for _ in 0..max_line_num_len {
Expand All @@ -1048,7 +1048,7 @@ impl EmitterWriter {
buffer.prepend(0,
&format!("{}:{}:{}: ",
loc.file.name,
cm.doctest_offset_line(loc.line),
sm.doctest_offset_line(loc.line),
loc.col.0 + 1),
Style::LineAndColumn);
}
Expand All @@ -1069,7 +1069,7 @@ impl EmitterWriter {
};
format!("{}:{}{}",
annotated_file.file.name,
cm.doctest_offset_line(first_line.line_index),
sm.doctest_offset_line(first_line.line_index),
col)
} else {
annotated_file.file.name.to_string()
Expand Down Expand Up @@ -1194,7 +1194,7 @@ impl EmitterWriter {
level: &Level,
max_line_num_len: usize)
-> io::Result<()> {
if let Some(ref cm) = self.cm {
if let Some(ref sm) = self.sm {
let mut buffer = StyledBuffer::new();

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

// Render the replacements for each suggestion
let suggestions = suggestion.splice_lines(&**cm);
let suggestions = suggestion.splice_lines(&**sm);

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

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

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

let line_start = cm.lookup_char_pos(parts[0].span.lo()).line;
let line_start = sm.lookup_char_pos(parts[0].span.lo()).line;
draw_col_separator_no_space(&mut buffer, 1, max_line_num_len + 1);
let mut line_pos = 0;
let mut lines = complete.lines();
Expand All @@ -1250,8 +1250,8 @@ impl EmitterWriter {
if show_underline {
draw_col_separator(&mut buffer, row_num, max_line_num_len + 1);
for part in parts {
let span_start_pos = cm.lookup_char_pos(part.span.lo()).col_display;
let span_end_pos = cm.lookup_char_pos(part.span.hi()).col_display;
let span_start_pos = sm.lookup_char_pos(part.span.lo()).col_display;
let span_end_pos = sm.lookup_char_pos(part.span.hi()).col_display;

// Do not underline the leading...
let start = part.snippet.len()
Expand Down
2 changes: 1 addition & 1 deletion src/librustc_errors/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,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_source_file_source_present(&self, file_map: Lrc<SourceFile>) -> bool;
fn ensure_source_file_source_present(&self, source_file: Lrc<SourceFile>) -> bool;
fn doctest_offset_line(&self, line: usize) -> usize;
}

Expand Down
18 changes: 9 additions & 9 deletions src/libsyntax/json.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,19 +36,19 @@ use rustc_serialize::json::{as_json, as_pretty_json};
pub struct JsonEmitter {
dst: Box<dyn Write + Send>,
registry: Option<Registry>,
cm: Lrc<dyn SourceMapper + sync::Send + sync::Sync>,
sm: Lrc<dyn SourceMapper + sync::Send + sync::Sync>,
pretty: bool,
ui_testing: bool,
}

impl JsonEmitter {
pub fn stderr(registry: Option<Registry>,
code_map: Lrc<SourceMap>,
source_map: Lrc<SourceMap>,
pretty: bool) -> JsonEmitter {
JsonEmitter {
dst: Box::new(io::stderr()),
registry,
cm: code_map,
sm: source_map,
pretty,
ui_testing: false,
}
Expand All @@ -62,12 +62,12 @@ impl JsonEmitter {

pub fn new(dst: Box<dyn Write + Send>,
registry: Option<Registry>,
code_map: Lrc<SourceMap>,
source_map: Lrc<SourceMap>,
pretty: bool) -> JsonEmitter {
JsonEmitter {
dst,
registry,
cm: code_map,
sm: source_map,
pretty,
ui_testing: false,
}
Expand Down Expand Up @@ -199,7 +199,7 @@ impl Diagnostic {
}
let buf = BufWriter::default();
let output = buf.clone();
EmitterWriter::new(Box::new(buf), Some(je.cm.clone()), false, false)
EmitterWriter::new(Box::new(buf), Some(je.sm.clone()), false, false)
.ui_testing(je.ui_testing).emit(db);
let output = Arc::try_unwrap(output.0).unwrap().into_inner().unwrap();
let output = String::from_utf8(output).unwrap();
Expand Down Expand Up @@ -269,8 +269,8 @@ impl DiagnosticSpan {
mut backtrace: vec::IntoIter<MacroBacktrace>,
je: &JsonEmitter)
-> DiagnosticSpan {
let start = je.cm.lookup_char_pos(span.lo());
let end = je.cm.lookup_char_pos(span.hi());
let start = je.sm.lookup_char_pos(span.lo());
let end = je.sm.lookup_char_pos(span.hi());
let backtrace_step = backtrace.next().map(|bt| {
let call_site =
Self::from_span_full(bt.call_site,
Expand Down Expand Up @@ -356,7 +356,7 @@ impl DiagnosticSpanLine {
/// of `span` gets a DiagnosticSpanLine, with the highlight indicating the
/// `span` within the line.
fn from_span(span: Span, je: &JsonEmitter) -> Vec<DiagnosticSpanLine> {
je.cm.span_to_lines(span)
je.sm.span_to_lines(span)
.map(|lines| {
let fm = &*lines.file;
lines.lines
Expand Down
Loading