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]
This commit is contained in:
@@ -117,7 +117,7 @@ impl BuildAst {
|
||||
fn flags(&self) -> Flags {
|
||||
match *self {
|
||||
Paren(flags, _, _) => flags,
|
||||
_ => fail!("Cannot get flags from {}", self),
|
||||
_ => panic!("Cannot get flags from {}", self),
|
||||
}
|
||||
}
|
||||
|
||||
@@ -125,7 +125,7 @@ impl BuildAst {
|
||||
match *self {
|
||||
Paren(_, 0, _) => None,
|
||||
Paren(_, c, _) => Some(c),
|
||||
_ => fail!("Cannot get capture group from {}", self),
|
||||
_ => panic!("Cannot get capture group from {}", self),
|
||||
}
|
||||
}
|
||||
|
||||
@@ -139,7 +139,7 @@ impl BuildAst {
|
||||
Some(name.clone())
|
||||
}
|
||||
}
|
||||
_ => fail!("Cannot get capture name from {}", self),
|
||||
_ => panic!("Cannot get capture name from {}", self),
|
||||
}
|
||||
}
|
||||
|
||||
@@ -153,7 +153,7 @@ impl BuildAst {
|
||||
fn unwrap(self) -> Result<Ast, Error> {
|
||||
match self {
|
||||
Expr(x) => Ok(x),
|
||||
_ => fail!("Tried to unwrap non-AST item: {}", self),
|
||||
_ => panic!("Tried to unwrap non-AST item: {}", self),
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -321,7 +321,7 @@ impl<'a> Parser<'a> {
|
||||
}
|
||||
let rep: Repeater = match c {
|
||||
'?' => ZeroOne, '*' => ZeroMore, '+' => OneMore,
|
||||
_ => fail!("Not a valid repeater operator."),
|
||||
_ => panic!("Not a valid repeater operator."),
|
||||
};
|
||||
|
||||
match self.peek(1) {
|
||||
@@ -393,7 +393,7 @@ impl<'a> Parser<'a> {
|
||||
continue
|
||||
}
|
||||
Some(ast) =>
|
||||
fail!("Expected Class AST but got '{}'", ast),
|
||||
panic!("Expected Class AST but got '{}'", ast),
|
||||
// Just drop down and try to add as a regular character.
|
||||
None => {},
|
||||
},
|
||||
@@ -408,7 +408,7 @@ impl<'a> Parser<'a> {
|
||||
return self.err(
|
||||
"\\A, \\z, \\b and \\B are not valid escape \
|
||||
sequences inside a character class."),
|
||||
ast => fail!("Unexpected AST item '{}'", ast),
|
||||
ast => panic!("Unexpected AST item '{}'", ast),
|
||||
}
|
||||
}
|
||||
_ => {},
|
||||
|
||||
Reference in New Issue
Block a user