diff options
| author | Steve Klabnik <steve@steveklabnik.com> | 2014-10-09 15:17:22 -0400 |
|---|---|---|
| committer | Steve Klabnik <steve@steveklabnik.com> | 2014-10-29 11:43:07 -0400 |
| commit | 7828c3dd2858d8f3a0448484d8093e22719dbda0 (patch) | |
| tree | 2d2b106b02526219463d877d480782027ffe1f3f /src/test/bench | |
| parent | 3bc545373df4c81ba223a8bece14cbc27eb85a4d (diff) | |
| download | rust-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/test/bench')
| -rw-r--r-- | src/test/bench/core-std.rs | 4 | ||||
| -rw-r--r-- | src/test/bench/shootout-chameneos-redux.rs | 2 | ||||
| -rw-r--r-- | src/test/bench/shootout-k-nucleotide.rs | 2 | ||||
| -rw-r--r-- | src/test/bench/shootout-meteor.rs | 2 | ||||
| -rw-r--r-- | src/test/bench/shootout-pfib.rs | 2 | ||||
| -rw-r--r-- | src/test/bench/sudoku.rs | 4 | ||||
| -rw-r--r-- | src/test/bench/task-perf-alloc-unwind.rs | 8 | ||||
| -rw-r--r-- | src/test/bench/task-perf-jargon-metal-smoke.rs | 2 |
8 files changed, 13 insertions, 13 deletions
diff --git a/src/test/bench/core-std.rs b/src/test/bench/core-std.rs index 404e2e31b05..39057215b5e 100644 --- a/src/test/bench/core-std.rs +++ b/src/test/bench/core-std.rs @@ -145,7 +145,7 @@ fn is_utf8_ascii() { for _ in range(0u, 20000) { v.push('b' as u8); if !str::is_utf8(v.as_slice()) { - fail!("is_utf8 failed"); + panic!("is_utf8 panicked"); } } } @@ -156,7 +156,7 @@ fn is_utf8_multibyte() { for _ in range(0u, 5000) { v.push_all(s.as_bytes()); if !str::is_utf8(v.as_slice()) { - fail!("is_utf8 failed"); + panic!("is_utf8 panicked"); } } } diff --git a/src/test/bench/shootout-chameneos-redux.rs b/src/test/bench/shootout-chameneos-redux.rs index 4ed0de2a138..abcd9f90333 100644 --- a/src/test/bench/shootout-chameneos-redux.rs +++ b/src/test/bench/shootout-chameneos-redux.rs @@ -90,7 +90,7 @@ fn show_digit(nn: uint) -> &'static str { 7 => {" seven"} 8 => {" eight"} 9 => {" nine"} - _ => {fail!("expected digits from 0 to 9...")} + _ => {panic!("expected digits from 0 to 9...")} } } diff --git a/src/test/bench/shootout-k-nucleotide.rs b/src/test/bench/shootout-k-nucleotide.rs index 1799504eb47..d0e6aacdbb2 100644 --- a/src/test/bench/shootout-k-nucleotide.rs +++ b/src/test/bench/shootout-k-nucleotide.rs @@ -225,7 +225,7 @@ fn pack_symbol(c: u8) -> u8 { 'C' => 1, 'G' => 2, 'T' => 3, - _ => fail!("{}", c as char), + _ => panic!("{}", c as char), } } diff --git a/src/test/bench/shootout-meteor.rs b/src/test/bench/shootout-meteor.rs index 8e837864185..6e80c07a1a2 100644 --- a/src/test/bench/shootout-meteor.rs +++ b/src/test/bench/shootout-meteor.rs @@ -207,7 +207,7 @@ fn get_id(m: u64) -> u8 { for id in range(0u8, 10) { if m & (1 << (id + 50) as uint) != 0 {return id;} } - fail!("{:016x} does not have a valid identifier", m); + panic!("{:016x} does not have a valid identifier", m); } // Converts a list of mask to a Vec<u8>. diff --git a/src/test/bench/shootout-pfib.rs b/src/test/bench/shootout-pfib.rs index 91b9e058e8f..425b2e3e714 100644 --- a/src/test/bench/shootout-pfib.rs +++ b/src/test/bench/shootout-pfib.rs @@ -61,7 +61,7 @@ fn parse_opts(argv: Vec<String> ) -> Config { Ok(ref m) => { return Config {stress: m.opt_present("stress")} } - Err(_) => { fail!(); } + Err(_) => { panic!(); } } } diff --git a/src/test/bench/sudoku.rs b/src/test/bench/sudoku.rs index 01c412c6d31..ae7594ea8a2 100644 --- a/src/test/bench/sudoku.rs +++ b/src/test/bench/sudoku.rs @@ -83,7 +83,7 @@ impl Sudoku { from_str::<uint>(comps[2]).unwrap() as u8; } else { - fail!("Invalid sudoku file"); + panic!("Invalid sudoku file"); } } return Sudoku::new(g) @@ -123,7 +123,7 @@ impl Sudoku { ptr = ptr + 1u; } else { // no: redo this field aft recoloring pred; unless there is none - if ptr == 0u { fail!("No solution found for this sudoku"); } + if ptr == 0u { panic!("No solution found for this sudoku"); } ptr = ptr - 1u; } } diff --git a/src/test/bench/task-perf-alloc-unwind.rs b/src/test/bench/task-perf-alloc-unwind.rs index bdeee5fb6e0..5d96c90197c 100644 --- a/src/test/bench/task-perf-alloc-unwind.rs +++ b/src/test/bench/task-perf-alloc-unwind.rs @@ -39,7 +39,7 @@ fn run(repeat: int, depth: int) { for _ in range(0, repeat) { println!("starting {:.4f}", precise_time_s()); task::try(proc() { - recurse_or_fail(depth, None) + recurse_or_panic(depth, None) }); println!("stopping {:.4f}", precise_time_s()); } @@ -70,10 +70,10 @@ fn r(l: Box<nillist>) -> r { } } -fn recurse_or_fail(depth: int, st: Option<State>) { +fn recurse_or_panic(depth: int, st: Option<State>) { if depth == 0 { println!("unwinding {:.4f}", precise_time_s()); - fail!(); + panic!(); } else { let depth = depth - 1; @@ -96,6 +96,6 @@ fn recurse_or_fail(depth: int, st: Option<State>) { } }; - recurse_or_fail(depth, Some(st)); + recurse_or_panic(depth, Some(st)); } } diff --git a/src/test/bench/task-perf-jargon-metal-smoke.rs b/src/test/bench/task-perf-jargon-metal-smoke.rs index 9ebdbf0682d..3d2822e1459 100644 --- a/src/test/bench/task-perf-jargon-metal-smoke.rs +++ b/src/test/bench/task-perf-jargon-metal-smoke.rs @@ -51,6 +51,6 @@ fn main() { let (tx, rx) = channel(); child_generation(from_str::<uint>(args[1].as_slice()).unwrap(), tx); if rx.recv_opt().is_err() { - fail!("it happened when we slumbered"); + panic!("it happened when we slumbered"); } } |
