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:
Steve Klabnik 2014-10-09 15:17:22 -04:00
parent 3bc545373d
commit 7828c3dd28
505 changed files with 1623 additions and 1618 deletions

View file

@ -38,7 +38,7 @@ pub fn alist_get<A:Clone + 'static,
return entry.value.clone();
}
}
fail!();
panic!();
}
#[inline]

View file

@ -10,5 +10,5 @@
pub unsafe fn f(xs: Vec<int> ) {
xs.iter().map(|_x| { unsafe fn q() { fail!(); } }).collect::<Vec<()>>();
xs.iter().map(|_x| { unsafe fn q() { panic!(); } }).collect::<Vec<()>>();
}

View file

@ -12,6 +12,6 @@
#[phase(plugin, link)] extern crate log;
pub fn foo<T>() {
fn death() -> int { fail!() }
fn death() -> int { panic!() }
debug!("{}", (||{ death() })());
}

View file

@ -36,7 +36,7 @@ pub trait IntoMaybeOwned<'a> {
}
impl<'a> IntoMaybeOwned<'a> for Inv<'a> {
fn into_maybe_owned(self) -> MaybeOwned<'a> { fail!() }
fn into_inv(self) -> Inv<'a> { fail!() }
fn bigger_region<'b:'a>(self, b: Inv<'b>) { fail!() }
fn into_maybe_owned(self) -> MaybeOwned<'a> { panic!() }
fn into_inv(self) -> Inv<'a> { panic!() }
fn bigger_region<'b:'a>(self, b: Inv<'b>) { panic!() }
}

View file

@ -36,6 +36,6 @@ impl read for bool {
pub fn read<T:read>(s: String) -> T {
match read::readMaybe(s) {
Some(x) => x,
_ => fail!("read failed!")
_ => panic!("read panicked!")
}
}

View file

@ -28,7 +28,7 @@ impl core::ops::Drop for A {
pub fn foo() {
let _a = A;
fail!("wut");
panic!("wut");
}
mod std {

View file

@ -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");
}
}
}

View file

@ -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...")}
}
}

View file

@ -225,7 +225,7 @@ fn pack_symbol(c: u8) -> u8 {
'C' => 1,
'G' => 2,
'T' => 3,
_ => fail!("{}", c as char),
_ => panic!("{}", c as char),
}
}

View file

@ -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>.

View file

@ -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!(); }
}
}

View file

@ -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;
}
}

View file

@ -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));
}
}

View file

@ -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");
}
}

View file

@ -11,7 +11,7 @@
// Tests that a function with a ! annotation always actually fails
fn bad_bang(i: uint) -> ! { //~ ERROR computation may converge in a function marked as diverging
if i < 0u { } else { fail!(); }
if i < 0u { } else { panic!(); }
}
fn main() { bad_bang(5u); }

View file

@ -20,6 +20,6 @@ fn main() {
let x = Some((X { x: () }, X { x: () }));
match x {
Some((ref _y, _z)) => { }, //~ ERROR cannot bind by-move and by-ref in the same pattern
None => fail!()
None => panic!()
}
}

View file

@ -22,6 +22,6 @@ fn main() {
let x = some2(X { x: () }, X { x: () });
match x {
some2(ref _y, _z) => { }, //~ ERROR cannot bind by-move and by-ref in the same pattern
none2 => fail!()
none2 => panic!()
}
}

View file

@ -20,6 +20,6 @@ fn main() {
let x = Some((X { x: () }, X { x: () }));
match x {
Some((_y, ref _z)) => { }, //~ ERROR cannot bind by-move and by-ref in the same pattern
None => fail!()
None => panic!()
}
}

View file

@ -13,8 +13,8 @@ fn main() {
let x = Some(rx);
tx.send(false);
match x {
Some(z) if z.recv() => { fail!() }, //~ ERROR cannot bind by-move into a pattern guard
Some(z) if z.recv() => { panic!() }, //~ ERROR cannot bind by-move into a pattern guard
Some(z) => { assert!(!z.recv()); },
None => fail!()
None => panic!()
}
}

View file

