Skip to content

Commit 4ce4396

Browse files
committed
---
yaml --- r: 6011 b: refs/heads/master c: bab2b37 h: refs/heads/master i: 6009: a7f3851 6007: 5cdcff7 v: v3
1 parent a007ed1 commit 4ce4396

File tree

2 files changed

+18
-17
lines changed

2 files changed

+18
-17
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
---
2-
refs/heads/master: 8da8a4a018bad826940fa3d5617e54f4b9ec8fb3
2+
refs/heads/master: bab2b37fd0d1491397736d9adc2317ffc06624ef

trunk/src/comp/driver/rustc.rs

Lines changed: 17 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -279,7 +279,7 @@ fn get_os(triple: str) -> session::os {
279279
session::os_macos
280280
} else if str::find(triple, "linux") >= 0 {
281281
session::os_linux
282-
} else { log_err "Unknown operating system!"; fail };
282+
} else { early_error("Unknown operating system!") };
283283
}
284284

285285
fn get_arch(triple: str) -> session::arch {
@@ -293,7 +293,7 @@ fn get_arch(triple: str) -> session::arch {
293293
} else if str::find(triple, "arm") >= 0 ||
294294
str::find(triple, "xscale") >= 0 {
295295
session::arch_arm
296-
} else { log_err "Unknown architecture! " + triple; fail };
296+
} else { early_error("Unknown architecture! " + triple) };
297297
}
298298

299299
fn build_target_config(sopts: @session::options) -> @session::config {
@@ -348,8 +348,7 @@ fn build_session_options(match: getopts::match)
348348
let opt_level: uint =
349349
if opt_present(match, "O") {
350350
if opt_present(match, "OptLevel") {
351-
log_err "error: -O and --OptLevel both provided";
352-
fail;
351+
early_error("-O and --OptLevel both provided");
353352
}
354353
2u
355354
} else if opt_present(match, "OptLevel") {
@@ -359,9 +358,8 @@ fn build_session_options(match: getopts::match)
359358
"2" { 2u }
360359
"3" { 3u }
361360
_ {
362-
log_err "error: optimization level needs " +
363-
"to be between 0-3";
364-
fail
361+
early_error("optimization level needs " +
362+
"to be between 0-3")
365363
}
366364
}
367365
} else { 0u };
@@ -485,14 +483,18 @@ fn build_output_filenames(ifile: str, ofile: option::t<str>,
485483
ret @{out_filename: saved_out_filename, obj_filename: obj_filename};
486484
}
487485

486+
fn early_error(msg: str) -> ! {
487+
codemap::print_diagnostic("", codemap::error, msg);
488+
fail;
489+
}
490+
488491
fn main(args: [str]) {
489492
let binary = vec::shift(args);
490493
let match =
491494
alt getopts::getopts(args, opts()) {
492495
getopts::success(m) { m }
493496
getopts::failure(f) {
494-
log_err #fmt["error: %s", getopts::fail_str(f)];
495-
fail
497+
early_error(getopts::fail_str(f))
496498
}
497499
};
498500
if opt_present(match, "h") || opt_present(match, "help") {
@@ -503,16 +505,15 @@ fn main(args: [str]) {
503505
version(binary);
504506
ret;
505507
}
508+
let ifile = alt vec::len(match.free) {
509+
0u { early_error("No input filename given.") }
510+
1u { match.free[0] }
511+
_ { early_error("Multiple input filenames provided.") }
512+
};
513+
506514
let sopts = build_session_options(match);
507515
let sess = build_session(sopts);
508-
let n_inputs = vec::len::<str>(match.free);
509-
if n_inputs == 0u {
510-
sess.fatal("No input filename given.");
511-
} else if n_inputs > 1u {
512-
sess.fatal("Multiple input filenames provided.");
513-
}
514516
let ofile = getopts::opt_maybe_str(match, "o");
515-
let ifile = match.free[0];
516517
let outputs = build_output_filenames(ifile, ofile, sopts);
517518
let cfg = build_configuration(sess, binary, ifile);
518519
let pretty =

0 commit comments

Comments
 (0)