about summary refs log tree commit diff
diff options
context:
space:
mode:
authorGuillaume Gomez <guillaume.gomez@huawei.com>2024-05-25 13:03:53 +0200
committerGuillaume Gomez <guillaume.gomez@huawei.com>2024-05-27 14:41:19 +0200
commit1551fd12023e3b84d844bde2e376c407af1e9a04 (patch)
tree7a91b9a9b069efcf270a913b666e87b06634cbe2
parent90fec5a0873c82674890a9f67b73a4f0a35e9d0b (diff)
downloadrust-1551fd12023e3b84d844bde2e376c407af1e9a04.tar.gz
rust-1551fd12023e3b84d844bde2e376c407af1e9a04.zip
Add file path in case it cannot be read in `Diff::actual_file`
-rw-r--r--src/tools/run-make-support/src/diff/mod.rs5
1 files changed, 4 insertions, 1 deletions
diff --git a/src/tools/run-make-support/src/diff/mod.rs b/src/tools/run-make-support/src/diff/mod.rs
index 332126939c0..d864ddf4eb1 100644
--- a/src/tools/run-make-support/src/diff/mod.rs
+++ b/src/tools/run-make-support/src/diff/mod.rs
@@ -51,7 +51,10 @@ impl Diff {
     /// Specify the actual output for the diff from a file.
     pub fn actual_file<P: AsRef<Path>>(&mut self, path: P) -> &mut Self {
         let path = path.as_ref();
-        let content = std::fs::read_to_string(path).expect("failed to read file");
+        let content = match std::fs::read_to_string(path) {
+            Ok(c) => c,
+            Err(e) => panic!("failed to read `{}`: {:?}", path.display(), e),
+        };
         let name = path.to_string_lossy().to_string();
 
         self.actual = Some(content);