2013-02-28 07:15:32 -06:00
|
|
|
// Copyright 2012-2013 The Rust Project Developers. See the COPYRIGHT
|
2012-12-03 18:48:01 -06:00
|
|
|
// file at the top-level directory of this distribution and at
|
|
|
|
// http://rust-lang.org/COPYRIGHT.
|
|
|
|
//
|
|
|
|
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
|
|
|
|
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
|
|
|
|
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
|
|
|
|
// option. This file may not be copied, modified, or distributed
|
|
|
|
// except according to those terms.
|
|
|
|
|
2011-06-30 00:35:49 -05:00
|
|
|
#[link(name = "rustc",
|
2013-04-04 23:46:37 -05:00
|
|
|
vers = "0.7-pre",
|
2011-06-30 00:35:49 -05:00
|
|
|
uuid = "0ce89b41-2f92-459e-bbc1-8f5fe32f16cf",
|
2012-03-28 15:42:17 -05:00
|
|
|
url = "https://github.com/mozilla/rust/tree/master/src/rustc")];
|
2011-06-30 00:35:49 -05:00
|
|
|
|
2012-01-23 18:25:15 -06:00
|
|
|
#[comment = "The Rust compiler"];
|
2013-03-01 10:41:31 -06:00
|
|
|
#[license = "MIT/ASL2"];
|
2012-01-17 16:40:59 -06:00
|
|
|
#[crate_type = "lib"];
|
2011-05-05 21:44:00 -05:00
|
|
|
|
2013-01-07 16:16:52 -06:00
|
|
|
#[allow(non_implicitly_copyable_typarams)];
|
2012-09-18 13:20:57 -05:00
|
|
|
#[allow(non_camel_case_types)];
|
2013-04-17 11:15:37 -05:00
|
|
|
#[deny(deprecated_pattern)];
|
2012-06-04 20:34:24 -05:00
|
|
|
|
2013-05-17 17:28:44 -05:00
|
|
|
#[no_core];
|
|
|
|
#[no_std];
|
|
|
|
|
|
|
|
extern mod core(name = "std");
|
2013-05-18 14:39:17 -05:00
|
|
|
extern mod extra(name = "extra");
|
2013-05-18 23:21:41 -05:00
|
|
|
extern mod syntax;
|
2013-03-26 21:53:33 -05:00
|
|
|
|
2013-05-18 14:39:17 -05:00
|
|
|
// For deriving(Encodable) purposes...
|
2013-05-20 17:20:16 -05:00
|
|
|
#[cfg(stage0)]
|
2013-05-18 14:39:17 -05:00
|
|
|
extern mod std(name = "extra", vers = "0.7-pre");
|
2013-05-20 17:20:16 -05:00
|
|
|
#[cfg(not(stage0))]
|
|
|
|
extern mod std(name = "std", vers = "0.7-pre");
|
2013-05-18 14:39:17 -05:00
|
|
|
|
2013-05-24 21:35:29 -05:00
|
|
|
// For bootstrapping purposes.
|
|
|
|
#[cfg(stage0)]
|
|
|
|
pub use core::str;
|
|
|
|
#[cfg(stage0)]
|
|
|
|
pub use core::unstable;
|
|
|
|
|
2013-05-17 17:28:44 -05:00
|
|
|
use core::prelude::*;
|
|
|
|
|
2013-03-26 21:53:33 -05:00
|
|
|
use driver::driver::{host_triple, optgroups, early_error};
|
|
|
|
use driver::driver::{str_input, file_input, build_session_options};
|
|
|
|
use driver::driver::{build_session, build_configuration, parse_pretty};
|
|
|
|
use driver::driver::{pp_mode, pretty_print_input, list_metadata};
|
|
|
|
use driver::driver::{compile_input};
|
|
|
|
use driver::session;
|
|
|
|
use middle::lint;
|
|
|
|
|
2013-05-24 21:35:29 -05:00
|
|
|
use core::io;
|
|
|
|
use core::os;
|
|
|
|
use core::result;
|
|
|
|
use core::str;
|
|
|
|
use core::task;
|
|
|
|
use core::uint;
|
|
|
|
use core::vec;
|
2013-05-18 14:39:17 -05:00
|
|
|
use extra::getopts::{groups, opt_present};
|
|
|
|
use extra::getopts;
|
2013-03-26 21:53:33 -05:00
|
|
|
use syntax::codemap;
|
|
|
|
use syntax::diagnostic;
|
|
|
|
|
2013-01-29 17:16:07 -06:00
|
|
|
pub mod middle {
|
|
|
|
pub mod trans {
|
2013-02-26 12:10:21 -06:00
|
|
|
pub mod macros;
|
2013-01-29 17:16:07 -06:00
|
|
|
pub mod inline;
|
|
|
|
pub mod monomorphize;
|
|
|
|
pub mod controlflow;
|
|
|
|
pub mod glue;
|
|
|
|
pub mod datum;
|
2013-05-04 13:29:32 -05:00
|
|
|
pub mod write_guard;
|
2013-01-29 17:16:07 -06:00
|
|
|
pub mod callee;
|
|
|
|
pub mod expr;
|
|
|
|
pub mod common;
|
|
|
|
pub mod consts;
|
|
|
|
pub mod type_of;
|
|
|
|
pub mod build;
|
|
|
|
pub mod base;
|
|
|
|
pub mod _match;
|
|
|
|
pub mod uniq;
|
|
|
|
pub mod closure;
|
|
|
|
pub mod tvec;
|
|
|
|
pub mod meth;
|
|
|
|
pub mod cabi;
|
2013-04-01 19:47:38 -05:00
|
|
|
pub mod cabi_x86;
|
2013-01-29 17:16:07 -06:00
|
|
|
pub mod cabi_x86_64;
|
2013-02-26 05:24:15 -06:00
|
|
|
pub mod cabi_arm;
|
2013-01-29 11:31:50 -06:00
|
|
|
pub mod cabi_mips;
|
2013-01-29 17:16:07 -06:00
|
|
|
pub mod foreign;
|
|
|
|
pub mod reflect;
|
|
|
|
pub mod shape;
|
|
|
|
pub mod debuginfo;
|
|
|
|
pub mod type_use;
|
|
|
|
pub mod reachable;
|
|
|
|
pub mod machine;
|
2013-02-18 16:16:21 -06:00
|
|
|
pub mod adt;
|
2013-03-27 14:50:57 -05:00
|
|
|
pub mod asm;
|
2012-01-27 06:17:06 -06:00
|
|
|
}
|
2013-01-29 17:16:07 -06:00
|
|
|
pub mod ty;
|
Cleanup substitutions and treatment of generics around traits in a number of ways.
- In a TraitRef, use the self type consistently to refer to the Self type:
- trait ref in `impl Trait<A,B,C> for S` has a self type of `S`.
- trait ref in `A:Trait` has the self type `A`
- trait ref associated with a trait decl has self type `Self`
- trait ref associated with a supertype has self type `Self`
- trait ref in an object type `@Trait` has no self type
- Rewrite `each_bound_traits_and_supertraits` to perform
substitutions as it goes, and thus yield a series of trait refs
that are always in the same 'namespace' as the type parameter
bound given as input. Before, we left this to the caller, but
this doesn't work because the caller lacks adequare information
to perform the type substitutions correctly.
- For provided methods, substitute the generics involved in the provided
method correctly.
- Introduce TypeParameterDef, which tracks the bounds declared on a type
parameter and brings them together with the def_id and (in the future)
other information (maybe even the parameter's name!).
- Introduce Subst trait, which helps to cleanup a lot of the
repetitive code involved with doing type substitution.
- Introduce Repr trait, which makes debug printouts far more convenient.
Fixes #4183. Needed for #5656.
2013-04-09 00:54:49 -05:00
|
|
|
pub mod subst;
|
2013-01-29 17:16:07 -06:00
|
|
|
pub mod resolve;
|
2012-12-19 16:17:53 -06:00
|
|
|
#[path = "typeck/mod.rs"]
|
2012-11-28 14:33:00 -06:00
|
|
|
pub mod typeck;
|
2013-01-29 17:16:07 -06:00
|
|
|
pub mod check_loop;
|
|
|
|
pub mod check_match;
|
|
|
|
pub mod check_const;
|
|
|
|
pub mod lint;
|
2012-12-19 16:17:53 -06:00
|
|
|
#[path = "borrowck/mod.rs"]
|
2012-12-13 15:05:22 -06:00
|
|
|
pub mod borrowck;
|
2013-04-17 17:05:17 -05:00
|
|
|
pub mod dataflow;
|
2013-01-29 17:16:07 -06:00
|
|
|
pub mod mem_categorization;
|
|
|
|
pub mod liveness;
|
|
|
|
pub mod kind;
|
|
|
|
pub mod freevars;
|
|
|
|
pub mod pat_util;
|
|
|
|
pub mod region;
|
|
|
|
pub mod const_eval;
|
|
|
|
pub mod astencode;
|
|
|
|
pub mod lang_items;
|
|
|
|
pub mod privacy;
|
2013-01-10 12:59:58 -06:00
|
|
|
pub mod moves;
|
2013-04-29 16:56:05 -05:00
|
|
|
pub mod entry;
|
2013-05-23 21:12:16 -05:00
|
|
|
pub mod effect;
|
2011-04-19 18:40:46 -05:00
|
|
|
}
|
|
|
|
|
2013-01-29 17:16:07 -06:00
|
|
|
pub mod front {
|
|
|
|
pub mod config;
|
|
|
|
pub mod test;
|
2013-05-17 15:12:42 -05:00
|
|
|
pub mod std_inject;
|
2013-01-29 17:16:07 -06:00
|
|
|
pub mod intrinsic_inject;
|
2010-06-23 23:03:09 -05:00
|
|
|
}
|
|
|
|
|
2013-01-29 17:16:07 -06:00
|
|
|
pub mod back {
|
|
|
|
pub mod link;
|
|
|
|
pub mod abi;
|
|
|
|
pub mod upcall;
|
|
|
|
pub mod arm;
|
2013-01-29 08:28:08 -06:00
|
|
|
pub mod mips;
|
2013-01-29 17:16:07 -06:00
|
|
|
pub mod x86;
|
|
|
|
pub mod x86_64;
|
|
|
|
pub mod rpath;
|
|
|
|
pub mod target_strs;
|
2013-05-27 18:15:31 -05:00
|
|
|
pub mod passes;
|
2010-09-23 17:46:31 -05:00
|
|
|
}
|
|
|
|
|
2012-11-28 18:20:41 -06:00
|
|
|
#[path = "metadata/mod.rs"]
|
2013-01-29 17:16:07 -06:00
|
|
|
pub mod metadata;
|
2011-06-27 18:38:57 -05:00
|
|
|
|
2012-11-28 18:20:41 -06:00
|
|
|
#[path = "driver/mod.rs"]
|
2013-01-29 17:16:07 -06:00
|
|
|
pub mod driver;
|
2010-06-23 23:03:09 -05:00
|
|
|
|
2013-01-29 17:16:07 -06:00
|
|
|
pub mod util {
|
|
|
|
pub mod common;
|
|
|
|
pub mod ppaux;
|
2013-05-07 16:30:21 -05:00
|
|
|
pub mod enum_set;
|
2010-08-18 13:34:47 -05:00
|
|
|
}
|
|
|
|
|
2013-01-29 17:16:07 -06:00
|
|
|
pub mod lib {
|
|
|
|
pub mod llvm;
|
2010-07-12 19:47:40 -05:00
|
|
|
}
|
|
|
|
|
2013-05-24 21:35:29 -05:00
|
|
|
// A curious inner module that allows ::std::foo to be available in here for
|
|
|
|
// macros.
|
|
|
|
mod std {
|
|
|
|
pub use core::cmp;
|
|
|
|
pub use core::os;
|
|
|
|
pub use core::str;
|
|
|
|
pub use core::sys;
|
|
|
|
pub use core::to_bytes;
|
|
|
|
pub use core::unstable;
|
|
|
|
pub use extra::serialize;
|
|
|
|
}
|
|
|
|
|
2013-01-29 17:16:07 -06:00
|
|
|
pub fn version(argv0: &str) {
|
2012-11-28 14:33:00 -06:00
|
|
|
let mut vers = ~"unknown version";
|
|
|
|
let env_vers = env!("CFG_VERSION");
|
2013-05-19 00:07:44 -05:00
|
|
|
if env_vers.len() != 0 { vers = env_vers.to_owned(); }
|
2012-11-28 14:33:00 -06:00
|
|
|
io::println(fmt!("%s %s", argv0, vers));
|
|
|
|
io::println(fmt!("host: %s", host_triple()));
|
|
|
|
}
|
|
|
|
|
2013-01-29 17:16:07 -06:00
|
|
|
pub fn usage(argv0: &str) {
|
2012-11-28 14:33:00 -06:00
|
|
|
let message = fmt!("Usage: %s [OPTIONS] INPUT", argv0);
|
2013-05-27 19:45:16 -05:00
|
|
|
io::println(fmt!("%s \
|
|
|
|
Additional help: \
|
|
|
|
-W help Print 'lint' options and default settings \
|
|
|
|
-Z help Print internal options for debugging rustc",
|
|
|
|
groups::usage(message, optgroups())));
|
2012-11-28 14:33:00 -06:00
|
|
|
}
|
|
|
|
|
2013-01-29 17:16:07 -06:00
|
|
|
pub fn describe_warnings() {
|
2012-11-28 14:33:00 -06:00
|
|
|
io::println(fmt!("
|
|
|
|
Available lint options:
|
|
|
|
-W <foo> Warn about <foo>
|
|
|
|
-A <foo> Allow <foo>
|
|
|
|
-D <foo> Deny <foo>
|
|
|
|
-F <foo> Forbid <foo> (deny, and deny all overrides)
|
|
|
|
"));
|
|
|
|
|
|
|
|
let lint_dict = lint::get_lint_dict();
|
|
|
|
let mut max_key = 0;
|
2013-03-22 21:26:41 -05:00
|
|
|
for lint_dict.each_key |k| { max_key = uint::max(k.len(), max_key); }
|
2012-11-28 14:33:00 -06:00
|
|
|
fn padded(max: uint, s: &str) -> ~str {
|
|
|
|
str::from_bytes(vec::from_elem(max - s.len(), ' ' as u8)) + s
|
|
|
|
}
|
|
|
|
io::println(fmt!("\nAvailable lint checks:\n"));
|
|
|
|
io::println(fmt!(" %s %7.7s %s",
|
2013-05-19 00:07:44 -05:00
|
|
|
padded(max_key, "name"), "default", "meaning"));
|
2012-11-28 14:33:00 -06:00
|
|
|
io::println(fmt!(" %s %7.7s %s\n",
|
2013-05-19 00:07:44 -05:00
|
|
|
padded(max_key, "----"), "-------", "-------"));
|
2013-04-06 10:22:36 -05:00
|
|
|
for lint_dict.each |k, v| {
|
2013-05-19 00:07:44 -05:00
|
|
|
let k = str::replace(*k, "_", "-");
|
2012-11-28 14:33:00 -06:00
|
|
|
io::println(fmt!(" %s %7.7s %s",
|
|
|
|
padded(max_key, k),
|
|
|
|
match v.default {
|
|
|
|
lint::allow => ~"allow",
|
|
|
|
lint::warn => ~"warn",
|
|
|
|
lint::deny => ~"deny",
|
|
|
|
lint::forbid => ~"forbid"
|
|
|
|
},
|
|
|
|
v.desc));
|
|
|
|
}
|
2013-05-19 00:07:44 -05:00
|
|
|
io::println("");
|
2012-11-28 14:33:00 -06:00
|
|
|
}
|
|
|
|
|
2013-01-29 17:16:07 -06:00
|
|
|
pub fn describe_debug_flags() {
|
2012-11-28 14:33:00 -06:00
|
|
|
io::println(fmt!("\nAvailable debug options:\n"));
|
|
|
|
for session::debugging_opts_map().each |pair| {
|
2013-01-07 16:16:52 -06:00
|
|
|
let (name, desc, _) = /*bad*/copy *pair;
|
2012-11-28 14:33:00 -06:00
|
|
|
io::println(fmt!(" -Z %-20s -- %s", name, desc));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-02-04 16:02:01 -06:00
|
|
|
pub fn run_compiler(args: &~[~str], demitter: diagnostic::Emitter) {
|
2012-11-28 14:33:00 -06:00
|
|
|
// Don't display log spew by default. Can override with RUST_LOG.
|
2013-03-26 21:53:33 -05:00
|
|
|
::core::logging::console_off();
|
2012-11-28 14:33:00 -06:00
|
|
|
|
2013-01-07 16:16:52 -06:00
|
|
|
let mut args = /*bad*/copy *args;
|
2013-04-16 18:10:21 -05:00
|
|
|
let binary = @args.shift();
|
2012-11-28 14:33:00 -06:00
|
|
|
|
2013-04-16 18:10:21 -05:00
|
|
|
if args.is_empty() { usage(*binary); return; }
|
2012-11-28 14:33:00 -06:00
|
|
|
|
|
|
|
let matches =
|
2012-11-28 14:38:53 -06:00
|
|
|
&match getopts::groups::getopts(args, optgroups()) {
|
2013-01-10 12:59:58 -06:00
|
|
|
Ok(m) => m,
|
|
|
|
Err(f) => {
|
|
|
|
early_error(demitter, getopts::fail_str(f));
|
2012-11-28 14:33:00 -06:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2013-05-19 00:07:44 -05:00
|
|
|
if opt_present(matches, "h") || opt_present(matches, "help") {
|
2013-04-16 18:10:21 -05:00
|
|
|
usage(*binary);
|
2012-11-28 14:33:00 -06:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2013-05-24 14:32:30 -05:00
|
|
|
// Display the available lint options if "-W help" or only "-W" is given.
|
2013-05-19 00:07:44 -05:00
|
|
|
let lint_flags = vec::append(getopts::opt_strs(matches, "W"),
|
|
|
|
getopts::opt_strs(matches, "warn"));
|
2013-05-24 14:32:30 -05:00
|
|
|
|
|
|
|
let show_lint_options = lint_flags.contains(&~"help") ||
|
|
|
|
(opt_present(matches, "W") && lint_flags.is_empty());
|
|
|
|
|
|
|
|
if show_lint_options {
|
2012-11-28 14:33:00 -06:00
|
|
|
describe_warnings();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2013-05-19 00:07:44 -05:00
|
|
|
if getopts::opt_strs(matches, "Z").contains(&~"help") {
|
2012-11-28 14:33:00 -06:00
|
|
|
describe_debug_flags();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2013-05-29 03:08:20 -05:00
|
|
|
if getopts::opt_maybe_str(matches, "passes") == Some(~"list") {
|
|
|
|
back::passes::list_passes();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2013-05-19 00:07:44 -05:00
|
|
|
if opt_present(matches, "v") || opt_present(matches, "version") {
|
2013-04-16 18:10:21 -05:00
|
|
|
version(*binary);
|
2012-11-28 14:33:00 -06:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
let input = match vec::len(matches.free) {
|
|
|
|
0u => early_error(demitter, ~"no input filename given"),
|
|
|
|
1u => {
|
2013-01-07 16:16:52 -06:00
|
|
|
let ifile = /*bad*/copy matches.free[0];
|
2012-11-28 14:33:00 -06:00
|
|
|
if ifile == ~"-" {
|
|
|
|
let src = str::from_bytes(io::stdin().read_whole_stream());
|
|
|
|
str_input(src)
|
|
|
|
} else {
|
|
|
|
file_input(Path(ifile))
|
|
|
|
}
|
|
|
|
}
|
|
|
|
_ => early_error(demitter, ~"multiple input filenames provided")
|
|
|
|
};
|
|
|
|
|
2013-04-16 18:10:21 -05:00
|
|
|
let sopts = build_session_options(binary, matches, demitter);
|
2012-11-28 14:33:00 -06:00
|
|
|
let sess = build_session(sopts, demitter);
|
2013-05-19 00:07:44 -05:00
|
|
|
let odir = getopts::opt_maybe_str(matches, "out-dir");
|
2012-11-28 14:33:00 -06:00
|
|
|
let odir = odir.map(|o| Path(*o));
|
2013-05-19 00:07:44 -05:00
|
|
|
let ofile = getopts::opt_maybe_str(matches, "o");
|
2012-11-28 14:33:00 -06:00
|
|
|
let ofile = ofile.map(|o| Path(*o));
|
2013-04-17 11:15:37 -05:00
|
|
|
let cfg = build_configuration(sess, binary, &input);
|
2013-05-19 00:07:44 -05:00
|
|
|
let pretty = getopts::opt_default(matches, "pretty", "normal").map(
|
2013-03-16 14:49:12 -05:00
|
|
|
|a| parse_pretty(sess, *a));
|
2012-11-28 14:33:00 -06:00
|
|
|
match pretty {
|
|
|
|
Some::<pp_mode>(ppm) => {
|
2013-04-17 11:15:37 -05:00
|
|
|
pretty_print_input(sess, cfg, &input, ppm);
|
2012-11-28 14:33:00 -06:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
None::<pp_mode> => {/* continue */ }
|
|
|
|
}
|
2013-05-19 00:07:44 -05:00
|
|
|
let ls = opt_present(matches, "ls");
|
2012-11-28 14:33:00 -06:00
|
|
|
if ls {
|
|
|
|
match input {
|
2012-12-04 12:50:00 -06:00
|
|
|
file_input(ref ifile) => {
|
|
|
|
list_metadata(sess, &(*ifile), io::stdout());
|
2012-11-28 14:33:00 -06:00
|
|
|
}
|
|
|
|
str_input(_) => {
|
|
|
|
early_error(demitter, ~"can not list metadata for stdin");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2013-04-17 11:15:37 -05:00
|
|
|
compile_input(sess, cfg, &input, &odir, &ofile);
|
2012-11-28 14:33:00 -06:00
|
|
|
}
|
|
|
|
|
2013-03-20 10:40:02 -05:00
|
|
|
#[deriving(Eq)]
|
2013-01-29 17:16:07 -06:00
|
|
|
pub enum monitor_msg {
|
2012-11-28 14:33:00 -06:00
|
|
|
fatal,
|
|
|
|
done,
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
This is a sanity check that any failure of the compiler is performed
|
|
|
|
through the diagnostic module and reported properly - we shouldn't be calling
|
|
|
|
plain-old-fail on any execution path that might be taken. Since we have
|
|
|
|
console logging off by default, hitting a plain fail statement would make the
|
|
|
|
compiler silently exit, which would be terrible.
|
|
|
|
|
|
|
|
This method wraps the compiler in a subtask and injects a function into the
|
|
|
|
diagnostic emitter which records when we hit a fatal error. If the task
|
|
|
|
fails without recording a fatal error then we've encountered a compiler
|
|
|
|
bug and need to present an error.
|
|
|
|
*/
|
2013-04-17 11:15:37 -05:00
|
|
|
pub fn monitor(f: ~fn(diagnostic::Emitter)) {
|
2013-02-02 05:10:12 -06:00
|
|
|
use core::comm::*;
|
2013-01-30 03:52:01 -06:00
|
|
|
let (p, ch) = stream();
|
2013-04-17 01:45:29 -05:00
|
|
|
let ch = SharedChan::new(ch);
|
2013-01-30 03:52:01 -06:00
|
|
|
let ch_capture = ch.clone();
|
2013-02-15 03:14:34 -06:00
|
|
|
match do task::try || {
|
2013-01-30 03:52:01 -06:00
|
|
|
let ch = ch_capture.clone();
|
|
|
|
let ch_capture = ch.clone();
|
2012-11-28 14:33:00 -06:00
|
|
|
// The 'diagnostics emitter'. Every error, warning, etc. should
|
|
|
|
// go through this function.
|
2013-03-01 14:11:07 -06:00
|
|
|
let demitter: @fn(Option<(@codemap::CodeMap, codemap::span)>,
|
|
|
|
&str,
|
|
|
|
diagnostic::level) =
|
|
|
|
|cmsp, msg, lvl| {
|
2012-11-28 14:33:00 -06:00
|
|
|
if lvl == diagnostic::fatal {
|
2013-01-30 03:52:01 -06:00
|
|
|
ch_capture.send(fatal);
|
2012-11-28 14:33:00 -06:00
|
|
|
}
|
|
|
|
diagnostic::emit(cmsp, msg, lvl);
|
|
|
|
};
|
|
|
|
|
|
|
|
struct finally {
|
2013-01-30 03:52:01 -06:00
|
|
|
ch: SharedChan<monitor_msg>,
|
2013-02-27 18:13:53 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
impl Drop for finally {
|
|
|
|
fn finalize(&self) { self.ch.send(done); }
|
2012-11-28 14:33:00 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
let _finally = finally { ch: ch };
|
|
|
|
|
|
|
|
f(demitter)
|
|
|
|
} {
|
|
|
|
result::Ok(_) => { /* fallthrough */ }
|
|
|
|
result::Err(_) => {
|
|
|
|
// Task failed without emitting a fatal diagnostic
|
2013-01-30 03:52:01 -06:00
|
|
|
if p.recv() == done {
|
2012-11-28 14:33:00 -06:00
|
|
|
diagnostic::emit(
|
|
|
|
None,
|
2013-05-19 00:07:44 -05:00
|
|
|
diagnostic::ice_msg("unexpected failure"),
|
2012-11-28 14:33:00 -06:00
|
|
|
diagnostic::error);
|
|
|
|
|
|
|
|
for [
|
|
|
|
~"the compiler hit an unexpected failure path. \
|
|
|
|
this is a bug",
|
|
|
|
~"try running with RUST_LOG=rustc=1,::rt::backtrace \
|
|
|
|
to get further details and report the results \
|
|
|
|
to github.com/mozilla/rust/issues"
|
|
|
|
].each |note| {
|
|
|
|
diagnostic::emit(None, *note, diagnostic::note)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
// Fail so the process returns a failure code
|
2013-02-11 21:26:38 -06:00
|
|
|
fail!();
|
2012-11-28 14:33:00 -06:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-01-29 17:16:07 -06:00
|
|
|
pub fn main() {
|
2013-01-10 12:59:58 -06:00
|
|
|
let args = os::args();
|
2013-02-15 03:14:34 -06:00
|
|
|
do monitor |demitter| {
|
2012-11-28 14:33:00 -06:00
|
|
|
run_compiler(&args, demitter);
|
|
|
|
}
|
|
|
|
}
|