Fix cosmetics for fail!() calls

This commit is contained in:
Marvin Löbel 2013-05-09 13:52:07 +02:00 committed by Björn Steinbrink
parent bdc182cc41
commit 04de8f852c
21 changed files with 47 additions and 63 deletions

View file

@ -178,11 +178,9 @@ pub fn to_str_bytes_common<T:NumCast+Zero+One+Eq+Ord+NumStrConv+Copy+
num: &T, radix: uint, negative_zero: bool, num: &T, radix: uint, negative_zero: bool,
sign: SignFormat, digits: SignificantDigits) -> (~[u8], bool) { sign: SignFormat, digits: SignificantDigits) -> (~[u8], bool) {
if (radix as int) < 2 { if (radix as int) < 2 {
fail!("to_str_bytes_common: radix %? to low, \ fail!("to_str_bytes_common: radix %? to low, must lie in the range [2, 36]", radix);
must lie in the range [2, 36]", radix);
} else if radix as int > 36 { } else if radix as int > 36 {
fail!("to_str_bytes_common: radix %? to high, \ fail!("to_str_bytes_common: radix %? to high, must lie in the range [2, 36]", radix);
must lie in the range [2, 36]", radix);
} }
let _0: T = Zero::zero(); let _0: T = Zero::zero();

View file

@ -178,8 +178,7 @@ pub fn env() -> ~[(~str,~str)] {
}; };
let ch = GetEnvironmentStringsA(); let ch = GetEnvironmentStringsA();
if (ch as uint == 0) { if (ch as uint == 0) {
fail!("os::env() failure getting env string from OS: %s", fail!("os::env() failure getting env string from OS: %s", os::last_os_error());
os::last_os_error());
} }
let mut curr_ptr: uint = ch as uint; let mut curr_ptr: uint = ch as uint;
let mut result = ~[]; let mut result = ~[];
@ -201,8 +200,7 @@ pub fn env() -> ~[(~str,~str)] {
} }
let environ = rust_env_pairs(); let environ = rust_env_pairs();
if (environ as uint == 0) { if (environ as uint == 0) {
fail!("os::env() failure getting env string from OS: %s", fail!("os::env() failure getting env string from OS: %s", os::last_os_error());
os::last_os_error());
} }
let mut result = ~[]; let mut result = ~[];
ptr::array_each(environ, |e| { ptr::array_each(environ, |e| {

View file

@ -646,8 +646,7 @@ pub fn program_output(prog: &str, args: &[~str]) -> ProgramOutput {
errs = s; errs = s;
} }
(n, _) => { (n, _) => {
fail!("program_output received an unexpected file \ fail!("program_output received an unexpected file number: %u", n);
number: %u", n);
} }
}; };
count -= 1; count -= 1;

View file

@ -917,8 +917,7 @@ mod test {
let matches = let matches =
&match getopts(~[~"--test"], optgroups()) { &match getopts(~[~"--test"], optgroups()) {
Ok(copy m) => m, Ok(copy m) => m,
Err(copy f) => fail!("test_switch_implies_cfg_test: %s", Err(copy f) => fail!("test_switch_implies_cfg_test: %s", getopts::fail_str(f))
getopts::fail_str(f))
}; };
let sessopts = build_session_options( let sessopts = build_session_options(
@~"rustc", matches, diagnostic::emit); @~"rustc", matches, diagnostic::emit);
@ -935,8 +934,7 @@ mod test {
&match getopts(~[~"--test", ~"--cfg=test"], optgroups()) { &match getopts(~[~"--test", ~"--cfg=test"], optgroups()) {
Ok(copy m) => m, Ok(copy m) => m,
Err(copy f) => { Err(copy f) => {
fail!("test_switch_implies_cfg_test_unless_cfg_test: %s", fail!("test_switch_implies_cfg_test_unless_cfg_test: %s", getopts::fail_str(f));
getopts::fail_str(f));
} }
}; };
let sessopts = build_session_options( let sessopts = build_session_options(

View file

@ -531,13 +531,13 @@ pub fn parse_def_id(buf: &[u8]) -> ast::def_id {
let crate_num = match uint::parse_bytes(crate_part, 10u) { let crate_num = match uint::parse_bytes(crate_part, 10u) {
Some(cn) => cn as int, Some(cn) => cn as int,
None => fail!("internal error: parse_def_id: crate number \ None => fail!("internal error: parse_def_id: crate number expected, but found %?",
expected, but found %?", crate_part) crate_part)
}; };
let def_num = match uint::parse_bytes(def_part, 10u) { let def_num = match uint::parse_bytes(def_part, 10u) {
Some(dn) => dn as int, Some(dn) => dn as int,
None => fail!("internal error: parse_def_id: id expected, but \ None => fail!("internal error: parse_def_id: id expected, but found %?",
found %?", def_part) def_part)
}; };
ast::def_id { crate: crate_num, node: def_num } ast::def_id { crate: crate_num, node: def_num }
} }

View file

@ -140,8 +140,7 @@ fn fold_enum(
copy ast_variant.node.attrs) copy ast_variant.node.attrs)
} }
_ => { _ => {
fail!("Enum variant %s has id that's \ fail!("Enum variant %s has id that's not bound to an enum item",
not bound to an enum item",
variant.name) variant.name)
} }
} }

View file

@ -146,8 +146,7 @@ impl PkgScript {
} }
} }
Err(e) => { Err(e) => {
fail!("Running package script, couldn't find rustpkg sysroot (%s)", fail!("Running package script, couldn't find rustpkg sysroot (%s)", e)
e)
} }
} }
} }

