]> git.lizzy.rs Git - rust.git/blobdiff - src/librustc_errors/json.rs
Rollup merge of #68889 - Zoxc:hir-krate, r=eddyb
[rust.git] / src / librustc_errors / json.rs
index 5f529c08c783625cf604ab5e29e4332fb70827e1..ffdff6acec5de1b0a08553198c048fda445667b3 100644 (file)
@@ -9,7 +9,7 @@
 
 // FIXME: spec the JSON output properly.
 
-use syntax_pos::source_map::{FilePathMapping, SourceMap};
+use rustc_span::source_map::{FilePathMapping, SourceMap};
 
 use crate::emitter::{Emitter, HumanReadableErrorType};
 use crate::registry::Registry;
 use crate::{CodeSuggestion, SubDiagnostic};
 
 use rustc_data_structures::sync::Lrc;
+use rustc_span::hygiene::ExpnData;
+use rustc_span::{MultiSpan, Span, SpanLabel};
 use std::io::{self, Write};
 use std::path::Path;
 use std::sync::{Arc, Mutex};
 use std::vec;
-use syntax_pos::{MacroBacktrace, MultiSpan, Span, SpanLabel};
 
 use rustc_serialize::json::{as_json, as_pretty_json};
 
@@ -35,7 +36,7 @@ pub struct JsonEmitter {
     pretty: bool,
     ui_testing: bool,
     json_rendered: HumanReadableErrorType,
-    external_macro_backtrace: bool,
+    macro_backtrace: bool,
 }
 
 impl JsonEmitter {
@@ -44,7 +45,7 @@ pub fn stderr(
         source_map: Lrc<SourceMap>,
         pretty: bool,
         json_rendered: HumanReadableErrorType,
-        external_macro_backtrace: bool,
+        macro_backtrace: bool,
     ) -> JsonEmitter {
         JsonEmitter {
             dst: Box::new(io::stderr()),
@@ -53,14 +54,14 @@ pub fn stderr(
             pretty,
             ui_testing: false,
             json_rendered,
-            external_macro_backtrace,
+            macro_backtrace,
         }
     }
 
     pub fn basic(
         pretty: bool,
         json_rendered: HumanReadableErrorType,
-        external_macro_backtrace: bool,
+        macro_backtrace: bool,
     ) -> JsonEmitter {
         let file_path_mapping = FilePathMapping::empty();
         JsonEmitter::stderr(
@@ -68,7 +69,7 @@ pub fn basic(
             Lrc::new(SourceMap::new(file_path_mapping)),
             pretty,
             json_rendered,
-            external_macro_backtrace,
+            macro_backtrace,
         )
     }
 
@@ -78,7 +79,7 @@ pub fn new(
         source_map: Lrc<SourceMap>,
         pretty: bool,
         json_rendered: HumanReadableErrorType,
-        external_macro_backtrace: bool,
+        macro_backtrace: bool,
     ) -> JsonEmitter {
         JsonEmitter {
             dst,
@@ -87,7 +88,7 @@ pub fn new(
             pretty,
             ui_testing: false,
             json_rendered,
-            external_macro_backtrace,
+            macro_backtrace,
         }
     }
 
@@ -244,13 +245,7 @@ fn flush(&mut self) -> io::Result<()> {
         let buf = BufWriter::default();
         let output = buf.clone();
         je.json_rendered
-            .new_emitter(
-                Box::new(buf),
-                Some(je.sm.clone()),
-                false,
-                None,
-                je.external_macro_backtrace,
-            )
+            .new_emitter(Box::new(buf), Some(je.sm.clone()), false, None, je.macro_backtrace)
             .ui_testing(je.ui_testing)
             .emit_diagnostic(diag);
         let output = Arc::try_unwrap(output.0).unwrap().into_inner().unwrap();
@@ -308,7 +303,7 @@ fn from_span_etc(
         // backtrace ourselves, but the `macro_backtrace` helper makes
         // some decision, such as dropping some frames, and I don't
         // want to duplicate that logic here.
-        let backtrace = span.macro_backtrace().into_iter();
+        let backtrace = span.macro_backtrace();
         DiagnosticSpan::from_span_full(span, is_primary, label, suggestion, backtrace, je)
     }
 
@@ -317,7 +312,7 @@ fn from_span_full(
         is_primary: bool,
         label: Option<String>,
         suggestion: Option<(&String, Applicability)>,
-        mut backtrace: vec::IntoIter<MacroBacktrace>,
+        mut backtrace: impl Iterator<Item = ExpnData>,
         je: &JsonEmitter,
     ) -> DiagnosticSpan {
         let start = je.sm.lookup_char_pos(span.lo());
@@ -325,10 +320,10 @@ fn from_span_full(
         let backtrace_step = backtrace.next().map(|bt| {
             let call_site = Self::from_span_full(bt.call_site, false, None, None, backtrace, je);
             let def_site_span =
-                Self::from_span_full(bt.def_site_span, false, None, None, vec![].into_iter(), je);
+                Self::from_span_full(bt.def_site, false, None, None, vec![].into_iter(), je);
             Box::new(DiagnosticSpanMacroExpansion {
                 span: call_site,
-                macro_decl_name: bt.macro_decl_name,
+                macro_decl_name: bt.kind.descr(),
                 def_site_span,
             })
         });
@@ -378,7 +373,7 @@ fn from_suggestion(suggestion: &CodeSuggestion, je: &JsonEmitter) -> Vec<Diagnos
 
 impl DiagnosticSpanLine {
     fn line_from_source_file(
-        fm: &syntax_pos::SourceFile,
+        fm: &rustc_span::SourceFile,
         index: usize,
         h_start: usize,
         h_end: usize,