@@ -7,7 +7,7 @@ use crate::runner::tasks::TaskCtx;
77use crate :: runner:: OverrideResult ;
88use anyhow:: Error ;
99use cargo_metadata:: diagnostic:: DiagnosticLevel ;
10- use cargo_metadata:: { CrateType , Message , Metadata , Package , Target , TargetKind } ;
10+ use cargo_metadata:: { CrateType , Metadata , Package , Target , TargetKind } ;
1111use docsrs_metadata:: Metadata as DocsrsMetadata ;
1212use remove_dir_all:: remove_dir_all;
1313use rustwide:: cmd:: { CommandError , MountKind , ProcessLinesActions , SandboxBuilder } ;
@@ -233,6 +233,45 @@ fn run_cargo(
233233 }
234234}
235235
236+ /// A cargo message
237+ ///
238+ /// This duplicates cargo_metadata::Message, but without variants we don't need to avoid recursion
239+ /// issues. See https://github.com/rust-lang/rust/issues/152354 for context.
240+ #[ derive( Debug , Deserialize ) ]
241+ #[ serde( tag = "reason" , rename_all = "kebab-case" ) ]
242+ enum Message {
243+ /// The compiler wants to display a message
244+ CompilerMessage ( CompilerMessage ) ,
245+ #[ serde( other) ]
246+ Other ,
247+ }
248+
249+ /// A cargo message
250+ ///
251+ /// This duplicates cargo_metadata::CompilerMessage, but without variants we don't need to avoid recursion
252+ /// issues. See https://github.com/rust-lang/rust/issues/152354 for context.
253+ #[ derive( Debug , Deserialize ) ]
254+ struct CompilerMessage {
255+ /// The package this message belongs to
256+ package_id : cargo_metadata:: PackageId ,
257+ /// The message the compiler sent.
258+ message : Diagnostic ,
259+ }
260+
261+ /// A diagnostic message generated by rustc
262+ ///
263+ /// This duplicates cargo_metadata::Diagnostic, but without variants we don't need to avoid recursion
264+ /// issues. See https://github.com/rust-lang/rust/issues/152354 for context.
265+ #[ derive( Debug , Deserialize ) ]
266+ struct Diagnostic {
267+ /// The associated error code for this diagnostic
268+ code : Option < cargo_metadata:: diagnostic:: DiagnosticCode > ,
269+ /// "error: internal compiler error", "error", "warning", "note", "help"
270+ level : cargo_metadata:: diagnostic:: DiagnosticLevel ,
271+ /// The message as rustc would render it
272+ rendered : Option < String > ,
273+ }
274+
236275pub ( super ) fn run_test (
237276 action : & str ,
238277 ctx : & TaskCtx ,
0 commit comments