View file

@ -21,8 +21,7 @@ pub fn pkg_parent_workspaces(pkgid: PkgId, action: &fn(&Path) -> bool) -> bool {
workspace_contains_package_id(pkgid, ws)); workspace_contains_package_id(pkgid, ws));
if workspaces.is_empty() { if workspaces.is_empty() {
// tjc: make this a condition // tjc: make this a condition
fail!("Package %s not found in any of \ fail!("Package %s not found in any of the following workspaces: %s",
the following workspaces: %s",
pkgid.path.to_str(), pkgid.path.to_str(),
rust_path().to_str()); rust_path().to_str());
} }

View file

@ -319,9 +319,7 @@ pub mod reader {
self.pos = r_doc.end; self.pos = r_doc.end;
let str = doc_as_str(r_doc); let str = doc_as_str(r_doc);
if lbl != str { if lbl != str {
fail!("Expected label %s but found %s", fail!("Expected label %s but found %s", lbl, str);
lbl,
str);
} }
} }
} }
@ -338,12 +336,11 @@ pub mod reader {
copy self.parent.start, copy self.parent.end, copy self.parent.start, copy self.parent.end,
copy self.pos, r_tag, r_doc.start, r_doc.end); copy self.pos, r_tag, r_doc.start, r_doc.end);
if r_tag != (exp_tag as uint) { if r_tag != (exp_tag as uint) {
fail!("expected EBML doc with tag %? but found tag %?", fail!("expected EBML doc with tag %? but found tag %?", exp_tag, r_tag);
exp_tag, r_tag);
} }
if r_doc.end > self.parent.end { if r_doc.end > self.parent.end {
fail!("invalid EBML, child extends to 0x%x, \ fail!("invalid EBML, child extends to 0x%x, parent to 0x%x",
parent to 0x%x", r_doc.end, self.parent.end); r_doc.end, self.parent.end);
} }
self.pos = r_doc.end; self.pos = r_doc.end;
r_doc r_doc

View file

@ -329,11 +329,9 @@ fn check_cvar_bounds<U>(out_of_bounds: Option<uint>, id: uint, act: &str,
blk: &fn() -> U) -> U { blk: &fn() -> U) -> U {
match out_of_bounds { match out_of_bounds {
Some(0) => Some(0) =>
fail!("%s with illegal ID %u - this lock has no condvars!", fail!("%s with illegal ID %u - this lock has no condvars!", act, id),
act, id),
Some(length) => Some(length) =>
fail!("%s with illegal ID %u - ID must be less than %u", fail!("%s with illegal ID %u - ID must be less than %u", act, id, length),
act, id, length),
None => blk() None => blk()
} }
} }

View file

@ -430,8 +430,7 @@ priv impl CodeMap {
} }
} }
if (a >= len) { if (a >= len) {
fail!("position %u does not resolve to a source location", fail!("position %u does not resolve to a source location", pos.to_uint())
pos.to_uint())
} }
return a; return a;

View file

@ -468,7 +468,7 @@ pub fn core_macros() -> ~str {
let expected_val = $expected; let expected_val = $expected;
// check both directions of equality.... // check both directions of equality....
if !((given_val == expected_val) && (expected_val == given_val)) { if !((given_val == expected_val) && (expected_val == given_val)) {
fail!(\"left: %? != right: %?\", given_val, expected_val); fail!(\"left: %? does not equal right: %?\", given_val, expected_val);
} }
} }
) )

View file

@ -1,4 +1,4 @@
// error-pattern:left: 14 != right: 15 // error-pattern:left: 14 does not equal right: 15
#[deriving(Eq)] #[deriving(Eq)]
struct Point { x : int } struct Point { x : int }

View file

@ -10,5 +10,5 @@
// error-pattern:giraffe // error-pattern:giraffe
fn main() { fn main() {
fail!({ while true { fail!(~"giraffe")}; "clandestine" }); fail!({ while true { fail!("giraffe") }; "clandestine" });
} }