diff options
Diffstat (limited to 'src/libsyntax/parse')
| -rw-r--r-- | src/libsyntax/parse/mod.rs | 16 |
1 files changed, 6 insertions, 10 deletions
diff --git a/src/libsyntax/parse/mod.rs b/src/libsyntax/parse/mod.rs index 003bc006ebe..cd1be9a3c16 100644 --- a/src/libsyntax/parse/mod.rs +++ b/src/libsyntax/parse/mod.rs @@ -21,8 +21,7 @@ use parse::parser::Parser; use std::path::Path; use std::rt::io; -use std::rt::io::Reader; -use std::rt::io::file::FileInfo; +use std::rt::io::file; use std::str; pub mod lexer; @@ -269,16 +268,13 @@ pub fn file_to_filemap(sess: @mut ParseSess, path: &Path, spanopt: Option<Span>) None => sess.span_diagnostic.handler().fatal(msg), } }; - let mut error = None; - let bytes = do io::io_error::cond.trap(|e| error = Some(e)).inside { - path.open_reader(io::Open).read_to_end() - }; - match error { - Some(e) => { + let bytes = match io::result(|| file::open(path).read_to_end()) { + Ok(bytes) => bytes, + Err(e) => { err(format!("couldn't read {}: {}", path.display(), e.desc)); + unreachable!() } - None => {} - } + }; match str::from_utf8_owned_opt(bytes) { Some(s) => { return string_to_filemap(sess, s.to_managed(), |