@ -20,12 +20,12 @@ fn distinct_variant() {
let a = match y {
Y(ref mut a, _) => a,
X => fail!()
X => panic!()
};
let b = match y {
Y(_, ref mut b) => b,
X => fail!()
X => panic!()
};
*a += 1;
@ -37,12 +37,12 @@ fn same_variant() {
let a = match y {
Y(ref mut a, _) => a,
X => fail!()
X => panic!()
};
let b = match y {
Y(ref mut b, _) => b, //~ ERROR cannot borrow
X => fail!()
X => panic!()
};
*a += 1;

View file

@ -28,7 +28,7 @@ fn main() {
x = X(Left((0,0)));
(*f)()
},
_ => fail!()
_ => panic!()
}
})
}

View file

@ -19,7 +19,7 @@ struct Bar {
int2: int,
}
fn make_foo() -> Box<Foo> { fail!() }
fn make_foo() -> Box<Foo> { panic!() }
fn borrow_same_field_twice_mut_mut() {
let mut foo = make_foo();

View file

@ -18,7 +18,7 @@ struct Bar {
int2: int,
}
fn make_foo() -> Foo { fail!() }
fn make_foo() -> Foo { panic!() }
fn borrow_same_field_twice_mut_mut() {
let mut foo = make_foo();

View file

@ -43,7 +43,7 @@ fn d(x: &mut int) {
}
fn e(x: &mut int) {
let c1: || = || x = fail!(); //~ ERROR closure cannot assign to immutable local variable
let c1: || = || x = panic!(); //~ ERROR closure cannot assign to immutable local variable
}
fn main() {

View file

@ -17,9 +17,9 @@
fn borrow(_v: &int) {}
fn borrow_mut(_v: &mut int) {}
fn cond() -> bool { fail!() }
fn for_func(_f: || -> bool) { fail!() }
fn produce<T>() -> T { fail!(); }
fn cond() -> bool { panic!() }
fn for_func(_f: || -> bool) { panic!() }
fn produce<T>() -> T { panic!(); }
fn inc(v: &mut Box<int>) {
*v = box() (**v + 1);

View file

@ -17,8 +17,8 @@
fn borrow(_v: &int) {}
fn borrow_mut(_v: &mut int) {}
fn cond() -> bool { fail!() }
fn produce<T>() -> T { fail!(); }
fn cond() -> bool { panic!() }
fn produce<T>() -> T { panic!(); }
fn inc(v: &mut Box<int>) {
*v = box() (**v + 1);

View file

@ -17,9 +17,9 @@
fn borrow(_v: &int) {}
fn borrow_mut(_v: &mut int) {}
fn cond() -> bool { fail!() }
fn for_func(_f: || -> bool) { fail!() }
fn produce<T>() -> T { fail!(); }
fn cond() -> bool { panic!() }
fn for_func(_f: || -> bool) { panic!() }
fn produce<T>() -> T { panic!(); }
fn inc(v: &mut Box<int>) {
*v = box() (**v + 1);

View file

@ -16,7 +16,7 @@ enum Either<T, U> { Left(T), Right(U) }
*x = Right(1.0);
*z
}
_ => fail!()
_ => panic!()
}
}

View file

@ -14,7 +14,7 @@ fn main() {
Some(ref m) => { //~ ERROR borrowed value does not live long enough
msg = m;
},
None => { fail!() }
None => { panic!() }
}
println!("{}", *msg);
}

View file

@ -15,7 +15,7 @@ fn a<'a>() -> &'a [int] {
let vec: &[int] = vec.as_slice(); //~ ERROR does not live long enough
let tail = match vec {
[_, tail..] => tail,
_ => fail!("a")
_ => panic!("a")
};
tail
}
@ -25,7 +25,7 @@ fn b<'a>() -> &'a [int] {
let vec: &[int] = vec.as_slice(); //~ ERROR does not live long enough
let init = match vec {
[init.., _] => init,
_ => fail!("b")
_ => panic!("b")
};
init
}
@ -35,7 +35,7 @@ fn c<'a>() -> &'a [int] {
let vec: &[int] = vec.as_slice(); //~ ERROR does not live long enough
let slice = match vec {
[_, slice.., _] => slice,
_ => fail!("c")
_ => panic!("c")
};
slice
}

View file

@ -13,7 +13,7 @@ fn a<'a>() -> &'a int {
let vec: &[int] = vec.as_slice(); //~ ERROR `vec` does not live long enough
let tail = match vec {
[_a, tail..] => &tail[0],
_ => fail!("foo")
_ => panic!("foo")
};
tail
}

View file

@ -12,8 +12,8 @@ fn foo(f: || -> !) {}
fn main() {
// Type inference didn't use to be able to handle this:
foo(|| fail!());
foo(|| -> ! fail!());
foo(|| panic!());
foo(|| -> ! panic!());
foo(|| 22i); //~ ERROR computation may converge in a function marked as diverging
foo(|| -> ! 22i); //~ ERROR computation may converge in a function marked as diverging
let x = || -> ! 1i; //~ ERROR computation may converge in a function marked as diverging

View file

@ -20,7 +20,7 @@ trait MyTrait<T> {
impl<T> MyTrait<T> for T { //~ ERROR E0119
fn get(&self) -> T {
fail!()
panic!()
}
}

View file

@ -11,7 +11,7 @@
#![deny(unreachable_code)]
fn main() {
let x: || -> ! = || fail!();
let x: || -> ! = || panic!();
x();
println!("Foo bar"); //~ ERROR: unreachable statement
}

View file

@ -10,6 +10,6 @@
fn main() {
match *1 { //~ ERROR: cannot be dereferenced
_ => { fail!(); }
_ => { panic!(); }
}
}

View file

@ -18,11 +18,11 @@
fn foo() { //~ ERROR function is never used
// none of these should have any dead_code exposed to the user
fail!();
panic!();
fail!("foo");
panic!("foo");
fail!("bar {}", "baz")
panic!("bar {}", "baz")
}

View file

@ -14,11 +14,11 @@
fn foo() { //~ ERROR function is never used
// none of these should have any dead_code exposed to the user
fail!();
panic!();
fail!("foo");
panic!("foo");
fail!("bar {}", "baz")
panic!("bar {}", "baz")
}

View file

@ -11,5 +11,5 @@
// error-pattern:unexpected token
fn main() {
fail!(@);
panic!(@);
}

View file

@ -23,7 +23,7 @@ trait Foo<'a> {
}
impl<'a> Foo<'a> for &'a str {
fn bar<T: Bar<'a>>(self) -> &'a str { fail!() } //~ ERROR lifetime
fn bar<T: Bar<'a>>(self) -> &'a str { panic!() } //~ ERROR lifetime
}
fn main() {

View file

@ -10,7 +10,7 @@
struct A { foo: int }
fn a() -> A { fail!() }
fn a() -> A { panic!() }
fn main() {
let A { .., } = a(); //~ ERROR: expected `}`

View file

@ -10,7 +10,7 @@
struct A { foo: int }
fn a() -> A { fail!() }
fn a() -> A { panic!() }
fn main() {
let A { , } = a(); //~ ERROR: expected ident

View file

@ -13,7 +13,7 @@ fn main() {
match a {
Ok(a) => //~ ERROR: mismatched types
println!("{}",a),
None => fail!()
None => panic!()
}
}

View file

@ -18,7 +18,7 @@ fn tail(source_list: &IntList) -> IntList {
&Cons(val, box ref next_list) => tail(next_list),
&Cons(val, box Nil) => Cons(val, box Nil),
//~^ ERROR: unreachable pattern
_ => fail!()
_ => panic!()
}
}

View file

@ -9,7 +9,7 @@
// except according to those terms.
fn new<T>() -> &'static T {
fail!()
panic!()
}
fn main() {

View file

@ -9,7 +9,7 @@
// except according to those terms.
fn new<'r, T>() -> &'r T {
fail!()
panic!()
}
fn main() {

View file

@ -16,6 +16,6 @@ pub fn main() {
// tricked into looking up a non-existing second type parameter.
let _x: uint = match Some(1u) {
Ok(u) => u, //~ ERROR mismatched types: expected `core::option::Option<uint>`
Err(e) => fail!(e) //~ ERROR mismatched types: expected `core::option::Option<uint>`
Err(e) => panic!(e) //~ ERROR mismatched types: expected `core::option::Option<uint>`
};
}

View file

@ -15,7 +15,7 @@ trait vec_monad<A> {
impl<A> vec_monad<A> for Vec<A> {
fn bind<B>(&self, f: |A| -> Vec<B> ) {
let mut r = fail!();
let mut r = panic!();
for elt in self.iter() { r = r + f(*elt); }
//~^ ERROR the type of this value must be known
//~^^ ERROR not implemented

View file

@ -14,7 +14,7 @@
fn fail_len(v: Vec<int> ) -> uint {
let mut i = 3;
fail!();
panic!();
for x in v.iter() { i += 1u; }
//~^ ERROR: unreachable statement
return i;

View file

@ -9,6 +9,6 @@
// except according to those terms.
fn main() {
let x = fail!();
let x = panic!();
x.clone(); //~ ERROR the type of this value must be known in this context
}

View file

@ -16,7 +16,7 @@ trait channel<T> {
// `chan` is not a trait, it's an enum
impl chan for int { //~ ERROR `chan` is not a trait
fn send(&self, v: int) { fail!() }
fn send(&self, v: int) { panic!() }
}
fn main() {

View file

@ -10,8 +10,8 @@
fn foo() { //~ NOTE Did you mean to close this delimiter?
match Some(x) {
Some(y) { fail!(); }
None { fail!(); }
Some(y) { panic!(); }
None { panic!(); }
}
fn bar() {

View file

@ -20,7 +20,7 @@ struct E {
}
impl A for E {
fn b<F: Sync, G>(_x: F) -> F { fail!() } //~ ERROR type parameter 0 requires `Sync`
fn b<F: Sync, G>(_x: F) -> F { panic!() } //~ ERROR type parameter 0 requires `Sync`
}
fn main() {}

View file

@ -21,7 +21,7 @@ struct E {
impl A for E {
// n.b. The error message is awful -- see #3404
fn b<F:Clone,G>(&self, _x: G) -> G { fail!() } //~ ERROR method `b` has an incompatible type
fn b<F:Clone,G>(&self, _x: G) -> G { panic!() } //~ ERROR method `b` has an incompatible type
}
fn main() {}

View file

@ -23,7 +23,7 @@ fn siphash(k0 : u64) -> SipHash {
//~^ ERROR unresolved name `k0`.
}
}
fail!();
panic!();
}
fn main() {}

View file

@ -38,6 +38,6 @@ fn main() {
box Element(ed) => match ed.kind { //~ ERROR non-exhaustive patterns
box HTMLImageElement(ref d) if d.image.is_some() => { true }
},
_ => fail!("WAT") //~ ERROR unreachable pattern
_ => panic!("WAT") //~ ERROR unreachable pattern
};
}

View file

@ -17,7 +17,7 @@ impl PTrait for P {
fn getChildOption(&self) -> Option<Box<P>> {
static childVal: Box<P> = self.child.get();
//~^ ERROR attempt to use a non-constant value in a constant
fail!();
panic!();
}
}

View file

@ -16,5 +16,5 @@ fn main() {
let a = 5;
let _iter = TrieMapIterator{node: &a};
_iter.node = & //~ ERROR cannot assign to immutable field
fail!()
panic!()
}

View file

@ -9,5 +9,5 @@
// except according to those terms.
fn foo<T>(t: T) {}
fn main() { foo(fail!()) }
fn main() { foo(panic!()) }
//~^ ERROR type annotations required

View file

@ -10,7 +10,7 @@
#![deny(unreachable_code)]
fn g() -> ! { fail!(); }
fn g() -> ! { panic!(); }
fn f() -> ! {
return g(); //~ ERROR `return` in a function declared as diverging
g();

View file

@ -11,8 +11,8 @@
#![deny(unreachable_code)]
fn f() -> ! {
return fail!(); //~ ERROR `return` in a function declared as diverging
fail!(); // the unreachable statement error is in <std macro>, at this line, there
return panic!(); //~ ERROR `return` in a function declared as diverging
panic!(); // the unreachable statement error is in <std macro>, at this line, there
// only is a note
}

View file

@ -11,13 +11,13 @@
// Lifetime annotation needed because we have no arguments.
fn f() -> &int { //~ ERROR missing lifetime specifier
//~^ NOTE there is no value for it to be borrowed from
fail!()
panic!()
}
// Lifetime annotation needed because we have two by-reference parameters.
fn g(_x: &int, _y: &int) -> &int { //~ ERROR missing lifetime specifier
//~^ NOTE the signature does not say whether it is borrowed from `_x` or `_y`
fail!()
panic!()
}
struct Foo<'a> {
@ -28,7 +28,7 @@ struct Foo<'a> {
// and one on the reference.
fn h(_x: &Foo) -> &int { //~ ERROR missing lifetime specifier
//~^ NOTE the signature does not say which one of `_x`'s 2 elided lifetimes it is borrowed from
fail!()
panic!()
}
fn main() {}

View file

@ -20,7 +20,7 @@ mod foo {
}
}
fn callback<T>(_f: || -> T) -> T { fail!() }
fn callback<T>(_f: || -> T) -> T { panic!() }
unsafe fn unsf() {}
fn bad1() { unsafe {} } //~ ERROR: unnecessary `unsafe` block
@ -50,7 +50,7 @@ fn good2() {
sure that when purity is inherited that the source of the unsafe-ness
is tracked correctly */
unsafe {
unsafe fn what() -> Vec<String> { fail!() }
unsafe fn what() -> Vec<String> { panic!() }
callback(|| {
what();

View file

@ -17,27 +17,27 @@ struct Private<T>;
pub struct Public<T>;
impl Private<Public<int>> {
pub fn a(&self) -> Private<int> { fail!() }
fn b(&self) -> Private<int> { fail!() }
pub fn a(&self) -> Private<int> { panic!() }
fn b(&self) -> Private<int> { panic!() }
pub fn c() -> Private<int> { fail!() }
fn d() -> Private<int> { fail!() }
pub fn c() -> Private<int> { panic!() }
fn d() -> Private<int> { panic!() }
}
impl Private<int> {
pub fn e(&self) -> Private<int> { fail!() }
fn f(&self) -> Private<int> { fail!() }
pub fn e(&self) -> Private<int> { panic!() }
fn f(&self) -> Private<int> { panic!() }
}
impl Public<Private<int>> {
pub fn a(&self) -> Private<int> { fail!() }
fn b(&self) -> Private<int> { fail!() }
pub fn a(&self) -> Private<int> { panic!() }
fn b(&self) -> Private<int> { panic!() }
pub fn c() -> Private<int> { fail!() } //~ ERROR private type in exported type signature
fn d() -> Private<int> { fail!() }
pub fn c() -> Private<int> { panic!() } //~ ERROR private type in exported type signature
fn d() -> Private<int> { panic!() }
}
impl Public<int> {
pub fn e(&self) -> Private<int> { fail!() } //~ ERROR private type in exported type signature
fn f(&self) -> Private<int> { fail!() }
pub fn e(&self) -> Private<int> { panic!() } //~ ERROR private type in exported type signature
fn f(&self) -> Private<int> { panic!() }
}
pub fn x(_: Private<int>) {} //~ ERROR private type in exported type signature
@ -70,39 +70,39 @@ enum Qux {
}
pub trait PubTrait {
fn foo(&self) -> Private<int> { fail!( )} //~ ERROR private type in exported type signature
fn foo(&self) -> Private<int> { panic!( )} //~ ERROR private type in exported type signature
fn bar(&self) -> Private<int>; //~ ERROR private type in exported type signature
fn baz() -> Private<int>; //~ ERROR private type in exported type signature
}
impl PubTrait for Public<int> {
fn bar(&self) -> Private<int> { fail!() }
fn baz() -> Private<int> { fail!() }
fn bar(&self) -> Private<int> { panic!() }
fn baz() -> Private<int> { panic!() }
}
impl PubTrait for Public<Private<int>> {
fn bar(&self) -> Private<int> { fail!() }
fn baz() -> Private<int> { fail!() }
fn bar(&self) -> Private<int> { panic!() }
fn baz() -> Private<int> { panic!() }
}
impl PubTrait for Private<int> {
fn bar(&self) -> Private<int> { fail!() }
fn baz() -> Private<int> { fail!() }
fn bar(&self) -> Private<int> { panic!() }
fn baz() -> Private<int> { panic!() }
}
impl PubTrait for (Private<int>,) {
fn bar(&self) -> Private<int> { fail!() }
fn baz() -> Private<int> { fail!() }
fn bar(&self) -> Private<int> { panic!() }
fn baz() -> Private<int> { panic!() }
}
trait PrivTrait {
fn foo(&self) -> Private<int> { fail!( )}
fn foo(&self) -> Private<int> { panic!( )}
fn bar(&self) -> Private<int>;
}
impl PrivTrait for Private<int> {
fn bar(&self) -> Private<int> { fail!() }
fn bar(&self) -> Private<int> { panic!() }
}
impl PrivTrait for (Private<int>,) {
fn bar(&self) -> Private<int> { fail!() }
fn bar(&self) -> Private<int> { panic!() }
}
pub trait ParamTrait<T> {
@ -111,14 +111,14 @@ pub trait ParamTrait<T> {
impl ParamTrait<Private<int>> //~ ERROR private type in exported type signature
for Public<int> {
fn foo() -> Private<int> { fail!() }
fn foo() -> Private<int> { panic!() }
}
impl ParamTrait<Private<int>> for Private<int> {
fn foo() -> Private<int> { fail!( )}
fn foo() -> Private<int> { panic!( )}
}
impl<T: ParamTrait<Private<int>>> //~ ERROR private type in exported type signature
ParamTrait<T> for Public<i8> {
fn foo() -> T { fail!() }
fn foo() -> T { panic!() }
}

View file

@ -11,7 +11,7 @@
fn send<T:Send + std::fmt::Show>(ch: _chan<T>, data: T) {
println!("{}", ch);
println!("{}", data);
fail!();
panic!();
}
#[deriving(Show)]
@ -24,4 +24,4 @@ fn test00_start(ch: _chan<Box<int>>, message: Box<int>, _count: Box<int>) {
println!("{}", message); //~ ERROR use of moved value: `message`
}
fn main() { fail!(); }
fn main() { panic!(); }

View file

@ -11,10 +11,10 @@
// a good test that we merge paths correctly in the presence of a
// variable that's used before it's declared
fn my_fail() -> ! { fail!(); }
fn my_panic() -> ! { panic!(); }
fn main() {
match true { false => { my_fail(); } true => { } }
match true { false => { my_panic(); } true => { } }
println!("{}", x); //~ ERROR unresolved name `x`.
let x: int;

View file

@ -13,7 +13,7 @@
struct Foo<A> { f: A }
fn guard(_s: String) -> bool {fail!()}
fn guard(_s: String) -> bool {panic!()}
fn touch<A>(_a: &A) {}
fn f10() {

View file

@ -13,7 +13,7 @@
// terms of the binding, not the discriminant.
struct Foo<A> { f: A }
fn guard(_s: String) -> bool {fail!()}
fn guard(_s: String) -> bool {panic!()}
fn touch<A>(_a: &A) {}
fn f10() {

View file

@ -31,7 +31,7 @@ fn innocent_looking_victim() {
//~^ ERROR: cannot borrow `*f` as mutable because
println!("{}", msg);
},
None => fail!("oops"),
None => panic!("oops"),
}
}
})

View file

@ -23,7 +23,7 @@ fn match_nested_vecs<'a, T>(l1: Option<&'a [T]>, l2: Result<&'a [T], ()>) -> &'s
fn main() {
let x = a(c);
match x { //~ ERROR non-exhaustive patterns: `a(c)` not covered
a(d) => { fail!("hello"); }
b => { fail!("goodbye"); }
a(d) => { panic!("hello"); }
b => { panic!("goodbye"); }
}
}

View file

@ -13,7 +13,7 @@
// unrelated errors.
fn foo(a: int, b: int, c: int, d:int) {
fail!();
panic!();
}
fn main() {

View file

@ -11,7 +11,7 @@
enum bar { t1((), Option<Vec<int>>), t2, }
// n.b. my change changes this error message, but I think it's right -- tjc
fn foo(t: bar) -> int { match t { t1(_, Some(x)) => { return x * 3; } _ => { fail!(); } } }
fn foo(t: bar) -> int { match t { t1(_, Some(x)) => { return x * 3; } _ => { panic!(); } } }
//~^ ERROR binary operation `*` cannot be applied to
fn main() { }

View file

@ -17,7 +17,7 @@ fn foo(t: bar) {
t1(_, Some::<int>(x)) => {
println!("{}", x);
}
_ => { fail!(); }
_ => { panic!(); }
}
}

View file

@ -64,5 +64,5 @@ fn main() {
}
fn check_pp<T>(expr: T, f: |pprust::ps, T|, expect: str) {
fail!();
panic!();
}

View file

@ -57,5 +57,5 @@ fn main() {
}
fn check_pp<T>(expr: T, f: |pprust::ps, T|, expect: str) {
fail!();
panic!();
}

View file

@ -21,8 +21,8 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
fn of<T>() -> |T| { fail!(); }
fn subtype<T>(x: |T|) { fail!(); }
fn of<T>() -> |T| { panic!(); }
fn subtype<T>(x: |T|) { panic!(); }
fn test_fn<'x, 'y, 'z, T>(_x: &'x T, _y: &'y T, _z: &'z T) {
// Here, x, y, and z are free. Other letters

View file

@ -31,17 +31,17 @@ fn want_G(f: G) { }
// Should meet both.
fn foo(x: &S) -> &'static S {
fail!()
panic!()
}
// Should meet both.
fn bar<'a,'b>(x: &'a S) -> &'b S {
fail!()
panic!()
}
// Meets F, but not G.
fn baz(x: &S) -> &S {
fail!()
panic!()
}
fn supply_F() {

View file

@ -8,8 +8,8 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
fn of<'a,T>() -> |T|:'a { fail!(); }
fn subtype<T>(x: |T|) { fail!(); }
fn of<'a,T>() -> |T|:'a { panic!(); }
fn subtype<T>(x: |T|) { panic!(); }
fn test_fn<'x,'y,'z,T>(_x: &'x T, _y: &'y T, _z: &'z T) {
// Here, x, y, and z are free. Other letters

View file

@ -27,7 +27,7 @@ fn ordering3<'a, 'b>(x: &'a uint, y: &'b uint) -> &'a &'b uint {
// Do not infer an ordering from the return value.
let z: &'b uint = &*x;
//~^ ERROR cannot infer
fail!();
panic!();
}
fn ordering4<'a, 'b>(a: &'a uint, b: &'b uint, x: |&'a &'b uint|) {

View file

@ -15,7 +15,7 @@
use std::vec::Vec;
fn last<T>(v: Vec<&T> ) -> std::option::Option<T> {
fail!();
panic!();
}
fn main() {

View file

@ -14,4 +14,4 @@ enum quux<T> { bar }
fn foo(c: quux) { assert!((false)); }
fn main() { fail!(); }
fn main() { panic!(); }

View file

@ -20,7 +20,7 @@ fn main() {
x: 3i
};
let baz: Foo<uint> = fail!();
let baz: Foo<uint> = panic!();
//~^ ERROR not implemented
}

View file

@ -17,7 +17,7 @@ enum MustUse { Test }
#[must_use = "some message"]
enum MustUseMsg { Test2 }
fn foo<T>() -> T { fail!() }
fn foo<T>() -> T { panic!() }
fn bar() -> int { return foo::<int>(); }
fn baz() -> MustUse { return foo::<MustUse>(); }

View file

@ -72,4 +72,4 @@ fn main() {
}
fn _zzz() {()}
fn _yyy() -> ! {fail!()}
fn _yyy() -> ! {panic!()}

View file

@ -8,6 +8,6 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
fn f() { if (1i == fail!()) { } else { } }
fn f() { if (1i == panic!()) { } else { } }
fn main() { }

View file

@ -11,6 +11,6 @@
// error-pattern:meep
fn f(_a: int, _b: int, _c: Box<int>) { fail!("moop"); }
fn f(_a: int, _b: int, _c: Box<int>) { panic!("moop"); }
fn main() { f(1, fail!("meep"), box 42); }
fn main() { f(1, panic!("meep"), box 42); }

View file

@ -9,5 +9,5 @@
// except according to those terms.
// error-pattern:quux
fn my_err(s: String) -> ! { println!("{}", s); fail!("quux"); }
fn my_err(s: String) -> ! { println!("{}", s); panic!("quux"); }
fn main() { 3u == my_err("bye".to_string()); }

View file

@ -16,7 +16,7 @@ use std::uint;
fn main() {
let x = vec!(1u,2u,3u);
// This should cause a bounds-check failure, but may not if we do our
// This should cause a bounds-check panic, but may not if we do our
// bounds checking by comparing a scaled index value to the vector's
// length (in bytes), because the scaling of the index will cause it to
// wrap around to a small number.
@ -24,6 +24,6 @@ fn main() {
let idx = uint::MAX & !(uint::MAX >> 1u);
println!("ov2 idx = 0x%x", idx);
// This should fail.
// This should panic.
println!("ov2 0x%x", x[idx]);
}

View file

@ -17,7 +17,7 @@ use std::u64;
fn main() {
let x = vec!(1u,2u,3u);
// This should cause a bounds-check failure, but may not if we do our
// This should cause a bounds-check panic, but may not if we do our
// bounds checking by truncating the index value to the size of the
// machine word, losing relevant bits of the index value.
@ -28,13 +28,13 @@ fn main() {
(idx >> 32) as uint,
idx as uint);
// This should fail.
// This should panic.
println!("ov3 0x%x", x.as_slice()[idx]);
}
#[cfg(target_arch="x86_64")]
fn main() {
// This version just fails anyways, for symmetry on 64-bit hosts.
// This version just panics anyways, for symmetry on 64-bit hosts.
let x = vec!(1u,2u,3u);
error!("ov3 0x%x", x.as_slice()[200]);
}

View file

@ -14,7 +14,7 @@ use std::mem;
fn main() {
// This should cause a bounds-check failure, but may not if we do our
// This should cause a bounds-check panic, but may not if we do our
// bounds checking by comparing the scaled index to the vector's
// address-bounds, since we've scaled the index to wrap around to the
// address of the 0th cell in the array (even though the index is
@ -30,6 +30,6 @@ fn main() {
println!("ov1 idx * sizeof::<uint>() = 0x{:x}",
idx * mem::size_of::<uint>());
// This should fail.
// This should panic.
println!("ov1 0x{:x}", x[idx]);
}

View file

@ -19,6 +19,6 @@ struct chan_t<T> {
port: port_id,
}
fn send<T:Send>(_ch: chan_t<T>, _data: T) { fail!(); }
fn send<T:Send>(_ch: chan_t<T>, _data: T) { panic!(); }
fn main() { fail!("quux"); }
fn main() { panic!("quux"); }

View file

@ -23,7 +23,7 @@ struct S {
impl Foo for S {
fn foo(self, x: int) {
fail!()
panic!()
}
}

View file

@ -11,5 +11,5 @@
// error-pattern:test
fn main() {
let _i: int = fail!("test");
let _i: int = panic!("test");
}

View file

@ -11,7 +11,7 @@
// error-pattern:test
fn f() {
fail!("test");
panic!("test");
}
fn main() {

View file

@ -11,5 +11,5 @@
// error-pattern:test
fn main() {
fail!("test");
panic!("test");
}

View file

@ -12,6 +12,6 @@
//error-pattern:One
fn main() {
fail!("One");
fail!("Two");
panic!("One");
panic!("Two");
}

View file

@ -15,5 +15,5 @@
fn main() {
let mut a = 1i;
if 1i == 1 { a = 2; }
fail!(format!("woooo{}", "o"));
panic!(format!("woooo{}", "o"));
}

View file

@ -12,4 +12,4 @@
// error-pattern:explicit
fn main() { fail!(); }
fn main() { panic!(); }

View file

@ -12,6 +12,6 @@
// error-pattern:explicit failure
fn f() -> ! { fail!() }
fn f() -> ! { panic!() }
fn main() { f(); }

View file

@ -12,7 +12,7 @@
// error-pattern:explicit failure
fn f() -> ! { fail!() }
fn f() -> ! { panic!() }
fn g() -> int { let x = if true { f() } else { 10 }; return x; }

View file

@ -12,4 +12,4 @@
// error-pattern:explicit failure
fn main() { let _x = if false { 0i } else if true { fail!() } else { 10i }; }
fn main() { let _x = if false { 0i } else if true { panic!() } else { 10i }; }

Some files were not shown because too many files have changed in this diff Show more