Skip to content

Commit 04de8f8

Browse files
Kimundidotdash
authored andcommitted
Fix cosmetics for fail!() calls
1 parent bdc182c commit 04de8f8

File tree

21 files changed

+47
-63
lines changed

21 files changed

+47
-63
lines changed

src/libcore/local_data.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -133,13 +133,13 @@ fn test_tls_modify() {
133133
local_data_modify(my_key, |data| {
134134
match data {
135135
Some(@ref val) => fail!("unwelcome value: %s", *val),
136-
None => Some(@~"first data")
136+
None => Some(@~"first data")
137137
}
138138
});
139139
local_data_modify(my_key, |data| {
140140
match data {
141141
Some(@~"first data") => Some(@~"next data"),
142-
Some(@ref val) => fail!("wrong value: %s", *val),
142+
Some(@ref val) => fail!("wrong value: %s", *val),
143143
None => fail!("missing value")
144144
}
145145
});

src/libcore/num/strconv.rs

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -178,11 +178,9 @@ pub fn to_str_bytes_common<T:NumCast+Zero+One+Eq+Ord+NumStrConv+Copy+
178178
num: &T, radix: uint, negative_zero: bool,
179179
sign: SignFormat, digits: SignificantDigits) -> (~[u8], bool) {
180180
if (radix as int) < 2 {
181-
fail!("to_str_bytes_common: radix %? to low, \
182-
must lie in the range [2, 36]", radix);
181+
fail!("to_str_bytes_common: radix %? to low, must lie in the range [2, 36]", radix);
183182
} else if radix as int > 36 {
184-
fail!("to_str_bytes_common: radix %? to high, \
185-
must lie in the range [2, 36]", radix);
183+
fail!("to_str_bytes_common: radix %? to high, must lie in the range [2, 36]", radix);
186184
}
187185

188186
let _0: T = Zero::zero();
@@ -445,19 +443,19 @@ pub fn from_str_bytes_common<T:NumCast+Zero+One+Eq+Ord+Copy+Div<T,T>+
445443
match exponent {
446444
ExpDec if radix >= DIGIT_E_RADIX // decimal exponent 'e'
447445
=> fail!("from_str_bytes_common: radix %? incompatible with \
448-
use of 'e' as decimal exponent", radix),
446+
use of 'e' as decimal exponent", radix),
449447
ExpBin if radix >= DIGIT_P_RADIX // binary exponent 'p'
450448
=> fail!("from_str_bytes_common: radix %? incompatible with \
451-
use of 'p' as binary exponent", radix),
449+
use of 'p' as binary exponent", radix),
452450
_ if special && radix >= DIGIT_I_RADIX // first digit of 'inf'
453451
=> fail!("from_str_bytes_common: radix %? incompatible with \
454-
special values 'inf' and 'NaN'", radix),
452+
special values 'inf' and 'NaN'", radix),
455453
_ if (radix as int) < 2
456454
=> fail!("from_str_bytes_common: radix %? to low, \
457-
must lie in the range [2, 36]", radix),
455+
must lie in the range [2, 36]", radix),
458456
_ if (radix as int) > 36
459457
=> fail!("from_str_bytes_common: radix %? to high, \
460-
must lie in the range [2, 36]", radix),
458+
must lie in the range [2, 36]", radix),
461459
_ => ()
462460
}
463461

src/libcore/os.rs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -178,8 +178,7 @@ pub fn env() -> ~[(~str,~str)] {
178178
};
179179
let ch = GetEnvironmentStringsA();
180180
if (ch as uint == 0) {
181-
fail!("os::env() failure getting env string from OS: %s",
182-
os::last_os_error());
181+
fail!("os::env() failure getting env string from OS: %s", os::last_os_error());
183182
}
184183
let mut curr_ptr: uint = ch as uint;
185184
let mut result = ~[];
@@ -201,8 +200,7 @@ pub fn env() -> ~[(~str,~str)] {
201200
}
202201
let environ = rust_env_pairs();
203202
if (environ as uint == 0) {
204-
fail!("os::env() failure getting env string from OS: %s",
205-
os::last_os_error());
203+
fail!("os::env() failure getting env string from OS: %s", os::last_os_error());
206204
}
207205
let mut result = ~[];
208206
ptr::array_each(environ, |e| {

src/libcore/run.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -646,8 +646,7 @@ pub fn program_output(prog: &str, args: &[~str]) -> ProgramOutput {
646646
errs = s;
647647
}
648648
(n, _) => {
649-
fail!("program_output received an unexpected file \
650-
number: %u", n);
649+
fail!("program_output received an unexpected file number: %u", n);
651650
}
652651
};
653652
count -= 1;

src/libcore/str.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1052,7 +1052,7 @@ pub fn _each_split_within<'a>(ss: &'a str,
10521052
(B, Cr, UnderLim) => { B }
10531053
(B, Cr, OverLim) if (i - last_start + 1) > lim
10541054
=> fail!("word starting with %? longer than limit!",
1055-
self::slice(ss, last_start, i + 1)),
1055+
self::slice(ss, last_start, i + 1)),
10561056
(B, Cr, OverLim) => { slice(); slice_start = last_start; B }
10571057
(B, Ws, UnderLim) => { last_end = i; C }
10581058
(B, Ws, OverLim) => { last_end = i; slice(); A }

src/librustc/driver/driver.rs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -917,8 +917,7 @@ mod test {
917917
let matches =
918918
&match getopts(~[~"--test"], optgroups()) {
919919
Ok(copy m) => m,
920-
Err(copy f) => fail!("test_switch_implies_cfg_test: %s",
921-
getopts::fail_str(f))
920+
Err(copy f) => fail!("test_switch_implies_cfg_test: %s", getopts::fail_str(f))
922921
};
923922
let sessopts = build_session_options(
924923
@~"rustc", matches, diagnostic::emit);
@@ -935,8 +934,7 @@ mod test {
935934
&match getopts(~[~"--test", ~"--cfg=test"], optgroups()) {
936935
Ok(copy m) => m,
937936
Err(copy f) => {
938-
fail!("test_switch_implies_cfg_test_unless_cfg_test: %s",
939-
getopts::fail_str(f));
937+
fail!("test_switch_implies_cfg_test_unless_cfg_test: %s", getopts::fail_str(f));
940938
}
941939
};
942940
let sessopts = build_session_options(

src/librustc/metadata/tydecode.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -531,13 +531,13 @@ pub fn parse_def_id(buf: &[u8]) -> ast::def_id {
531531

532532
let crate_num = match uint::parse_bytes(crate_part, 10u) {
533533
Some(cn) => cn as int,
534-
None => fail!("internal error: parse_def_id: crate number \
535-
expected, but found %?", crate_part)
534+
None => fail!("internal error: parse_def_id: crate number expected, but found %?",
535+
crate_part)
536536
};
537537
let def_num = match uint::parse_bytes(def_part, 10u) {
538538
Some(dn) => dn as int,
539-
None => fail!("internal error: parse_def_id: id expected, but \
540-
found %?", def_part)
539+
None => fail!("internal error: parse_def_id: id expected, but found %?",
540+
def_part)
541541
};
542542
ast::def_id { crate: crate_num, node: def_num }
543543
}

src/librustc/middle/kind.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -276,10 +276,10 @@ pub fn check_expr(e: @expr, cx: Context, v: visit::vt<Context>) {
276276
if ts.len() != type_param_defs.len() {
277277
// Fail earlier to make debugging easier
278278
fail!("internal error: in kind::check_expr, length \
279-
mismatch between actual and declared bounds: actual = \
280-
%s, declared = %s",
281-
ts.repr(cx.tcx),
282-
type_param_defs.repr(cx.tcx));
279+
mismatch between actual and declared bounds: actual = \
280+
%s, declared = %s",
281+
ts.repr(cx.tcx),
282+
type_param_defs.repr(cx.tcx));
283283
}
284284
for vec::each2(**ts, *type_param_defs) |&ty, type_param_def| {
285285
check_bounds(cx, type_parameter_id, e.span, ty, type_param_def)

src/librustc/middle/typeck/infer/test.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -154,16 +154,16 @@ pub impl Env {
154154
fn assert_subtype(&self, a: ty::t, b: ty::t) {
155155
if !self.is_subtype(a, b) {
156156
fail!("%s is not a subtype of %s, but it should be",
157-
self.ty_to_str(a),
158-
self.ty_to_str(b));
157+
self.ty_to_str(a),
158+
self.ty_to_str(b));
159159
}
160160
}
161161

162162
fn assert_not_subtype(&self, a: ty::t, b: ty::t) {
163163
if self.is_subtype(a, b) {
164164
fail!("%s is a subtype of %s, but it shouldn't be",
165-
self.ty_to_str(a),
166-
self.ty_to_str(b));
165+
self.ty_to_str(a),
166+
self.ty_to_str(b));
167167
}
168168
}
169169

src/librustdoc/attr_pass.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -140,9 +140,8 @@ fn fold_enum(
140140
copy ast_variant.node.attrs)
141141
}
142142
_ => {
143-
fail!("Enum variant %s has id that's \
144-
not bound to an enum item",
145-
variant.name)
143+
fail!("Enum variant %s has id that's not bound to an enum item",
144+
variant.name)
146145
}
147146
}
148147
}

src/librustpkg/rustpkg.rc

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -146,8 +146,7 @@ impl PkgScript {
146146
}
147147
}
148148
Err(e) => {
149-
fail!("Running package script, couldn't find rustpkg sysroot (%s)",
150-
e)
149+
fail!("Running package script, couldn't find rustpkg sysroot (%s)", e)
151150
}
152151
}
153152
}

src/librustpkg/workspace.rs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,9 @@ pub fn pkg_parent_workspaces(pkgid: PkgId, action: &fn(&Path) -> bool) -> bool {
2121
workspace_contains_package_id(pkgid, ws));
2222
if workspaces.is_empty() {
2323
// tjc: make this a condition
24-
fail!("Package %s not found in any of \
25-
the following workspaces: %s",
26-
pkgid.path.to_str(),
27-
rust_path().to_str());
24+
fail!("Package %s not found in any of the following workspaces: %s",
25+
pkgid.path.to_str(),
26+
rust_path().to_str());
2827
}
2928
for workspaces.each |ws| {
3029
if action(ws) {

src/libstd/ebml.rs

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -319,9 +319,7 @@ pub mod reader {
319319
self.pos = r_doc.end;
320320
let str = doc_as_str(r_doc);
321321
if lbl != str {
322-
fail!("Expected label %s but found %s",
323-
lbl,
324-
str);
322+
fail!("Expected label %s but found %s", lbl, str);
325323
}
326324
}
327325
}
@@ -338,12 +336,11 @@ pub mod reader {
338336
copy self.parent.start, copy self.parent.end,
339337
copy self.pos, r_tag, r_doc.start, r_doc.end);
340338
if r_tag != (exp_tag as uint) {
341-
fail!("expected EBML doc with tag %? but found tag %?",
342-
exp_tag, r_tag);
339+
fail!("expected EBML doc with tag %? but found tag %?", exp_tag, r_tag);
343340
}
344341
if r_doc.end > self.parent.end {
345-
fail!("invalid EBML, child extends to 0x%x, \
346-
parent to 0x%x", r_doc.end, self.parent.end);
342+
fail!("invalid EBML, child extends to 0x%x, parent to 0x%x",
343+
r_doc.end, self.parent.end);
347344
}
348345
self.pos = r_doc.end;
349346
r_doc

src/libstd/net_tcp.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1687,7 +1687,7 @@ mod test {
16871687
assert!(true);
16881688
}
16891689
_ => {
1690-
fail!("expected address_in_use listen error,\
1690+
fail!("expected address_in_use listen error, \
16911691
but got a different error varient. check logs.");
16921692
}
16931693
}
@@ -1706,7 +1706,7 @@ mod test {
17061706
assert!(true);
17071707
}
17081708
_ => {
1709-
fail!("expected address_in_use listen error,\
1709+
fail!("expected address_in_use listen error, \
17101710
but got a different error varient. check logs.");
17111711
}
17121712
}

src/libstd/sync.rs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -329,11 +329,9 @@ fn check_cvar_bounds<U>(out_of_bounds: Option<uint>, id: uint, act: &str,
329329
blk: &fn() -> U) -> U {
330330
match out_of_bounds {
331331
Some(0) =>
332-
fail!("%s with illegal ID %u - this lock has no condvars!",
333-
act, id),
332+
fail!("%s with illegal ID %u - this lock has no condvars!", act, id),
334333
Some(length) =>
335-
fail!("%s with illegal ID %u - ID must be less than %u",
336-
act, id, length),
334+
fail!("%s with illegal ID %u - ID must be less than %u", act, id, length),
337335
None => blk()
338336
}
339337
}

src/libsyntax/codemap.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -430,8 +430,7 @@ priv impl CodeMap {
430430
}
431431
}
432432
if (a >= len) {
433-
fail!("position %u does not resolve to a source location",
434-
pos.to_uint())
433+
fail!("position %u does not resolve to a source location", pos.to_uint())
435434
}
436435

437436
return a;

src/libsyntax/ext/expand.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -468,7 +468,7 @@ pub fn core_macros() -> ~str {
468468
let expected_val = $expected;
469469
// check both directions of equality....
470470
if !((given_val == expected_val) && (expected_val == given_val)) {
471-
fail!(\"left: %? != right: %?\", given_val, expected_val);
471+
fail!(\"left: %? does not equal right: %?\", given_val, expected_val);
472472
}
473473
}
474474
)

src/libsyntax/print/pprust.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2237,7 +2237,7 @@ mod test {
22372237

22382238
fn string_check<T:Eq> (given : &T, expected: &T) {
22392239
if !(given == expected) {
2240-
fail!("given %?, expected %?",given,expected);
2240+
fail!("given %?, expected %?", given, expected);
22412241
}
22422242
}
22432243

src/test/run-fail/assert-eq-macro-fail.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// error-pattern:left: 14 != right: 15
1+
// error-pattern:left: 14 does not equal right: 15
22

33
#[deriving(Eq)]
44
struct Point { x : int }

src/test/run-fail/while-fail.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,5 +10,5 @@
1010

1111
// error-pattern:giraffe
1212
fn main() {
13-
fail!({ while true { fail!(~"giraffe")}; "clandestine" });
13+
fail!({ while true { fail!("giraffe") }; "clandestine" });
1414
}

src/test/run-pass/nullable-pointer-iotareduction.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ macro_rules! check_fancy {
5858
match t_.get_ref() {
5959
(23, $v) => { $chk }
6060
_ => fail!("Thing::<%s>(23, %s).get_ref() != (23, _)",
61-
stringify!($T), stringify!($e))
61+
stringify!($T), stringify!($e))
6262
}
6363
}}
6464
}

0 commit comments

Comments
 (0)