Skip to content

Commit 4445b38

Browse files
Nick Desaulniersbrson
Nick Desaulniers
authored andcommitted
Remove die!, raplace invocations with fail! Issue #4524 pt 3
1 parent c51ecc3 commit 4445b38

File tree

363 files changed

+910
-906
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

363 files changed

+910
-906
lines changed

src/compiletest/compiletest.rc

+3-3
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ pub fn parse_config(args: ~[~str]) -> config {
7070
let matches =
7171
&match getopts::getopts(args_, opts) {
7272
Ok(m) => m,
73-
Err(f) => die!(getopts::fail_str(f))
73+
Err(f) => fail!(getopts::fail_str(f))
7474
};
7575

7676
fn opt_path(m: &getopts::Matches, nm: ~str) -> Path {
@@ -133,7 +133,7 @@ pub fn str_mode(s: ~str) -> mode {
133133
~"run-pass" => mode_run_pass,
134134
~"pretty" => mode_pretty,
135135
~"debug-info" => mode_debug_info,
136-
_ => die!(~"invalid mode")
136+
_ => fail!(~"invalid mode")
137137
}
138138
}
139139

@@ -151,7 +151,7 @@ pub fn run_tests(config: config) {
151151
let opts = test_opts(config);
152152
let tests = make_tests(config);
153153
let res = test::run_tests_console(&opts, tests);
154-
if !res { die!(~"Some tests failed"); }
154+
if !res { fail!(~"Some tests failed"); }
155155
}
156156

157157
pub fn test_opts(config: config) -> test::TestOpts {

src/compiletest/header.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ fn parse_exec_env(line: ~str) -> Option<(~str, ~str)> {
145145
match strs.len() {
146146
1u => (strs[0], ~""),
147147
2u => (strs[0], strs[1]),
148-
n => die!(fmt!("Expected 1 or 2 strings, not %u", n))
148+
n => fail!(fmt!("Expected 1 or 2 strings, not %u", n))
149149
}
150150
}
151151
}

src/compiletest/procsrv.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ pub fn run(lib_path: ~str,
7171
os::close(pipe_in.out);
7272
os::close(pipe_out.in);
7373
os::close(pipe_err.in);
74-
die!();
74+
fail!();
7575
}
7676

7777

@@ -99,7 +99,7 @@ pub fn run(lib_path: ~str,
9999
(2, s) => {
100100
errs = s;
101101
}
102-
_ => { die!() }
102+
_ => { fail!() }
103103
};
104104
count -= 1;
105105
};

src/compiletest/runtest.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -202,7 +202,7 @@ actual:\n\
202202
\n",
203203
expected, actual);
204204
io::stdout().write_str(msg);
205-
die!();
205+
fail!();
206206
}
207207
}
208208

