about summary refs log tree commit diff
path: root/src/libstd/io/net/pipe.rs
diff options
context:
space:
mode:
authorSteve Klabnik <steve@steveklabnik.com>2014-10-09 15:17:22 -0400
committerSteve Klabnik <steve@steveklabnik.com>2014-10-29 11:43:07 -0400
commit7828c3dd2858d8f3a0448484d8093e22719dbda0 (patch)
tree2d2b106b02526219463d877d480782027ffe1f3f /src/libstd/io/net/pipe.rs
parent3bc545373df4c81ba223a8bece14cbc27eb85a4d (diff)
downloadrust-7828c3dd2858d8f3a0448484d8093e22719dbda0.tar.gz
rust-7828c3dd2858d8f3a0448484d8093e22719dbda0.zip
Rename fail! to panic!
https://github.com/rust-lang/rfcs/pull/221

The current terminology of "task failure" often causes problems when
writing or speaking about code. You often want to talk about the
possibility of an operation that returns a Result "failing", but cannot
because of the ambiguity with task failure. Instead, you have to speak
of "the failing case" or "when the operation does not succeed" or other
circumlocutions.

Likewise, we use a "Failure" header in rustdoc to describe when
operations may fail the task, but it would often be helpful to separate
out a section describing the "Err-producing" case.

We have been steadily moving away from task failure and toward Result as
an error-handling mechanism, so we should optimize our terminology
accordingly: Result-producing functions should be easy to describe.

To update your code, rename any call to `fail!` to `panic!` instead.
Assuming you have not created your own macro named `panic!`, this
will work on UNIX based systems:

    grep -lZR 'fail!' . | xargs -0 -l sed -i -e 's/fail!/panic!/g'

You can of course also do this by hand.

[breaking-change]
Diffstat (limited to 'src/libstd/io/net/pipe.rs')
-rw-r--r--src/libstd/io/net/pipe.rs28
1 files changed, 14 insertions, 14 deletions
diff --git a/src/libstd/io/net/pipe.rs b/src/libstd/io/net/pipe.rs
index e0cf761fdbd..112094d1d39 100644
--- a/src/libstd/io/net/pipe.rs
+++ b/src/libstd/io/net/pipe.rs
@@ -269,13 +269,13 @@ mod tests {
         spawn(proc() {
             match UnixStream::connect(&path2) {
                 Ok(c) => client(c),
-                Err(e) => fail!("failed connect: {}", e),
+                Err(e) => panic!("failed connect: {}", e),
             }
         });
 
         match acceptor.accept() {
             Ok(c) => server(c),
-            Err(e) => fail!("failed accept: {}", e),
+            Err(e) => panic!("failed accept: {}", e),
         }
     }
 
@@ -283,7 +283,7 @@ mod tests {
     fn bind_error() {
         let path = "path/to/nowhere";
         match UnixListener::bind(&path) {
-            Ok(..) => fail!(),
+            Ok(..) => panic!(),
             Err(e) => {
                 assert!(e.kind == PermissionDenied || e.kind == FileNotFound ||
                         e.kind == InvalidInput);
@@ -299,7 +299,7 @@ mod tests {
             "path/to/nowhere"
         };
         match UnixStream::connect(&path) {
-            Ok(..) => fail!(),
+            Ok(..) => panic!(),
             Err(e) => {
                 assert!(e.kind == FileNotFound || e.kind == OtherIoError);
             }
@@ -358,7 +358,7 @@ mod tests {
 
         let mut acceptor = match UnixListener::bind(&path1).listen() {
             Ok(a) => a,
-            Err(e) => fail!("failed listen: {}", e),
+            Err(e) => panic!("failed listen: {}", e),
         };
 
         spawn(proc() {
@@ -366,7 +366,7 @@ mod tests {
                 let mut stream = UnixStream::connect(&path2);
                 match stream.write([100]) {
                     Ok(..) => {}
-                    Err(e) => fail!("failed write: {}", e)
+                    Err(e) => panic!("failed write: {}", e)
                 }
             }
         });
@@ -376,7 +376,7 @@ mod tests {
             let mut buf = [0];
             match client.read(buf) {
                 Ok(..) => {}
-                Err(e) => fail!("failed read/accept: {}", e),
+                Err(e) => panic!("failed read/accept: {}", e),
             }
             assert_eq!(buf[0], 100);
         }
@@ -531,10 +531,10 @@ mod tests {
             match a.accept() {
                 Ok(..) => break,
                 Err(ref e) if e.kind == TimedOut => {}
-                Err(e) => fail!("error: {}", e),
+                Err(e) => panic!("error: {}", e),
             }
             ::task::deschedule();
-            if i == 1000 { fail!("should have a pending connection") }
+            if i == 1000 { panic!("should have a pending connection") }
         }
         drop(l);
 
@@ -659,9 +659,9 @@ mod tests {
             match s.write([0, .. 128 * 1024]) {
                 Ok(()) | Err(IoError { kind: ShortWrite(..), .. }) => {},
                 Err(IoError { kind: TimedOut, .. }) => break,
-                Err(e) => fail!("{}", e),
+                Err(e) => panic!("{}", e),
            }
-           if i == 1000 { fail!("should have filled up?!"); }
+           if i == 1000 { panic!("should have filled up?!"); }
         }
 
         // I'm not sure as to why, but apparently the write on windows always
@@ -687,7 +687,7 @@ mod tests {
             while amt < 100 * 128 * 1024 {
                 match s.read([0, ..128 * 1024]) {
                     Ok(n) => { amt += n; }
-                    Err(e) => fail!("{}", e),
+                    Err(e) => panic!("{}", e),
                 }
             }
             let _ = rx.recv_opt();
@@ -722,9 +722,9 @@ mod tests {
             match s.write([0, .. 128 * 1024]) {
                 Ok(()) | Err(IoError { kind: ShortWrite(..), .. }) => {},
                 Err(IoError { kind: TimedOut, .. }) => break,
-                Err(e) => fail!("{}", e),
+                Err(e) => panic!("{}", e),
            }
-           if i == 1000 { fail!("should have filled up?!"); }
+           if i == 1000 { panic!("should have filled up?!"); }
         }
 
         tx.send(());