99
1010// FIXME: spec the JSON output properly.
1111
12- use rustc_span:: source_map:: SourceMap ;
13- use termcolor:: { ColorSpec , WriteColor } ;
14-
1512use crate :: emitter:: {
1613 should_show_source_code, ColorConfig , Destination , Emitter , HumanEmitter ,
1714 HumanReadableErrorType ,
@@ -22,32 +19,39 @@ use crate::{
2219 diagnostic:: IsLint , CodeSuggestion , FluentBundle , LazyFallbackBundle , MultiSpan , SpanLabel ,
2320 Subdiag , TerminalUrl ,
2421} ;
25- use rustc_lint_defs:: Applicability ;
26-
22+ use derive_setters:: Setters ;
2723use rustc_data_structures:: sync:: { IntoDynSyncSend , Lrc } ;
2824use rustc_error_messages:: FluentArgs ;
25+ use rustc_lint_defs:: Applicability ;
2926use rustc_span:: hygiene:: ExpnData ;
27+ use rustc_span:: source_map:: SourceMap ;
3028use rustc_span:: Span ;
29+ use serde:: Serialize ;
3130use std:: error:: Report ;
3231use std:: io:: { self , Write } ;
3332use std:: path:: Path ;
3433use std:: sync:: { Arc , Mutex } ;
3534use std:: vec;
36-
37- use serde:: Serialize ;
35+ use termcolor:: { ColorSpec , WriteColor } ;
3836
3937#[ cfg( test) ]
4038mod tests;
4139
40+ #[ derive( Setters ) ]
4241pub struct JsonEmitter {
42+ #[ setters( skip) ]
4343 dst : IntoDynSyncSend < Box < dyn Write + Send > > ,
4444 registry : Option < Registry > ,
45+ #[ setters( skip) ]
4546 sm : Lrc < SourceMap > ,
4647 fluent_bundle : Option < Lrc < FluentBundle > > ,
48+ #[ setters( skip) ]
4749 fallback_bundle : LazyFallbackBundle ,
50+ #[ setters( skip) ]
4851 pretty : bool ,
4952 ui_testing : bool ,
5053 ignored_directories_in_source_blocks : Vec < String > ,
54+ #[ setters( skip) ]
5155 json_rendered : HumanReadableErrorType ,
5256 diagnostic_width : Option < usize > ,
5357 macro_backtrace : bool ,
@@ -58,42 +62,28 @@ pub struct JsonEmitter {
5862impl JsonEmitter {
5963 pub fn new (
6064 dst : Box < dyn Write + Send > ,
61- registry : Option < Registry > ,
62- source_map : Lrc < SourceMap > ,
63- fluent_bundle : Option < Lrc < FluentBundle > > ,
65+ sm : Lrc < SourceMap > ,
6466 fallback_bundle : LazyFallbackBundle ,
6567 pretty : bool ,
6668 json_rendered : HumanReadableErrorType ,
67- diagnostic_width : Option < usize > ,
68- macro_backtrace : bool ,
69- track_diagnostics : bool ,
70- terminal_url : TerminalUrl ,
7169 ) -> JsonEmitter {
7270 JsonEmitter {
7371 dst : IntoDynSyncSend ( dst) ,
74- registry,
75- sm : source_map ,
76- fluent_bundle,
72+ registry : None ,
73+ sm,
74+ fluent_bundle : None ,
7775 fallback_bundle,
7876 pretty,
7977 ui_testing : false ,
8078 ignored_directories_in_source_blocks : Vec :: new ( ) ,
8179 json_rendered,
82- diagnostic_width,
83- macro_backtrace,
84- track_diagnostics,
85- terminal_url,
80+ diagnostic_width : None ,
81+ macro_backtrace : false ,
82+ track_diagnostics : false ,
83+ terminal_url : TerminalUrl :: No ,
8684 }
8785 }
8886
89- pub fn ui_testing ( self , ui_testing : bool ) -> Self {
90- Self { ui_testing, ..self }
91- }
92-
93- pub fn ignored_directories_in_source_blocks ( self , value : Vec < String > ) -> Self {
94- Self { ignored_directories_in_source_blocks : value, ..self }
95- }
96-
9787 fn emit ( & mut self , val : EmitTyped < ' _ > ) -> io:: Result < ( ) > {
9888 if self . pretty {
9989 serde_json:: to_writer_pretty ( & mut * self . dst , & val) ?
0 commit comments