@@ -518,7 +518,7 @@ fn compose_and_run_compiler(
518518
fn ensure_dir(path: &Path) {
519519
if os::path_is_dir(path) { return; }
520520
if !os::make_dir(path, 0x1c0i32) {
521-
die!(fmt!("can't make dir %s", path.to_str()));
521+
fail!(fmt!("can't make dir %s", path.to_str()));
522522
}
523523
}
524524

@@ -668,7 +668,7 @@ fn maybe_dump_to_stdout(config: config, out: ~str, err: ~str) {
668668
669669
fn error(err: ~str) { io::stdout().write_line(fmt!("\nerror: %s", err)); }
670670
671-
fn fatal(err: ~str) -> ! { error(err); die!(); }
671+
fn fatal(err: ~str) -> ! { error(err); fail!(); }
672672
673673
fn fatal_ProcRes(err: ~str, ProcRes: ProcRes) -> ! {
674674
let msg =
@@ -686,5 +686,5 @@ stderr:\n\
686686
\n",
687687
err, ProcRes.cmdline, ProcRes.stdout, ProcRes.stderr);
688688
io::stdout().write_str(msg);
689-
die!();
689+
fail!();
690690
}

src/libcargo/cargo.rc

+15-15
Original file line numberDiff line numberDiff line change
@@ -295,7 +295,7 @@ pub fn load_link(mis: ~[@ast::meta_item]) -> (Option<~str>,
295295
_ => { }
296296
}
297297
}
298-
_ => die!(~"load_link: meta items must be name-values")
298+
_ => fail!(~"load_link: meta items must be name-values")
299299
}
300300
}
301301
(name, vers, uuid)
@@ -332,7 +332,7 @@ pub fn load_crate(filename: &Path) -> Option<Crate> {
332332
}
333333
}
334334
_ => {
335-
die!(~"crate attributes may not contain " +
335+
fail!(~"crate attributes may not contain " +
336336
~"meta_words");
337337
}
338338
}
@@ -435,7 +435,7 @@ pub fn rest(s: ~str, start: uint) -> ~str {
435435
pub fn need_dir(s: &Path) {
436436
if os::path_is_dir(s) { return; }
437437
if !os::make_dir(s, 493_i32 /* oct: 755 */) {
438-
die!(fmt!("can't make_dir %s", s.to_str()));
438+
fail!(fmt!("can't make_dir %s", s.to_str()));
439439
}
440440
}
441441

@@ -453,14 +453,14 @@ pub fn valid_pkg_name(s: &str) -> bool {
453453

454454
pub fn parse_source(name: ~str, j: &json::Json) -> @Source {
455455
if !valid_pkg_name(name) {
456-
die!(fmt!("'%s' is an invalid source name", name));
456+
fail!(fmt!("'%s' is an invalid source name", name));
457457
}
458458

459459
match *j {
460460
json::Object(ref j) => {
461461
let mut url = match j.find(&~"url") {
462462
Some(&json::String(u)) => copy u,
463-
_ => die!(~"needed 'url' field in source")
463+
_ => fail!(~"needed 'url' field in source")
464464
};
465465
let method = match j.find(&~"method") {
466466
Some(&json::String(u)) => copy u,
@@ -485,7 +485,7 @@ pub fn parse_source(name: ~str, j: &json::Json) -> @Source {
485485
mut keyfp: keyfp,
486486
packages: DVec() };
487487
}
488-
_ => die!(~"needed dict value in source")
488+
_ => fail!(~"needed dict value in source")
489489
};
490490
}
491491

@@ -500,8 +500,8 @@ pub fn try_parse_sources(filename: &Path,
500500
debug!("source: %s", *k);
501501
}
502502
}
503-
Ok(_) => die!(~"malformed sources.json"),
504-
Err(e) => die!(fmt!("%s:%s", filename.to_str(), e.to_str()))
503+
Ok(_) => fail!(~"malformed sources.json"),
504+
Err(e) => fail!(fmt!("%s:%s", filename.to_str(), e.to_str()))
505505
}
506506
}
507507

