about summary refs log tree commit diff
path: root/src/libstd/io/net/tcp.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/tcp.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/tcp.rs')
-rw-r--r--src/libstd/io/net/tcp.rs26
1 files changed, 13 insertions, 13 deletions
diff --git a/src/libstd/io/net/tcp.rs b/src/libstd/io/net/tcp.rs
index d6528ce977e..09804ef5703 100644
--- a/src/libstd/io/net/tcp.rs
+++ b/src/libstd/io/net/tcp.rs
@@ -471,7 +471,7 @@ impl TcpAcceptor {
     ///         match socket {
     ///             Ok(s) => { /* handle s */ }
     ///             Err(ref e) if e.kind == EndOfFile => break, // closed
-    ///             Err(e) => fail!("unexpected error: {}", e),
+    ///             Err(e) => panic!("unexpected error: {}", e),
     ///         }
     ///     }
     /// });
@@ -532,7 +532,7 @@ mod test {
     #[test]
     fn bind_error() {
         match TcpListener::bind("0.0.0.0", 1) {
-            Ok(..) => fail!(),
+            Ok(..) => panic!(),
             Err(e) => assert_eq!(e.kind, PermissionDenied),
         }
     }
@@ -540,7 +540,7 @@ mod test {
     #[test]
     fn connect_error() {
         match TcpStream::connect("0.0.0.0", 1) {
-            Ok(..) => fail!(),
+            Ok(..) => panic!(),
             Err(e) => assert_eq!(e.kind, ConnectionRefused),
         }
     }
@@ -708,7 +708,7 @@ mod test {
         assert!(nread.is_err());
 
         match stream.read(buf) {
-            Ok(..) => fail!(),
+            Ok(..) => panic!(),
             Err(ref e) => {
                 assert!(e.kind == NotConnected || e.kind == EndOfFile,
                         "unknown kind: {}", e.kind);
@@ -734,7 +734,7 @@ mod test {
         assert!(nread.is_err());
 
         match stream.read(buf) {
-            Ok(..) => fail!(),
+            Ok(..) => panic!(),
             Err(ref e) => {
                 assert!(e.kind == NotConnected || e.kind == EndOfFile,
                         "unknown kind: {}", e.kind);
@@ -1082,7 +1082,7 @@ mod test {
         let listener = TcpListener::bind(ip_str.as_slice(), port).unwrap().listen();
         assert!(listener.is_ok());
         match TcpListener::bind(ip_str.as_slice(), port).listen() {
-            Ok(..) => fail!(),
+            Ok(..) => panic!(),
             Err(e) => {
                 assert!(e.kind == ConnectionRefused || e.kind == OtherIoError,
                         "unknown error: {} {}", e, e.kind);
@@ -1266,10 +1266,10 @@ mod test {
                 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") }
             }
         }
 
@@ -1373,9 +1373,9 @@ mod test {
             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?!"); }
         }
         assert_eq!(s.write([0]).err().unwrap().kind, TimedOut);
 
@@ -1398,7 +1398,7 @@ mod test {
             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();
@@ -1435,9 +1435,9 @@ mod test {
             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?!"); }
         }
         assert_eq!(s.write([0]).err().unwrap().kind, TimedOut);