about summary refs log tree commit diff
path: root/src/libregex/test
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/libregex/test
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/libregex/test')
-rw-r--r--src/libregex/test/bench.rs4
-rw-r--r--src/libregex/test/mod.rs2
-rw-r--r--src/libregex/test/tests.rs4
3 files changed, 5 insertions, 5 deletions
diff --git a/src/libregex/test/bench.rs b/src/libregex/test/bench.rs
index be8e12b09f0..e1c24a902fa 100644
--- a/src/libregex/test/bench.rs
+++ b/src/libregex/test/bench.rs
@@ -15,7 +15,7 @@ use stdtest::Bencher;
 use regex::{Regex, NoExpand};
 
 fn bench_assert_match(b: &mut Bencher, re: Regex, text: &str) {
-    b.iter(|| if !re.is_match(text) { fail!("no match") });
+    b.iter(|| if !re.is_match(text) { panic!("no match") });
 }
 
 #[bench]
@@ -143,7 +143,7 @@ macro_rules! throughput(
         fn $name(b: &mut Bencher) {
             let text = gen_text($size);
             b.bytes = $size;
-            b.iter(|| if $regex.is_match(text.as_slice()) { fail!("match") });
+            b.iter(|| if $regex.is_match(text.as_slice()) { panic!("match") });
         }
     );
 )
diff --git a/src/libregex/test/mod.rs b/src/libregex/test/mod.rs
index 96c600b0fda..7f014b4eb68 100644
--- a/src/libregex/test/mod.rs
+++ b/src/libregex/test/mod.rs
@@ -30,7 +30,7 @@ macro_rules! regex(
     ($re:expr) => (
         match ::regex::Regex::new($re) {
             Ok(re) => re,
-            Err(err) => fail!("{}", err),
+            Err(err) => panic!("{}", err),
         }
     );
 )
diff --git a/src/libregex/test/tests.rs b/src/libregex/test/tests.rs
index 088425c0888..f93a3d51251 100644
--- a/src/libregex/test/tests.rs
+++ b/src/libregex/test/tests.rs
@@ -75,7 +75,7 @@ macro_rules! noparse(
             let re = $re;
             match Regex::new(re) {
                 Err(_) => {},
-                Ok(_) => fail!("Regex '{}' should cause a parse error.", re),
+                Ok(_) => panic!("Regex '{}' should cause a parse error.", re),
             }
         }
     );
@@ -133,7 +133,7 @@ macro_rules! mat(
                 sgot = sgot[0..sexpect.len()]
             }
             if sexpect != sgot {
-                fail!("For RE '{}' against '{}', expected '{}' but got '{}'",
+                panic!("For RE '{}' against '{}', expected '{}' but got '{}'",
                       $re, text, sexpect, sgot);
             }
         }