@@ -28,7 +28,7 @@ use std::path::Path;
2828use std:: sync:: { Arc , Mutex } ;
2929use std:: vec;
3030
31- use rustc_serialize :: json :: { as_json , as_pretty_json } ;
31+ use serde :: Serialize ;
3232
3333#[ cfg( test) ]
3434mod tests;
@@ -126,9 +126,9 @@ impl Emitter for JsonEmitter {
126126 fn emit_diagnostic ( & mut self , diag : & crate :: Diagnostic ) {
127127 let data = Diagnostic :: from_errors_diagnostic ( diag, self ) ;
128128 let result = if self . pretty {
129- writeln ! ( & mut self . dst, "{}" , as_pretty_json ( & data) )
129+ writeln ! ( & mut self . dst, "{}" , serde_json :: to_string_pretty ( & data) . unwrap ( ) )
130130 } else {
131- writeln ! ( & mut self . dst, "{}" , as_json ( & data) )
131+ writeln ! ( & mut self . dst, "{}" , serde_json :: to_string ( & data) . unwrap ( ) )
132132 }
133133 . and_then ( |_| self . dst . flush ( ) ) ;
134134 if let Err ( e) = result {
@@ -139,9 +139,9 @@ impl Emitter for JsonEmitter {
139139 fn emit_artifact_notification ( & mut self , path : & Path , artifact_type : & str ) {
140140 let data = ArtifactNotification { artifact : path, emit : artifact_type } ;
141141 let result = if self . pretty {
142- writeln ! ( & mut self . dst, "{}" , as_pretty_json ( & data) )
142+ writeln ! ( & mut self . dst, "{}" , serde_json :: to_string_pretty ( & data) . unwrap ( ) )
143143 } else {
144- writeln ! ( & mut self . dst, "{}" , as_json ( & data) )
144+ writeln ! ( & mut self . dst, "{}" , serde_json :: to_string ( & data) . unwrap ( ) )
145145 }
146146 . and_then ( |_| self . dst . flush ( ) ) ;
147147 if let Err ( e) = result {
@@ -161,9 +161,9 @@ impl Emitter for JsonEmitter {
161161 . collect ( ) ;
162162 let report = FutureIncompatReport { future_incompat_report : data } ;
163163 let result = if self . pretty {
164- writeln ! ( & mut self . dst, "{}" , as_pretty_json ( & report) )
164+ writeln ! ( & mut self . dst, "{}" , serde_json :: to_string_pretty ( & report) . unwrap ( ) )
165165 } else {
166- writeln ! ( & mut self . dst, "{}" , as_json ( & report) )
166+ writeln ! ( & mut self . dst, "{}" , serde_json :: to_string ( & report) . unwrap ( ) )
167167 }
168168 . and_then ( |_| self . dst . flush ( ) ) ;
169169 if let Err ( e) = result {
@@ -175,9 +175,9 @@ impl Emitter for JsonEmitter {
175175 let lint_level = lint_level. as_str ( ) ;
176176 let data = UnusedExterns { lint_level, unused_extern_names : unused_externs } ;
177177 let result = if self . pretty {
178- writeln ! ( & mut self . dst, "{}" , as_pretty_json ( & data) )
178+ writeln ! ( & mut self . dst, "{}" , serde_json :: to_string_pretty ( & data) . unwrap ( ) )
179179 } else {
180- writeln ! ( & mut self . dst, "{}" , as_json ( & data) )
180+ writeln ! ( & mut self . dst, "{}" , serde_json :: to_string ( & data) . unwrap ( ) )
181181 }
182182 . and_then ( |_| self . dst . flush ( ) ) ;
183183 if let Err ( e) = result {
@@ -204,7 +204,7 @@ impl Emitter for JsonEmitter {
204204
205205// The following data types are provided just for serialisation.
206206
207- #[ derive( Encodable ) ]
207+ #[ derive( Serialize ) ]
208208struct Diagnostic {
209209 /// The primary error message.
210210 message : String ,
@@ -218,7 +218,7 @@ struct Diagnostic {
218218 rendered : Option < String > ,
219219}
220220
221- #[ derive( Encodable ) ]
221+ #[ derive( Serialize ) ]
222222struct DiagnosticSpan {
223223 file_name : String ,
224224 byte_start : u32 ,
@@ -245,7 +245,7 @@ struct DiagnosticSpan {
245245 expansion : Option < Box < DiagnosticSpanMacroExpansion > > ,
246246}
247247
248- #[ derive( Encodable ) ]
248+ #[ derive( Serialize ) ]
249249struct DiagnosticSpanLine {
250250 text : String ,
251251
@@ -255,7 +255,7 @@ struct DiagnosticSpanLine {
255255 highlight_end : usize ,
256256}
257257
258- #[ derive( Encodable ) ]
258+ #[ derive( Serialize ) ]
259259struct DiagnosticSpanMacroExpansion {
260260 /// span where macro was applied to generate this code; note that
261261 /// this may itself derive from a macro (if
@@ -269,28 +269,28 @@ struct DiagnosticSpanMacroExpansion {
269269 def_site_span : DiagnosticSpan ,
270270}
271271
272- #[ derive( Encodable ) ]
272+ #[ derive( Serialize ) ]
273273struct DiagnosticCode {
274274 /// The code itself.
275275 code : String ,
276276 /// An explanation for the code.
277277 explanation : Option < & ' static str > ,
278278}
279279
280- #[ derive( Encodable ) ]
280+ #[ derive( Serialize ) ]
281281struct ArtifactNotification < ' a > {
282282 /// The path of the artifact.
283283 artifact : & ' a Path ,
284284 /// What kind of artifact we're emitting.
285285 emit : & ' a str ,
286286}
287287
288- #[ derive( Encodable ) ]
288+ #[ derive( Serialize ) ]
289289struct FutureBreakageItem {
290290 diagnostic : Diagnostic ,
291291}
292292
293- #[ derive( Encodable ) ]
293+ #[ derive( Serialize ) ]
294294struct FutureIncompatReport {
295295 future_incompat_report : Vec < FutureBreakageItem > ,
296296}
@@ -299,7 +299,7 @@ struct FutureIncompatReport {
299299// doctest component (as well as cargo).
300300// We could unify this struct the one in rustdoc but they have different
301301// ownership semantics, so doing so would create wasteful allocations.
302- #[ derive( Encodable ) ]
302+ #[ derive( Serialize ) ]
303303struct UnusedExterns < ' a , ' b , ' c > {
304304 /// The severity level of the unused dependencies lint
305305 lint_level : & ' a str ,
0 commit comments