Add file path in case it cannot be read in `Diff::actual_file` · rust-lang/rust@1551fd1

File tree

1 file changed

lines changed

  • src/tools/run-make-support/src/diff

1 file changed

lines changed

Original file line numberDiff line numberDiff line change

@@ -51,7 +51,10 @@ impl Diff {

5151

/// Specify the actual output for the diff from a file.

5252

pub fn actual_file<P: AsRef<Path>>(&mut self, path: P) -> &mut Self {

5353

let path = path.as_ref();

54-

let content = std::fs::read_to_string(path).expect("failed to read file");

54+

let content = match std::fs::read_to_string(path) {

55+

Ok(c) => c,

56+

Err(e) => panic!("failed to read `{}`: {:?}", path.display(), e),

57+

};

5558

let name = path.to_string_lossy().to_string();

5659
5760

self.actual = Some(content);