Skip to content

Commit fb6cf56

Browse files
Rollup merge of rust-lang#129049 - Zalathar:json-like, r=jieyouxu
compiletest: Don't panic on unknown JSON-like output lines The `json::extract_rendered` function is called for both compiler output and non-compiler output, so it's inappropriate to panic just because a line starting with `{` didn't contain a compiler output message. It is called from two places: when checking the output of a `ui` test process, and when printing the output of an arbitrary non-passing `ProcRes`. So unfortunately there's currently no easy way to know for sure whether it is seeing compiler output or not. Fortunately, neither call site appears to be relying on this panic; it's just an overzealous internal check. Fixes rust-lang#126373.
2 parents f5611fb + 355f264 commit fb6cf56

File tree

1 file changed

+4
-6
lines changed

1 file changed

+4
-6
lines changed

src/tools/compiletest/src/json.rs

+4-6
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
//! These structs are a subset of the ones found in `rustc_errors::json`.
2-
//! They are only used for deserialization of JSON output provided by libtest.
32
43
use std::path::{Path, PathBuf};
54
use std::str::FromStr;
@@ -127,11 +126,10 @@ pub fn extract_rendered(output: &str) -> String {
127126
// Ignore the notification.
128127
None
129128
} else {
130-
print!(
131-
"failed to decode compiler output as json: line: {}\noutput: {}",
132-
line, output
133-
);
134-
panic!()
129+
// This function is called for both compiler and non-compiler output,
130+
// so if the line isn't recognized as JSON from the compiler then
131+
// just print it as-is.
132+
Some(format!("{line}\n"))
135133
}
136134
} else {
137135
// preserve non-JSON lines, such as ICEs

0 commit comments

Comments
 (0)