Skip to content

Commit e8d0fec

Browse files
steveklabnikSimonSapin
authored andcommitted
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 9b24eb8 commit e8d0fec

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

src/libstd/ascii.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ impl<'a> fmt::Show for Ascii {
138138

139139
/// Trait for converting into an ascii type.
140140
pub trait AsciiCast<T> {
141-
/// Convert to an ascii type, fail on non-ASCII input.
141+
/// Convert to an ascii type, panic on non-ASCII input.
142142
#[inline]
143143
fn to_ascii(&self) -> T {
144144
assert!(self.is_ascii());
@@ -649,16 +649,16 @@ mod tests {
649649
}
650650

651651
#[test] #[should_fail]
652-
fn test_ascii_vec_fail_u8_slice() { (&[127u8, 128u8, 255u8]).to_ascii(); }
652+
fn test_ascii_vec_panic_u8_slice() { (&[127u8, 128u8, 255u8]).to_ascii(); }
653653

654654
#[test] #[should_fail]
655-
fn test_ascii_vec_fail_str_slice() { "zoä华".to_ascii(); }
655+
fn test_ascii_vec_panic_str_slice() { "zoä华".to_ascii(); }
656656

657657
#[test] #[should_fail]
658-
fn test_ascii_fail_u8_slice() { 255u8.to_ascii(); }
658+
fn test_ascii_panic_u8_slice() { 255u8.to_ascii(); }
659659

660660
#[test] #[should_fail]
661-
fn test_ascii_fail_char_slice() { 'λ'.to_ascii(); }
661+
fn test_ascii_panic_char_slice() { 'λ'.to_ascii(); }
662662

663663
#[test]
664664
fn test_opt() {

0 commit comments

Comments
 (0)