// 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};
pretty: bool,
ui_testing: bool,
json_rendered: HumanReadableErrorType,
- external_macro_backtrace: bool,
+ macro_backtrace: bool,
}
impl JsonEmitter {
source_map: Lrc<SourceMap>,
pretty: bool,
json_rendered: HumanReadableErrorType,
- external_macro_backtrace: bool,
+ macro_backtrace: bool,
) -> JsonEmitter {
JsonEmitter {
dst: Box::new(io::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(
Lrc::new(SourceMap::new(file_path_mapping)),
pretty,
json_rendered,
- external_macro_backtrace,
+ macro_backtrace,
)
}
source_map: Lrc<SourceMap>,
pretty: bool,
json_rendered: HumanReadableErrorType,
- external_macro_backtrace: bool,
+ macro_backtrace: bool,
) -> JsonEmitter {
JsonEmitter {
dst,
pretty,
ui_testing: false,
json_rendered,
- external_macro_backtrace,
+ macro_backtrace,
}
}
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();
// 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)
}
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());
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,
})
});
impl DiagnosticSpanLine {
fn line_from_source_file(
- fm: &syntax_pos::SourceFile,
+ fm: &rustc_span::SourceFile,
index: usize,
h_start: usize,
h_end: usize,