about summary refs log tree commit diff
path: root/src/libsyntax/parse
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2014-02-03 10:41:34 -0800
committerbors <bors@rust-lang.org>2014-02-03 10:41:34 -0800
commitcb40eba4b1ce12914612914b94bdccd251a9f554 (patch)
tree5cb922f942920dc7d6b0f3606e9cd914360b2707 /src/libsyntax/parse
parentbe4fc638092bf896c5c6c0672136b83b71e491ee (diff)
parentc765a8e7ad314651b92ff860cda0159c79dbec6e (diff)
downloadrust-cb40eba4b1ce12914612914b94bdccd251a9f554.tar.gz
rust-cb40eba4b1ce12914612914b94bdccd251a9f554.zip
auto merge of #11946 : alexcrichton/rust/no-io-error, r=brson
Turns out this was a little more far-reaching than I thought it was.

The first commit is the crux of this stack of commits. The `io::io_error` condition is completely removed and the `read` and `write` methods are altered to return `IoResult<T>`. This turned out to be an incredibly far-reaching change!

Overall, I'm very happy with how this turned out (in addition with the `unused_must_use` lint). I had to almost rewrite the pretty printer in `libsyntax` as well as the the formatting in `librustdoc` (as one would expect). These two modules do *tons* of I/O, and I believe that it's definitely improved.

This pull request also introduces the `if_ok!()` macro for returning-early from something that returns a result. I made quite liberal use of this in mostly the pretty printer and html renderer, and I found its usage generally quite pleasant and convenient to have. I didn't really feel like adding any other macro while I was using it, and I figured that pretty printing could be nicer, but it's nowhere near horrid today.

This may be a controversial issue closing, but I'm going to say it.

Closes #6163
Diffstat (limited to 'src/libsyntax/parse')
-rw-r--r--src/libsyntax/parse/comments.rs3
-rw-r--r--src/libsyntax/parse/mod.rs5
-rw-r--r--src/libsyntax/parse/token.rs4
3 files changed, 6 insertions, 6 deletions
diff --git a/src/libsyntax/parse/comments.rs b/src/libsyntax/parse/comments.rs
index 7165e7b404f..f65bc3ad7a3 100644
--- a/src/libsyntax/parse/comments.rs
+++ b/src/libsyntax/parse/comments.rs
@@ -350,7 +350,8 @@ pub fn gather_comments_and_literals(span_diagnostic:
                                     path: ~str,
                                     srdr: &mut io::Reader)
                                  -> (~[Comment], ~[Literal]) {
-    let src = str::from_utf8_owned(srdr.read_to_end()).unwrap();
+    let src = srdr.read_to_end().unwrap();
+    let src = str::from_utf8_owned(src).unwrap();
     let cm = CodeMap::new();
     let filemap = cm.new_filemap(path, src);
     let rdr = lexer::new_low_level_string_reader(span_diagnostic, filemap);
diff --git a/src/libsyntax/parse/mod.rs b/src/libsyntax/parse/mod.rs
index cec9f7c2d9f..328f0e7f221 100644
--- a/src/libsyntax/parse/mod.rs
+++ b/src/libsyntax/parse/mod.rs
@@ -19,7 +19,6 @@ use parse::attr::ParserAttr;
 use parse::parser::Parser;
 
 use std::cell::RefCell;
-use std::io;
 use std::io::File;
 use std::str;
 
@@ -232,10 +231,10 @@ pub fn file_to_filemap(sess: @ParseSess, path: &Path, spanopt: Option<Span>)
             None => sess.span_diagnostic.handler().fatal(msg),
         }
     };
-    let bytes = match io::result(|| File::open(path).read_to_end()) {
+    let bytes = match File::open(path).read_to_end() {
         Ok(bytes) => bytes,
         Err(e) => {
-            err(format!("couldn't read {}: {}", path.display(), e.desc));
+            err(format!("couldn't read {}: {}", path.display(), e));
             unreachable!()
         }
     };
diff --git a/src/libsyntax/parse/token.rs b/src/libsyntax/parse/token.rs
index 6d2acd3d803..f1dd844fc7c 100644
--- a/src/libsyntax/parse/token.rs
+++ b/src/libsyntax/parse/token.rs
@@ -588,8 +588,8 @@ impl BytesContainer for InternedString {
 }
 
 impl fmt::Show for InternedString {
-    fn fmt(obj: &InternedString, f: &mut fmt::Formatter) {
-        write!(f.buf, "{}", obj.string.as_slice());
+    fn fmt(obj: &InternedString, f: &mut fmt::Formatter) -> fmt::Result {
+        write!(f.buf, "{}", obj.string.as_slice())
     }
 }