diff options
| author | Mark Rousskov <mark.simulacrum@gmail.com> | 2019-09-07 09:57:11 -0400 |
|---|---|---|
| committer | Mark Rousskov <mark.simulacrum@gmail.com> | 2019-09-17 09:29:46 -0400 |
| commit | cdd805506e7a01d60906f8b153afb697d687609d (patch) | |
| tree | 6658569a67824f7f59aeea3b3a1c395a2f05d7e5 /src/libsyntax | |
| parent | 5670d048c0f88af9976b5505c7853b23dd06770d (diff) | |
| download | rust-cdd805506e7a01d60906f8b153afb697d687609d.tar.gz rust-cdd805506e7a01d60906f8b153afb697d687609d.zip | |
Replace DiagnosticBuilder with Diagnostic when emitting error
Diffstat (limited to 'src/libsyntax')
| -rw-r--r-- | src/libsyntax/json.rs | 26 | ||||
| -rw-r--r-- | src/libsyntax/parse/lexer/tests.rs | 1 | ||||
| -rw-r--r-- | src/libsyntax/tests.rs | 1 |
3 files changed, 20 insertions, 8 deletions
diff --git a/src/libsyntax/json.rs b/src/libsyntax/json.rs index ada46f7bc5a..5cdea3aabbe 100644 --- a/src/libsyntax/json.rs +++ b/src/libsyntax/json.rs @@ -12,7 +12,7 @@ use crate::source_map::{SourceMap, FilePathMapping}; use errors::registry::Registry; -use errors::{DiagnosticBuilder, SubDiagnostic, CodeSuggestion, SourceMapper}; +use errors::{SubDiagnostic, CodeSuggestion, SourceMapper}; use errors::{DiagnosticId, Applicability}; use errors::emitter::{Emitter, HumanReadableErrorType}; @@ -32,6 +32,7 @@ pub struct JsonEmitter { pretty: bool, ui_testing: bool, json_rendered: HumanReadableErrorType, + external_macro_backtrace: bool, } impl JsonEmitter { @@ -40,6 +41,7 @@ impl JsonEmitter { source_map: Lrc<SourceMap>, pretty: bool, json_rendered: HumanReadableErrorType, + external_macro_backtrace: bool, ) -> JsonEmitter { JsonEmitter { dst: Box::new(io::stderr()), @@ -48,13 +50,18 @@ impl JsonEmitter { pretty, ui_testing: false, json_rendered, + external_macro_backtrace, } } - pub fn basic(pretty: bool, json_rendered: HumanReadableErrorType) -> JsonEmitter { + pub fn basic( + pretty: bool, + json_rendered: HumanReadableErrorType, + external_macro_backtrace: bool, + ) -> JsonEmitter { let file_path_mapping = FilePathMapping::empty(); JsonEmitter::stderr(None, Lrc::new(SourceMap::new(file_path_mapping)), - pretty, json_rendered) + pretty, json_rendered, external_macro_backtrace) } pub fn new( @@ -63,6 +70,7 @@ impl JsonEmitter { source_map: Lrc<SourceMap>, pretty: bool, json_rendered: HumanReadableErrorType, + external_macro_backtrace: bool, ) -> JsonEmitter { JsonEmitter { dst, @@ -71,6 +79,7 @@ impl JsonEmitter { pretty, ui_testing: false, json_rendered, + external_macro_backtrace, } } @@ -80,8 +89,8 @@ impl JsonEmitter { } impl Emitter for JsonEmitter { - fn emit_diagnostic(&mut self, db: &DiagnosticBuilder<'_>) { - let data = Diagnostic::from_diagnostic_builder(db, self); + fn emit_diagnostic(&mut self, db: &errors::Diagnostic) { + let data = Diagnostic::from_errors_diagnostic(db, self); let result = if self.pretty { writeln!(&mut self.dst, "{}", as_pretty_json(&data)) } else { @@ -189,7 +198,7 @@ struct ArtifactNotification<'a> { } impl Diagnostic { - fn from_diagnostic_builder(db: &DiagnosticBuilder<'_>, + fn from_errors_diagnostic(db: &errors::Diagnostic, je: &JsonEmitter) -> Diagnostic { let sugg = db.suggestions.iter().map(|sugg| { @@ -219,8 +228,9 @@ impl Diagnostic { } let buf = BufWriter::default(); let output = buf.clone(); - je.json_rendered.new_emitter(Box::new(buf), Some(je.sm.clone()), false, None) - .ui_testing(je.ui_testing).emit_diagnostic(db); + je.json_rendered.new_emitter( + Box::new(buf), Some(je.sm.clone()), false, None, je.external_macro_backtrace + ).ui_testing(je.ui_testing).emit_diagnostic(db); let output = Arc::try_unwrap(output.0).unwrap().into_inner().unwrap(); let output = String::from_utf8(output).unwrap(); diff --git a/src/libsyntax/parse/lexer/tests.rs b/src/libsyntax/parse/lexer/tests.rs index c1ec41902e2..de301b1fc49 100644 --- a/src/libsyntax/parse/lexer/tests.rs +++ b/src/libsyntax/parse/lexer/tests.rs @@ -18,6 +18,7 @@ fn mk_sess(sm: Lrc<SourceMap>) -> ParseSess { false, false, None, + false, ); ParseSess::with_span_handler(Handler::with_emitter(true, None, Box::new(emitter)), sm) } diff --git a/src/libsyntax/tests.rs b/src/libsyntax/tests.rs index 540881b0a54..f510ac9273d 100644 --- a/src/libsyntax/tests.rs +++ b/src/libsyntax/tests.rs @@ -147,6 +147,7 @@ fn test_harness(file_text: &str, span_labels: Vec<SpanLabel>, expected_output: & false, false, None, + false, ); let handler = Handler::with_emitter(true, None, Box::new(emitter)); handler.span_err(msp, "foo"); |
