@@ -14,7 +14,6 @@ use rustc_span::source_map::{FilePathMapping, SourceMap};
1414use crate :: emitter:: { Emitter , HumanReadableErrorType } ;
1515use crate :: registry:: Registry ;
1616use crate :: DiagnosticId ;
17- use crate :: ToolMetadata ;
1817use crate :: {
1918 CodeSuggestion , FluentBundle , LazyFallbackBundle , MultiSpan , SpanLabel , SubDiagnostic ,
2019} ;
@@ -30,7 +29,6 @@ use std::sync::{Arc, Mutex};
3029use std:: vec;
3130
3231use rustc_serialize:: json:: { as_json, as_pretty_json} ;
33- use rustc_serialize:: { Encodable , Encoder } ;
3432
3533#[ cfg( test) ]
3634mod tests;
@@ -205,8 +203,7 @@ impl Emitter for JsonEmitter {
205203
206204// The following data types are provided just for serialisation.
207205
208- // NOTE: this has a manual implementation of Encodable which needs to be updated in
209- // parallel.
206+ #[ derive( Encodable ) ]
210207struct Diagnostic {
211208 /// The primary error message.
212209 message : String ,
@@ -218,65 +215,6 @@ struct Diagnostic {
218215 children : Vec < Diagnostic > ,
219216 /// The message as rustc would render it.
220217 rendered : Option < String > ,
221- /// Extra tool metadata
222- tool_metadata : ToolMetadata ,
223- }
224-
225- macro_rules! encode_fields {
226- (
227- $enc: expr, // encoder
228- $idx: expr, // starting field index
229- $struct: expr, // struct we're serializing
230- $struct_name: ident, // struct name
231- [ $( $name: ident) ,+$( , ) ? ] , // fields to encode
232- [ $( $ignore: ident) ,+$( , ) ? ] // fields we're skipping
233- ) => {
234- {
235- // Pattern match to make sure all fields are accounted for
236- let $struct_name { $( $name, ) + $( $ignore: _, ) + } = $struct;
237- let mut idx = $idx;
238- $(
239- $enc. emit_struct_field(
240- stringify!( $name) ,
241- idx == 0 ,
242- |enc| $name. encode( enc) ,
243- ) ?;
244- idx += 1 ;
245- ) +
246- idx
247- }
248- } ;
249- }
250-
251- // Special-case encoder to skip tool_metadata if not set
252- impl < E : Encoder > Encodable < E > for Diagnostic {
253- fn encode ( & self , s : & mut E ) -> Result < ( ) , E :: Error > {
254- s. emit_struct ( false , |s| {
255- let mut idx = 0 ;
256-
257- idx = encode_fields ! (
258- s,
259- idx,
260- self ,
261- Self ,
262- [ message, code, level, spans, children, rendered] ,
263- [ tool_metadata]
264- ) ;
265- if self . tool_metadata . is_set ( ) {
266- idx = encode_fields ! (
267- s,
268- idx,
269- self ,
270- Self ,
271- [ tool_metadata] ,
272- [ message, code, level, spans, children, rendered]
273- ) ;
274- }
275-
276- let _ = idx;
277- Ok ( ( ) )
278- } )
279- }
280218}
281219
282220#[ derive( Encodable ) ]
@@ -380,7 +318,6 @@ impl Diagnostic {
380318 spans : DiagnosticSpan :: from_suggestion ( sugg, & args, je) ,
381319 children : vec ! [ ] ,
382320 rendered : None ,
383- tool_metadata : sugg. tool_metadata . clone ( ) ,
384321 }
385322 } ) ;
386323
@@ -428,7 +365,6 @@ impl Diagnostic {
428365 . chain ( sugg)
429366 . collect ( ) ,
430367 rendered : Some ( output) ,
431- tool_metadata : ToolMetadata :: default ( ) ,
432368 }
433369 }
434370
@@ -449,7 +385,6 @@ impl Diagnostic {
449385 . unwrap_or_else ( || DiagnosticSpan :: from_multispan ( & diag. span , args, je) ) ,
450386 children : vec ! [ ] ,
451387 rendered : None ,
452- tool_metadata : ToolMetadata :: default ( ) ,
453388 }
454389 }
455390}
0 commit comments