@@ -662,7 +662,7 @@ pub fn build_cargo_options(argv: ~[~str]) -> Options {
662662
let matches = &match getopts::getopts(argv, opts()) {
663663
result::Ok(m) => m,
664664
result::Err(f) => {
665-
die!(fmt!("%s", getopts::fail_str(f)));
665+
fail!(fmt!("%s", getopts::fail_str(f)));
666666
}
667667
};
668668

@@ -675,10 +675,10 @@ pub fn build_cargo_options(argv: ~[~str]) -> Options {
675675
let is_install = len > 1u && matches.free[1] == ~"install";
676676
let is_uninstall = len > 1u && matches.free[1] == ~"uninstall";
677677

678-
if G && g { die!(~"-G and -g both provided"); }
678+
if G && g { fail!(~"-G and -g both provided"); }
679679

680680
if !is_install && !is_uninstall && (g || G) {
681-
die!(~"-g and -G are only valid for `install` and `uninstall|rm`");
681+
fail!(~"-g and -G are only valid for `install` and `uninstall|rm`");
682682
}
683683

684684
let mode =
@@ -845,7 +845,7 @@ pub fn install_source(c: &mut Cargo, path: &Path) {
845845
}
846846

847847
if vec::is_empty(cratefiles) {
848-
die!(~"this doesn't look like a rust package (no .rc files)");
848+
fail!(~"this doesn't look like a rust package (no .rc files)");
849849
}
850850

851851
for cratefiles.each |cf| {
@@ -889,7 +889,7 @@ pub fn install_curl(c: &mut Cargo, wd: &Path, url: ~str) {
889889
let p = run::program_output(~"curl", ~[~"-f", ~"-s", ~"-o",
890890
tarpath.to_str(), url]);
891891
if p.status != 0 {
892-
die!(fmt!("fetch of %s failed: %s", url, p.err));
892+
fail!(fmt!("fetch of %s failed: %s", url, p.err));
893893
}
894894
run::run_program(~"tar", ~[~"-x", ~"--strip-components=1",
895895
~"-C", wd.to_str(),
@@ -1123,7 +1123,7 @@ pub fn install_query(c: &mut Cargo, wd: &Path, target: ~str) {
11231123
pub fn get_temp_workdir(c: &Cargo) -> Path {
11241124
match tempfile::mkdtemp(&c.workdir, "cargo") {
11251125
Some(wd) => wd,
1126-
None => die!(fmt!("needed temp dir: %s",
1126+
None => fail!(fmt!("needed temp dir: %s",
11271127
c.workdir.to_str()))
11281128
}
11291129
}
@@ -1138,7 +1138,7 @@ pub fn cmd_install(c: &mut Cargo) {
11381138
wd.to_str()]);
11391139

11401140
if status != 0 {
1141-
die!(fmt!("could not copy directory: %s", cwd.to_str()));
1141+
fail!(fmt!("could not copy directory: %s", cwd.to_str()));
11421142
}
11431143

11441144
install_source(c, &wd);

src/libcargo/pgp.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ pub fn init(root: &Path) {
8787
p.input().write_str(signing_key());
8888
let s = p.finish();
8989
if s != 0 {
90-
die!(~"pgp init failed");
90+
fail!(~"pgp init failed");
9191
}
9292
}
9393
}
@@ -98,7 +98,7 @@ pub fn add(root: &Path, key: &Path) {
9898
run::program_output(~"gpg", ~[~"--homedir", path.to_str(),
9999
~"--import", key.to_str()]);
100100
if p.status != 0 {
101-
die!(~"pgp add failed: " + p.out);
101+
fail!(~"pgp add failed: " + p.out);
102102
}
103103
}
104104

src/libcore/char.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@ pub pure fn is_digit_radix(c: char, radix: uint) -> bool {
150150
#[inline]
151151
pub pure fn to_digit(c: char, radix: uint) -> Option<uint> {
152152
if radix > 36 {
153-
die!(fmt!("to_digit: radix %? is to high (maximum 36)", radix));
153+
fail!(fmt!("to_digit: radix %? is to high (maximum 36)", radix));
154154
}
155155
let val = match c {
156156
'0' .. '9' => c as uint - ('0' as uint),
@@ -173,7 +173,7 @@ pub pure fn to_digit(c: char, radix: uint) -> Option<uint> {
173173
#[inline]
174174
pub pure fn from_digit(num: uint, radix: uint) -> Option<char> {
175175
if radix > 36 {
176-
die!(fmt!("from_digit: radix %? is to high (maximum 36)", num));
176+
fail!(fmt!("from_digit: radix %? is to high (maximum 36)", num));
177177
}
178178
if num < radix {
179179
if num < 10 {

src/libcore/condition.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ impl<T, U> Condition<T, U> {
3737

3838
fn raise(t: T) -> U {
3939
let msg = fmt!("Unhandled condition: %s: %?", self.name, t);
40-
self.raise_default(t, || die!(copy msg))
40+
self.raise_default(t, || fail!(copy msg))
4141
}
4242

4343
fn raise_default(t: T, default: &fn() -> U) -> U {

src/libcore/dlist.rs

+14-14
Original file line numberDiff line numberDiff line change
@@ -44,18 +44,18 @@ priv impl<T> DListNode<T> {
4444
match self.next {
4545
Some(neighbour) => match neighbour.prev {
4646
Some(me) => if !managed::mut_ptr_eq(self, me) {
47-
die!(~"Asymmetric next-link in dlist node.")
47+
fail!(~"Asymmetric next-link in dlist node.")
4848
},
49-
None => die!(~"One-way next-link in dlist node.")
49+
None => fail!(~"One-way next-link in dlist node.")
5050
},
5151
None => ()
5252
}
5353
match self.prev {
5454
Some(neighbour) => match neighbour.next {
5555
Some(me) => if !managed::mut_ptr_eq(me, self) {
56-
die!(~"Asymmetric prev-link in dlist node.")
56+
fail!(~"Asymmetric prev-link in dlist node.")
5757
},
58-
None => die!(~"One-way prev-link in dlist node.")
58+
None => fail!(~"One-way prev-link in dlist node.")
5959
},
6060
None => ()
6161
}
@@ -72,7 +72,7 @@ impl<T> DListNode<T> {
7272
pure fn next_node(@mut self) -> @mut DListNode<T> {
7373
match self.next_link() {
7474
Some(nobe) => nobe,
75-
None => die!(~"This dlist node has no next neighbour.")
75+
None => fail!(~"This dlist node has no next neighbour.")
7676
}
7777
}
7878
/// Get the previous node in the list, if there is one.
@@ -84,7 +84,7 @@ impl<T> DListNode<T> {
8484
pure fn prev_node(@mut self) -> @mut DListNode<T> {
8585
match self.prev_link() {
8686
Some(nobe) => nobe,
87-
None => die!(~"This dlist node has no previous neighbour.")
87+
None => fail!(~"This dlist node has no previous neighbour.")
8888
}
8989
}
9090
}
@@ -136,21 +136,21 @@ priv impl<T> DList<T> {
136136
// These asserts could be stronger if we had node-root back-pointers,
137137
// but those wouldn't allow for O(1) append.
138138
if self.size == 0 {
139-
die!(~"This dlist is empty; that node can't be on it.")
139+
fail!(~"This dlist is empty; that node can't be on it.")
140140
}
141-
if !nobe.linked { die!(~"That node isn't linked to any dlist.") }
141+
if !nobe.linked { fail!(~"That node isn't linked to any dlist.") }
142142
if !((nobe.prev.is_some()
143143
|| managed::mut_ptr_eq(self.hd.expect(~"headless dlist?"),
144144
nobe)) &&
145145
(nobe.next.is_some()
146146
|| managed::mut_ptr_eq(self.tl.expect(~"tailless dlist?"),
147147
nobe))) {
148-
die!(~"That node isn't on this dlist.")
148+
fail!(~"That node isn't on this dlist.")
149149
}
150150
}
151151
fn make_mine(nobe: @mut DListNode<T>) {
152152
if nobe.prev.is_some() || nobe.next.is_some() || nobe.linked {
153-
die!(~"Cannot insert node that's already on a dlist!")
153+
fail!(~"Cannot insert node that's already on a dlist!")
154154
}
155155
nobe.linked = true;
156156
}
@@ -322,15 +322,15 @@ impl<T> DList<T> {
322322
pure fn head_n(@mut self) -> @mut DListNode<T> {
323323
match self.hd {
324324
Some(nobe) => nobe,
325-
None => die!(
325+
None => fail!(
326326
~"Attempted to get the head of an empty dlist.")
327327
}
328328
}
329329
/// Get the node at the list's tail, failing if empty. O(1).
330330
pure fn tail_n(@mut self) -> @mut DListNode<T> {
331331
match self.tl {
332332
Some(nobe) => nobe,
333-
None => die!(
333+
None => fail!(
334334
~"Attempted to get the tail of an empty dlist.")
335335
}
336336
}
@@ -344,7 +344,7 @@ impl<T> DList<T> {
344344
*/
345345
fn append(@mut self, them: @mut DList<T>) {
346346
if managed::mut_ptr_eq(self, them) {
347-
die!(~"Cannot append a dlist to itself!")
347+
fail!(~"Cannot append a dlist to itself!")
348348
}
349349
if them.len() > 0 {
350350
self.link(self.tl, them.hd);
@@ -361,7 +361,7 @@ impl<T> DList<T> {
361361
*/
362362
fn prepend(@mut self, them: @mut DList<T>) {
363363
if managed::mut_ptr_eq(self, them) {
364-
die!(~"Cannot prepend a dlist to itself!")
364+
fail!(~"Cannot prepend a dlist to itself!")
365365
}
366366
if them.len() > 0 {
367367
self.link(them.tl, self.hd);

src/libcore/dvec.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ priv impl<A> DVec<A> {
8787
unsafe {
8888
let data: *() = cast::reinterpret_cast(&self.data);
8989
if data.is_null() {
90-
die!(~"Recursive use of dvec");
90+
fail!(~"Recursive use of dvec");
9191
}
9292
}
9393
}
@@ -98,7 +98,7 @@ priv impl<A> DVec<A> {
9898
let mut data = cast::reinterpret_cast(&null::<()>());
9999
data <-> self.data;
100100
let data_ptr: *() = cast::reinterpret_cast(&data);
101-
if data_ptr.is_null() { die!(~"Recursive use of dvec"); }
101+
if data_ptr.is_null() { fail!(~"Recursive use of dvec"); }
102102
return f(move data);
103103
}
104104
}
@@ -175,7 +175,7 @@ impl<A> DVec<A> {
175175
let mut data = cast::reinterpret_cast(&null::<()>());
176176
data <-> self.data;
177177
let data_ptr: *() = cast::reinterpret_cast(&data);
178-
if data_ptr.is_null() { die!(~"Recursive use of dvec"); }
178+
if data_ptr.is_null() { fail!(~"Recursive use of dvec"); }
179179
self.data = move ~[move t];
180180
self.data.push_all_move(move data);
181181
}
@@ -325,7 +325,7 @@ impl<A: Copy> DVec<A> {
325325
326326
let length = self.len();
327327
if length == 0 {
328-
die!(~"attempt to retrieve the last element of an empty vector");
328+
fail!(~"attempt to retrieve the last element of an empty vector");
329329
}
330330

331331
return self.data[length - 1];

0 commit comments

Comments
 (0)