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:
parent
3bc545373d
commit
7828c3dd28
505 changed files with 1623 additions and 1618 deletions
|
|
@ -174,7 +174,7 @@ fn build_external_function(cx: &DocContext, tcx: &ty::ctxt,
|
|||
clean::Function {
|
||||
decl: match ty::get(t.ty).sty {
|
||||
ty::ty_bare_fn(ref f) => (did, &f.sig).clean(cx),
|
||||
_ => fail!("bad function"),
|
||||
_ => panic!("bad function"),
|
||||
},
|
||||
generics: (&t.generics, subst::FnSpace).clean(cx),
|
||||
fn_style: style,
|
||||
|
|
@ -308,7 +308,7 @@ fn build_impl(cx: &DocContext, tcx: &ty::ctxt,
|
|||
generics: generics,
|
||||
})
|
||||
}
|
||||
_ => fail!("not a tymethod"),
|
||||
_ => panic!("not a tymethod"),
|
||||
};
|
||||
Some(item)
|
||||
}
|
||||
|
|
@ -382,7 +382,7 @@ fn build_module(cx: &DocContext, tcx: &ty::ctxt,
|
|||
decoder::DlDef(..) => {}
|
||||
// All impls were inlined above
|
||||
decoder::DlImpl(..) => {}
|
||||
decoder::DlField => fail!("unimplemented field"),
|
||||
decoder::DlField => panic!("unimplemented field"),
|
||||
}
|
||||
});
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1259,7 +1259,7 @@ impl Clean<Type> for ast::Ty {
|
|||
TyBareFn(ref barefn) => BareFunction(box barefn.clean(cx)),
|
||||
TyParen(ref ty) => ty.clean(cx),
|
||||
TyBot => Bottom,
|
||||
ref x => fail!("Unimplemented type {}", x),
|
||||
ref x => panic!("Unimplemented type {}", x),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1354,9 +1354,9 @@ impl Clean<Type> for ty::t {
|
|||
|
||||
ty::ty_unboxed_closure(..) => Primitive(Unit), // FIXME(pcwalton)
|
||||
|
||||
ty::ty_infer(..) => fail!("ty_infer"),
|
||||
ty::ty_open(..) => fail!("ty_open"),
|
||||
ty::ty_err => fail!("ty_err"),
|
||||
ty::ty_infer(..) => panic!("ty_infer"),
|
||||
ty::ty_open(..) => panic!("ty_open"),
|
||||
ty::ty_err => panic!("ty_err"),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -2068,9 +2068,9 @@ fn name_from_pat(p: &ast::Pat) -> String {
|
|||
which is silly in function arguments");
|
||||
"()".to_string()
|
||||
},
|
||||
PatRange(..) => fail!("tried to get argument name from PatRange, \
|
||||
PatRange(..) => panic!("tried to get argument name from PatRange, \
|
||||
which is not allowed in function arguments"),
|
||||
PatVec(..) => fail!("tried to get argument name from pat_vec, \
|
||||
PatVec(..) => panic!("tried to get argument name from pat_vec, \
|
||||
which is not allowed in function arguments"),
|
||||
PatMac(..) => {
|
||||
warn!("can't document the name of a function argument \
|
||||
|
|
@ -2092,7 +2092,7 @@ fn resolve_type(cx: &DocContext, path: Path,
|
|||
debug!("searching for {} in defmap", id);
|
||||
let def = match tcx.def_map.borrow().find(&id) {
|
||||
Some(&k) => k,
|
||||
None => fail!("unresolved id not in defmap")
|
||||
None => panic!("unresolved id not in defmap")
|
||||
};
|
||||
|
||||
match def {
|
||||
|
|
|
|||
|
|
@ -128,7 +128,7 @@ mod imp {
|
|||
};
|
||||
if ret == -1 {
|
||||
unsafe { libc::close(fd); }
|
||||
fail!("could not lock `{}`", p.display())
|
||||
panic!("could not lock `{}`", p.display())
|
||||
}
|
||||
Lock { fd: fd }
|
||||
}
|
||||
|
|
@ -197,7 +197,7 @@ mod imp {
|
|||
ptr::null_mut())
|
||||
};
|
||||
if handle == libc::INVALID_HANDLE_VALUE {
|
||||
fail!("create file error: {}", os::last_os_error());
|
||||
panic!("create file error: {}", os::last_os_error());
|
||||
}
|
||||
let mut overlapped: libc::OVERLAPPED = unsafe { mem::zeroed() };
|
||||
let ret = unsafe {
|
||||
|
|
@ -206,7 +206,7 @@ mod imp {
|
|||
};
|
||||
if ret == 0 {
|
||||
unsafe { libc::CloseHandle(handle); }
|
||||
fail!("could not lock `{}`: {}", p.display(),
|
||||
panic!("could not lock `{}`: {}", p.display(),
|
||||
os::last_os_error())
|
||||
}
|
||||
Lock { handle: handle }
|
||||
|
|
|
|||
|
|
@ -499,7 +499,7 @@ impl fmt::Show for clean::Type {
|
|||
}
|
||||
}
|
||||
clean::Unique(..) => {
|
||||
fail!("should have been cleaned")
|
||||
panic!("should have been cleaned")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1042,7 +1042,7 @@ impl Context {
|
|||
/// sure it always points to the top (relatively)
|
||||
fn recurse<T>(&mut self, s: String, f: |&mut Context| -> T) -> T {
|
||||
if s.len() == 0 {
|
||||
fail!("Unexpected empty destination: {}", self.current);
|
||||
panic!("Unexpected empty destination: {}", self.current);
|
||||
}
|
||||
let prev = self.dst.clone();
|
||||
self.dst.push(s.as_slice());
|
||||
|
|
|
|||
|
|
@ -243,13 +243,13 @@ pub fn main_args(args: &[String]) -> int {
|
|||
Some("html") | None => {
|
||||
match html::render::run(krate, &external_html, output.unwrap_or(Path::new("doc"))) {
|
||||
Ok(()) => {}
|
||||
Err(e) => fail!("failed to generate documentation: {}", e),
|
||||
Err(e) => panic!("failed to generate documentation: {}", e),
|
||||
}
|
||||
}
|
||||
Some("json") => {
|
||||
match json_output(krate, res, output.unwrap_or(Path::new("doc.json"))) {
|
||||
Ok(()) => {}
|
||||
Err(e) => fail!("failed to write json: {}", e),
|
||||
Err(e) => panic!("failed to write json: {}", e),
|
||||
}
|
||||
}
|
||||
Some(s) => {
|
||||
|
|
@ -480,7 +480,7 @@ fn json_output(krate: clean::Crate, res: Vec<plugins::PluginJson> ,
|
|||
};
|
||||
let crate_json = match json::from_str(crate_json_str.as_slice()) {
|
||||
Ok(j) => j,
|
||||
Err(e) => fail!("Rust generated JSON is invalid: {}", e)
|
||||
Err(e) => panic!("Rust generated JSON is invalid: {}", e)
|
||||
};
|
||||
|
||||
json.insert("crate".to_string(), crate_json);
|
||||
|
|
|
|||
|
|
@ -192,15 +192,15 @@ fn runtest(test: &str, cratename: &str, libs: Vec<Path>, externs: core::Externs,
|
|||
cmd.env(DynamicLibrary::envvar(), newpath.as_slice());
|
||||
|
||||
match cmd.output() {
|
||||
Err(e) => fail!("couldn't run the test: {}{}", e,
|
||||
Err(e) => panic!("couldn't run the test: {}{}", e,
|
||||
if e.kind == io::PermissionDenied {
|
||||
" - maybe your tempdir is mounted with noexec?"
|
||||
} else { "" }),
|
||||
Ok(out) => {
|
||||
if should_fail && out.status.success() {
|
||||
fail!("test executable succeeded when it should have failed");
|
||||
panic!("test executable succeeded when it should have failed");
|
||||
} else if !should_fail && !out.status.success() {
|
||||
fail!("test executable failed:\n{}",
|
||||
panic!("test executable failed:\n{}",
|
||||
str::from_utf8(out.error.as_slice()));
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -249,7 +249,7 @@ impl<'a, 'tcx> RustdocVisitor<'a, 'tcx> {
|
|||
self.visit_item(&**i, None, om);
|
||||
}
|
||||
}
|
||||
_ => { fail!("glob not mapped to a module"); }
|
||||
_ => { panic!("glob not mapped to a module"); }
|
||||
}
|
||||
} else {
|
||||
self.visit_item(it, renamed, om);
|
||||
|
|
@ -353,7 +353,7 @@ impl<'a, 'tcx> RustdocVisitor<'a, 'tcx> {
|
|||
om.foreigns.push(fm.clone());
|
||||
}
|
||||
ast::ItemMac(_) => {
|
||||
fail!("rustdoc: macros should be gone, after expansion");
|
||||
panic!("rustdoc: macros should be gone, after expansion");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue