about summary refs log tree commit diff
path: root/src/libsyntax/util/parser_testing.rs
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/util/parser_testing.rs
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/util/parser_testing.rs')
-rw-r--r--src/libsyntax/util/parser_testing.rs18
1 files changed, 9 insertions, 9 deletions
diff --git a/src/libsyntax/util/parser_testing.rs b/src/libsyntax/util/parser_testing.rs
index 58c2bed7a45..aa22f47221b 100644
--- a/src/libsyntax/util/parser_testing.rs
+++ b/src/libsyntax/util/parser_testing.rs
@@ -101,30 +101,30 @@ pub fn matches_codepattern(a : &str, b : &str) -> bool {
     let mut idx_a = 0;
     let mut idx_b = 0;
     loop {
-        if (idx_a == a.len() && idx_b == b.len()) {
+        if idx_a == a.len() && idx_b == b.len() {
             return true;
         }
-        else if (idx_a == a.len()) {return false;}
-        else if (idx_b == b.len()) {
+        else if idx_a == a.len() {return false;}
+        else if idx_b == b.len() {
             // maybe the stuff left in a is all ws?
-            if (is_whitespace(a.char_at(idx_a))) {
-                return (scan_for_non_ws_or_end(a,idx_a) == a.len());
+            if is_whitespace(a.char_at(idx_a)) {
+                return scan_for_non_ws_or_end(a,idx_a) == a.len();
             } else {
                 return false;
             }
         }
         // ws in both given and pattern:
-        else if (is_whitespace(a.char_at(idx_a))
-           && is_whitespace(b.char_at(idx_b))) {
+        else if is_whitespace(a.char_at(idx_a))
+           && is_whitespace(b.char_at(idx_b)) {
             idx_a = scan_for_non_ws_or_end(a,idx_a);
             idx_b = scan_for_non_ws_or_end(b,idx_b);
         }
         // ws in given only:
-        else if (is_whitespace(a.char_at(idx_a))) {
+        else if is_whitespace(a.char_at(idx_a)) {
             idx_a = scan_for_non_ws_or_end(a,idx_a);
         }
         // *don't* silently eat ws in expected only.
-        else if (a.char_at(idx_a) == b.char_at(idx_b)) {
+        else if a.char_at(idx_a) == b.char_at(idx_b) {
             idx_a += 1;
             idx_b += 1;
         }