diff --git a/src/cargo/core/compiler/mod.rs b/src/cargo/core/compiler/mod.rs index 66d7835927e..1687a5d2ace 100644 --- a/src/cargo/core/compiler/mod.rs +++ b/src/cargo/core/compiler/mod.rs @@ -1172,10 +1172,14 @@ struct OutputOptions { /// of empty files are not created. If this is None, the output will not /// be cached (such as when replaying cached messages). cache_cell: Option<(PathBuf, LazyCell)>, - /// If `true`, display any recorded warning messages. - /// Other types of messages are processed regardless - /// of the value of this flag - show_warnings: bool, + /// If `true`, display any diagnostics. + /// Other types of JSON messages are processed regardless + /// of the value of this flag. + /// + /// This is used primarily for cache replay. If you build with `-vv`, the + /// cache will be filled with diagnostics from dependencies. When the + /// cache is replayed without `-vv`, we don't want to show them. + show_diagnostics: bool, warnings_seen: usize, errors_seen: usize, } @@ -1193,7 +1197,7 @@ impl OutputOptions { look_for_metadata_directive, color, cache_cell, - show_warnings: true, + show_diagnostics: true, warnings_seen: 0, errors_seen: 0, } @@ -1319,7 +1323,7 @@ fn on_stderr_line_inner( .map(|v| String::from_utf8(v).expect("utf8")) .expect("strip should never fail") }; - if options.show_warnings { + if options.show_diagnostics { count_diagnostic(&msg.level, options); state.emit_diag(msg.level, rendered)?; } @@ -1404,7 +1408,7 @@ fn on_stderr_line_inner( // from the compiler, so wrap it in an external Cargo JSON message // indicating which package it came from and then emit it. - if !options.show_warnings { + if !options.show_diagnostics { return Ok(true); } @@ -1438,7 +1442,7 @@ fn replay_output_cache( path: PathBuf, format: MessageFormat, color: bool, - show_warnings: bool, + show_diagnostics: bool, ) -> Work { let target = target.clone(); let mut options = OutputOptions { @@ -1446,7 +1450,7 @@ fn replay_output_cache( look_for_metadata_directive: true, color, cache_cell: None, - show_warnings, + show_diagnostics, warnings_seen: 0, errors_seen: 0, };