Skip to content

Commit a675fd6

Browse files
committed
don't fail manifest creation if the toolstate file is missing or mal-formed
1 parent 9138d3b commit a675fd6

File tree

1 file changed

+9
-5
lines changed
  • src/tools/build-manifest/src

1 file changed

+9
-5
lines changed

src/tools/build-manifest/src/main.rs

+9-5
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
//! via `x.py dist hash-and-sign`; the cmdline arguments are set up
55
//! by rustbuild (in `src/bootstrap/dist.rs`).
66
7+
#![feature(try_blocks)]
78
#![deny(warnings)]
89

910
use toml;
@@ -380,11 +381,14 @@ impl Builder {
380381
/// If a tool does not pass its tests, don't ship it.
381382
/// Right now, we do this only for Miri.
382383
fn check_toolstate(&mut self) {
383-
// Get the toolstate for this rust revision.
384-
let toolstates = File::open(self.input.join("toolstates-linux.json"))
385-
.expect("failed to open toolstates file");
386-
let toolstates: HashMap<String, String> = serde_json::from_reader(&toolstates)
387-
.expect("toolstates file contains malformed JSON");
384+
let toolstates: Option<HashMap<String, String>> = try {
385+
let toolstates = File::open(self.input.join("toolstates-linux.json")).ok()?;
386+
serde_json::from_reader(&toolstates).ok()?
387+
};
388+
let toolstates = toolstates.unwrap_or_else(|| {
389+
println!("WARNING: `toolstates-linux.json` missing; assuming all tools failed");
390+
HashMap::default() // Use empty map if anything went wrong.
391+
});
388392
// Mark some tools as missing based on toolstate.
389393
if toolstates.get("miri").map(|s| &*s as &str) != Some("test-pass") {
390394
println!("Miri tests are not passing, removing component");

0 commit comments

Comments
 (0)