@@ -13,8 +13,9 @@ use rustc_span::source_map::{FilePathMapping, SourceMap};
1313
1414use crate :: emitter:: { Emitter , HumanReadableErrorType } ;
1515use crate :: registry:: Registry ;
16- use crate :: { Applicability , DiagnosticId } ;
16+ use crate :: DiagnosticId ;
1717use crate :: { CodeSuggestion , SubDiagnostic } ;
18+ use rustc_lint_defs:: { Applicability , FutureBreakage } ;
1819
1920use rustc_data_structures:: sync:: Lrc ;
2021use rustc_span:: hygiene:: ExpnData ;
@@ -131,6 +132,30 @@ impl Emitter for JsonEmitter {
131132 }
132133 }
133134
135+ fn emit_future_breakage_report ( & mut self , diags : Vec < ( FutureBreakage , crate :: Diagnostic ) > ) {
136+ let data: Vec < FutureBreakageItem > = diags
137+ . into_iter ( )
138+ . map ( |( breakage, mut diag) | {
139+ if diag. level == crate :: Level :: Allow {
140+ diag. level = crate :: Level :: Warning ;
141+ }
142+ FutureBreakageItem {
143+ future_breakage_date : breakage. date ,
144+ diagnostic : Diagnostic :: from_errors_diagnostic ( & diag, self ) ,
145+ }
146+ } )
147+ . collect ( ) ;
148+ let result = if self . pretty {
149+ writeln ! ( & mut self . dst, "{}" , as_pretty_json( & data) )
150+ } else {
151+ writeln ! ( & mut self . dst, "{}" , as_json( & data) )
152+ }
153+ . and_then ( |_| self . dst . flush ( ) ) ;
154+ if let Err ( e) = result {
155+ panic ! ( "failed to print future breakage report: {:?}" , e) ;
156+ }
157+ }
158+
134159 fn source_map ( & self ) -> Option < & Lrc < SourceMap > > {
135160 Some ( & self . sm )
136161 }
@@ -223,6 +248,12 @@ struct ArtifactNotification<'a> {
223248 emit : & ' a str ,
224249}
225250
251+ #[ derive( Encodable ) ]
252+ struct FutureBreakageItem {
253+ future_breakage_date : Option < & ' static str > ,
254+ diagnostic : Diagnostic ,
255+ }
256+
226257impl Diagnostic {
227258 fn from_errors_diagnostic ( diag : & crate :: Diagnostic , je : & JsonEmitter ) -> Diagnostic {
228259 let sugg = diag. suggestions . iter ( ) . map ( |sugg| Diagnostic {
@@ -432,7 +463,7 @@ impl DiagnosticCode {
432463 s. map ( |s| {
433464 let s = match s {
434465 DiagnosticId :: Error ( s) => s,
435- DiagnosticId :: Lint ( s ) => s ,
466+ DiagnosticId :: Lint { name , has_future_breakage : _ } => name ,
436467 } ;
437468 let je_result =
438469 je. registry . as_ref ( ) . map ( |registry| registry. try_find_description ( & s) ) . unwrap ( ) ;
0 commit comments