pluralize, CodeSuggestion, Diagnostic, DiagnosticId, Level, SubDiagnostic, SuggestionStyle,
};
+use log::*;
use rustc_data_structures::fx::FxHashMap;
use rustc_data_structures::sync::Lrc;
use rustc_span::hygiene::{ExpnKind, MacroKind};
}
if sm.span_to_filename(sp_label.span.clone()).is_macros() && !always_backtrace {
if let Some(use_site) = sp_label.span.macro_backtrace().last() {
- before_after.push((sp_label.span.clone(), use_site.call_site.clone()));
+ before_after.push((sp_label.span, use_site.call_site));
}
}
}
let level_str = level.to_string();
// The failure note level itself does not provide any useful diagnostic information
if *level != Level::FailureNote && !level_str.is_empty() {
- buffer.append(0, &level_str, Style::Level(level.clone()));
+ buffer.append(0, &level_str, Style::Level(*level));
}
// only render error codes, not lint codes
if let Some(DiagnosticId::Error(ref code)) = *code {
- buffer.append(0, "[", Style::Level(level.clone()));
- buffer.append(0, &code, Style::Level(level.clone()));
- buffer.append(0, "]", Style::Level(level.clone()));
+ buffer.append(0, "[", Style::Level(*level));
+ buffer.append(0, &code, Style::Level(*level));
+ buffer.append(0, "]", Style::Level(*level));
}
if *level != Level::FailureNote && !level_str.is_empty() {
buffer.append(0, ": ", header_style);
} else if self.ui_testing {
140
} else {
- term_size::dimensions()
+ termize::dimensions()
.map(|(w, _)| w.saturating_sub(code_offset))
.unwrap_or(std::usize::MAX)
};
// Render the suggestion message
let level_str = level.to_string();
if !level_str.is_empty() {
- buffer.append(0, &level_str, Style::Level(level.clone()));
+ buffer.append(0, &level_str, Style::Level(*level));
buffer.append(0, ": ", Style::HeaderMsg);
}
self.msg_to_buffer(
/// Whether the original and suggested code are visually similar enough to warrant extra wording.
pub fn is_case_difference(sm: &SourceMap, suggested: &str, sp: Span) -> bool {
// FIXME: this should probably be extended to also account for `FO0` → `FOO` and unicode.
- let found = sm.span_to_snippet(sp).unwrap();
+ let found = match sm.span_to_snippet(sp) {
+ Ok(snippet) => snippet,
+ Err(e) => {
+ warn!("Invalid span {:?}. Err={:?}", sp, e);
+ return false;
+ }
+ };
let ascii_confusables = &['c', 'f', 'i', 'k', 'o', 's', 'u', 'v', 'w', 'x', 'y', 'z'];
// All the chars that differ in capitalization are confusable (above):
let confusable = found