diff options
| author | Maxim Zholobak <maxim.zholobak@grammarly.com> | 2020-02-22 16:07:05 +0200 |
|---|---|---|
| committer | Maxim Zholobak <maxim.zholobak@grammarly.com> | 2020-02-22 16:17:31 +0200 |
| commit | 20c9a40fec886826a3e7c4ec0c33ea4692f2c6a8 (patch) | |
| tree | 932068f21449f5ed9dbe9aef74563c1f072a54e3 /src/librustc_errors | |
| parent | 03d2f5cd6c634b1fdcd26b036009aa4dce37fdfc (diff) | |
Rename CodeMap to SourceMap follow up
Diffstat (limited to 'src/librustc_errors')
| -rw-r--r-- | src/librustc_errors/json.rs | 8 | ||||
| -rw-r--r-- | src/librustc_errors/lib.rs | 32 |
2 files changed, 20 insertions, 20 deletions
diff --git a/src/librustc_errors/json.rs b/src/librustc_errors/json.rs index ffdff6acec5..1f6e268b506 100644 --- a/src/librustc_errors/json.rs +++ b/src/librustc_errors/json.rs @@ -373,13 +373,13 @@ impl DiagnosticSpan { impl DiagnosticSpanLine { fn line_from_source_file( - fm: &rustc_span::SourceFile, + sf: &rustc_span::SourceFile, index: usize, h_start: usize, h_end: usize, ) -> DiagnosticSpanLine { DiagnosticSpanLine { - text: fm.get_line(index).map_or(String::new(), |l| l.into_owned()), + text: sf.get_line(index).map_or(String::new(), |l| l.into_owned()), highlight_start: h_start, highlight_end: h_end, } @@ -392,13 +392,13 @@ impl DiagnosticSpanLine { je.sm .span_to_lines(span) .map(|lines| { - let fm = &*lines.file; + let sf = &*lines.file; lines .lines .iter() .map(|line| { DiagnosticSpanLine::line_from_source_file( - fm, + sf, line.line_index, line.start_col.0 + 1, line.end_col.0 + 1, diff --git a/src/librustc_errors/lib.rs b/src/librustc_errors/lib.rs index 594e813def8..1a0fe343521 100644 --- a/src/librustc_errors/lib.rs +++ b/src/librustc_errors/lib.rs @@ -144,7 +144,7 @@ pub struct SubstitutionPart { impl CodeSuggestion { /// Returns the assembled code suggestions, whether they should be shown with an underline /// and whether the substitution only differs in capitalization. - pub fn splice_lines(&self, cm: &SourceMap) -> Vec<(String, Vec<SubstitutionPart>, bool)> { + pub fn splice_lines(&self, sm: &SourceMap) -> Vec<(String, Vec<SubstitutionPart>, bool)> { use rustc_span::{CharPos, Pos}; fn push_trailing( @@ -176,7 +176,7 @@ impl CodeSuggestion { .filter(|subst| { // Suggestions coming from macros can have malformed spans. This is a heavy // handed approach to avoid ICEs by ignoring the suggestion outright. - let invalid = subst.parts.iter().any(|item| cm.is_valid_span(item.span).is_err()); + let invalid = subst.parts.iter().any(|item| sm.is_valid_span(item.span).is_err()); if invalid { debug!("splice_lines: suggestion contains an invalid span: {:?}", subst); } @@ -193,7 +193,7 @@ impl CodeSuggestion { let hi = substitution.parts.iter().map(|part| part.span.hi()).max()?; let bounding_span = Span::with_root_ctxt(lo, hi); // The different spans might belong to different contexts, if so ignore suggestion. - let lines = cm.span_to_lines(bounding_span).ok()?; + let lines = sm.span_to_lines(bounding_span).ok()?; assert!(!lines.lines.is_empty()); // To build up the result, we do this for each span: @@ -205,36 +205,36 @@ impl CodeSuggestion { // - splice in the span substitution // // Finally push the trailing line segment of the last span - let fm = &lines.file; - let mut prev_hi = cm.lookup_char_pos(bounding_span.lo()); + let sf = &lines.file; + let mut prev_hi = sm.lookup_char_pos(bounding_span.lo()); prev_hi.col = CharPos::from_usize(0); - let mut prev_line = fm.get_line(lines.lines[0].line_index); + let mut prev_line = sf.get_line(lines.lines[0].line_index); let mut buf = String::new(); for part in &substitution.parts { - let cur_lo = cm.lookup_char_pos(part.span.lo()); + let cur_lo = sm.lookup_char_pos(part.span.lo()); if prev_hi.line == cur_lo.line { push_trailing(&mut buf, prev_line.as_ref(), &prev_hi, Some(&cur_lo)); } else { push_trailing(&mut buf, prev_line.as_ref(), &prev_hi, None); // push lines between the previous and current span (if any) for idx in prev_hi.line..(cur_lo.line - 1) { - if let Some(line) = fm.get_line(idx) { + if let Some(line) = sf.get_line(idx) { buf.push_str(line.as_ref()); buf.push('\n'); } } - if let Some(cur_line) = fm.get_line(cur_lo.line - 1) { + if let Some(cur_line) = sf.get_line(cur_lo.line - 1) { let end = std::cmp::min(cur_line.len(), cur_lo.col.to_usize()); buf.push_str(&cur_line[..end]); } } buf.push_str(&part.snippet); - prev_hi = cm.lookup_char_pos(part.span.hi()); - prev_line = fm.get_line(prev_hi.line - 1); + prev_hi = sm.lookup_char_pos(part.span.hi()); + prev_line = sf.get_line(prev_hi.line - 1); } - let only_capitalization = is_case_difference(cm, &buf, bounding_span); + let only_capitalization = is_case_difference(sm, &buf, bounding_span); // if the replacement already ends with a newline, don't print the next line if !buf.ends_with('\n') { push_trailing(&mut buf, prev_line.as_ref(), &prev_hi, None); @@ -363,23 +363,23 @@ impl Handler { color_config: ColorConfig, can_emit_warnings: bool, treat_err_as_bug: Option<usize>, - cm: Option<Lrc<SourceMap>>, + sm: Option<Lrc<SourceMap>>, ) -> Self { Self::with_tty_emitter_and_flags( color_config, - cm, + sm, HandlerFlags { can_emit_warnings, treat_err_as_bug, ..Default::default() }, ) } pub fn with_tty_emitter_and_flags( color_config: ColorConfig, - cm: Option<Lrc<SourceMap>>, + sm: Option<Lrc<SourceMap>>, flags: HandlerFlags, ) -> Self { let emitter = Box::new(EmitterWriter::stderr( color_config, - cm, + sm, false, false, None, |
