]> git.lizzy.rs Git - rust.git/blobdiff - compiler/rustc_errors/src/emitter.rs
Auto merge of #96881 - est31:join_osstr, r=dtolnay
[rust.git] / compiler / rustc_errors / src / emitter.rs
index 47cdf39cd52ce056905cff618d64592d361388a9..3fdc8cf8ac25fb9cd30da027b104e59844f92164 100644 (file)
@@ -212,7 +212,12 @@ fn emit_artifact_notification(&mut self, _path: &Path, _artifact_type: &str) {}
     fn emit_future_breakage_report(&mut self, _diags: Vec<Diagnostic>) {}
 
     /// Emit list of unused externs
-    fn emit_unused_externs(&mut self, _lint_level: &str, _unused_externs: &[&str]) {}
+    fn emit_unused_externs(
+        &mut self,
+        _lint_level: rustc_lint_defs::Level,
+        _unused_externs: &[&str],
+    ) {
+    }
 
     /// Checks if should show explanations about "rustc --explain"
     fn should_show_explain(&self) -> bool {
@@ -1256,16 +1261,23 @@ fn get_multispan_max_line_num(&mut self, msp: &MultiSpan) -> usize {
             return 0;
         };
 
+        let will_be_emitted = |span: Span| {
+            !span.is_dummy() && {
+                let file = sm.lookup_source_file(span.hi());
+                sm.ensure_source_file_source_present(file)
+            }
+        };
+
         let mut max = 0;
         for primary_span in msp.primary_spans() {
-            if !primary_span.is_dummy() {
+            if will_be_emitted(*primary_span) {
                 let hi = sm.lookup_char_pos(primary_span.hi());
                 max = (hi.line).max(max);
             }
         }
         if !self.short_message {
             for span_label in msp.span_labels() {
-                if !span_label.span.is_dummy() {
+                if will_be_emitted(span_label.span) {
                     let hi = sm.lookup_char_pos(span_label.span.hi());
                     max = (hi.line).max(max);
                 }