Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 7828c3d

Browse files
committedOct 29, 2014
Rename fail! to panic!
rust-lang/rfcs#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]
1 parent 3bc5453 commit 7828c3d

File tree

505 files changed

+1623
-1618
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

505 files changed

+1623
-1618
lines changed
 

‎src/compiletest/compiletest.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ pub fn main() {
4141
let config = parse_config(args);
4242

4343
if config.valgrind_path.is_none() && config.force_valgrind {
44-
fail!("Can't find Valgrind to run Valgrind tests");
44+
panic!("Can't find Valgrind to run Valgrind tests");
4545
}
4646

4747
log_config(&config);
@@ -94,20 +94,20 @@ pub fn parse_config(args: Vec<String> ) -> Config {
9494
let message = format!("Usage: {} [OPTIONS] [TESTNAME...]", argv0);
9595
println!("{}", getopts::usage(message.as_slice(), groups.as_slice()));
9696
println!("");
97-
fail!()
97+
panic!()
9898
}
9999

100100
let matches =
101101
&match getopts::getopts(args_.as_slice(), groups.as_slice()) {
102102
Ok(m) => m,
103-
Err(f) => fail!("{}", f)
103+
Err(f) => panic!("{}", f)
104104
};
105105

106106
if matches.opt_present("h") || matches.opt_present("help") {
107107
let message = format!("Usage: {} [OPTIONS] [TESTNAME...]", argv0);
108108
println!("{}", getopts::usage(message.as_slice(), groups.as_slice()));
109109
println!("");
110-
fail!()
110+
panic!()
111111
}
112112

113113
fn opt_path(m: &getopts::Matches, nm: &str) -> Path {
@@ -120,7 +120,7 @@ pub fn parse_config(args: Vec<String> ) -> Config {
120120
Ok(re) => Some(re),
121121
Err(e) => {
122122
println!("failed to parse filter /{}/: {}", s, e);
123-
fail!()
123+
panic!()
124124
}
125125
}
126126
} else {
@@ -263,7 +263,7 @@ pub fn run_tests(config: &Config) {
263263
let res = test::run_tests_console(&opts, tests.into_iter().collect());
264264
match res {
265265
Ok(true) => {}
266-
Ok(false) => fail!("Some tests failed"),
266+
Ok(false) => panic!("Some tests failed"),
267267
Err(e) => {
268268
println!("I/O failure during tests: {}", e);
269269
}

‎src/compiletest/header.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -305,7 +305,7 @@ fn parse_exec_env(line: &str) -> Option<(String, String)> {
305305
let end = strs.pop().unwrap();
306306
(strs.pop().unwrap(), end)
307307
}
308-
n => fail!("Expected 1 or 2 strings, not {}", n)
308+
n => panic!("Expected 1 or 2 strings, not {}", n)
309309
}
310310
})
311311
}
@@ -350,7 +350,7 @@ pub fn gdb_version_to_int(version_string: &str) -> int {
350350
let components: Vec<&str> = version_string.trim().split('.').collect();
351351

352352
if components.len() != 2 {
353-
fail!("{}", error_string);
353+
panic!("{}", error_string);
354354
}
355355

356356
let major: int = FromStr::from_str(components[0]).expect(error_string);

0 commit comments

Comments
 (0)
Please sign in to comment.