From b6b8880f0ec3f057dc56320f6886be173a8f0d8e Mon Sep 17 00:00:00 2001 From: Ryan Levick Date: Sun, 18 Jan 2015 00:49:50 +0100 Subject: [PATCH] Improve the error message when source file cannot be read Contribution from @look! --- src/libsyntax/parse/mod.rs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/libsyntax/parse/mod.rs b/src/libsyntax/parse/mod.rs index f1f547ba0c7dd..10fb0a73cec7b 100644 --- a/src/libsyntax/parse/mod.rs +++ b/src/libsyntax/parse/mod.rs @@ -253,9 +253,10 @@ pub fn file_to_filemap(sess: &ParseSess, path: &Path, spanopt: Option) let bytes = match File::open(path).read_to_end() { Ok(bytes) => bytes, Err(e) => { - err(&format!("couldn't read {:?}: {:?}", + let error_msg = e.desc; + err(&format!("couldn't read {:?}: {}", path.display(), - e)[]); + error_msg)[]); unreachable!() } };