@@ -14,7 +14,6 @@ use rustc_span::source_map::{FilePathMapping, SourceMap};
14
14
use crate :: emitter:: { Emitter , HumanReadableErrorType } ;
15
15
use crate :: registry:: Registry ;
16
16
use crate :: DiagnosticId ;
17
- use crate :: ToolMetadata ;
18
17
use crate :: {
19
18
CodeSuggestion , FluentBundle , LazyFallbackBundle , MultiSpan , SpanLabel , SubDiagnostic ,
20
19
} ;
@@ -30,7 +29,6 @@ use std::sync::{Arc, Mutex};
30
29
use std:: vec;
31
30
32
31
use rustc_serialize:: json:: { as_json, as_pretty_json} ;
33
- use rustc_serialize:: { Encodable , Encoder } ;
34
32
35
33
#[ cfg( test) ]
36
34
mod tests;
@@ -205,8 +203,7 @@ impl Emitter for JsonEmitter {
205
203
206
204
// The following data types are provided just for serialisation.
207
205
208
- // NOTE: this has a manual implementation of Encodable which needs to be updated in
209
- // parallel.
206
+ #[ derive( Encodable ) ]
210
207
struct Diagnostic {
211
208
/// The primary error message.
212
209
message : String ,
@@ -218,65 +215,6 @@ struct Diagnostic {
218
215
children : Vec < Diagnostic > ,
219
216
/// The message as rustc would render it.
220
217
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
- }
280
218
}
281
219
282
220
#[ derive( Encodable ) ]
@@ -380,7 +318,6 @@ impl Diagnostic {
380
318
spans : DiagnosticSpan :: from_suggestion ( sugg, & args, je) ,
381
319
children : vec ! [ ] ,
382
320
rendered : None ,
383
- tool_metadata : sugg. tool_metadata . clone ( ) ,
384
321
}
385
322
} ) ;
386
323
@@ -428,7 +365,6 @@ impl Diagnostic {
428
365
. chain ( sugg)
429
366
. collect ( ) ,
430
367
rendered : Some ( output) ,
431
- tool_metadata : ToolMetadata :: default ( ) ,
432
368
}
433
369
}
434
370
@@ -449,7 +385,6 @@ impl Diagnostic {
449
385
. unwrap_or_else ( || DiagnosticSpan :: from_multispan ( & diag. span , args, je) ) ,
450
386
children : vec ! [ ] ,
451
387
rendered : None ,
452
- tool_metadata : ToolMetadata :: default ( ) ,
453
388
}
454
389
}
455
390
}
0 commit comments