diff options
| author | bors <bors@rust-lang.org> | 2020-01-29 13:40:58 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2020-01-29 13:40:58 +0000 |
| commit | eed12bcd0cb281979c4c9ed956b9e41fda2bfaeb (patch) | |
| tree | fdf73820fb17548b3ae1a65849819d42d1783dd5 /src/librustc_errors | |
| parent | edb368491551a77d77a48446d4ee88b35490c565 (diff) | |
| parent | 50df7880a77912702de51f454e58ae65a48d9e29 (diff) | |
Auto merge of #68635 - JohnTitor:rollup-jsc34ac, r=JohnTitor
Rollup of 7 pull requests Successful merges: - #67722 (Minor: note how Any is an unsafe trait in SAFETY comments) - #68586 (Make conflicting_repr_hints a deny-by-default c-future-compat lint) - #68598 (Fix null synthetic_implementors error) - #68603 (Changelog: Demonstrate final build-override syntax) - #68609 (Set lld flavor for MSVC to link.exe) - #68611 (Correct ICE caused by macros generating invalid spans.) - #68627 (Document that write_all will not call write if given an empty buffer) Failed merges: r? @ghost
Diffstat (limited to 'src/librustc_errors')
| -rw-r--r-- | src/librustc_errors/emitter.rs | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/src/librustc_errors/emitter.rs b/src/librustc_errors/emitter.rs index bf660d188b2..7ef623807d0 100644 --- a/src/librustc_errors/emitter.rs +++ b/src/librustc_errors/emitter.rs @@ -19,6 +19,7 @@ use crate::{ 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}; @@ -2108,7 +2109,13 @@ impl<'a> Drop for WritableDst<'a> { /// 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 |
