Add handy switch -Z treat-err-as-bug
-- it often happens that I am
compiling something I expect to succeed, and this lets me get stacktraces and also abort compilation faster.
This commit is contained in:
parent
cf73e36ab0
commit
31e09f740a
2 changed files with 15 additions and 0 deletions
|
@ -99,6 +99,7 @@ pub struct Options {
|
||||||
pub test: bool,
|
pub test: bool,
|
||||||
pub parse_only: bool,
|
pub parse_only: bool,
|
||||||
pub no_trans: bool,
|
pub no_trans: bool,
|
||||||
|
pub treat_err_as_bug: bool,
|
||||||
pub no_analysis: bool,
|
pub no_analysis: bool,
|
||||||
pub debugging_opts: DebuggingOptions,
|
pub debugging_opts: DebuggingOptions,
|
||||||
/// Whether to write dependency files. It's (enabled, optional filename).
|
/// Whether to write dependency files. It's (enabled, optional filename).
|
||||||
|
@ -223,6 +224,7 @@ pub fn basic_options() -> Options {
|
||||||
test: false,
|
test: false,
|
||||||
parse_only: false,
|
parse_only: false,
|
||||||
no_trans: false,
|
no_trans: false,
|
||||||
|
treat_err_as_bug: false,
|
||||||
no_analysis: false,
|
no_analysis: false,
|
||||||
debugging_opts: basic_debugging_options(),
|
debugging_opts: basic_debugging_options(),
|
||||||
write_dependency_info: (false, None),
|
write_dependency_info: (false, None),
|
||||||
|
@ -573,6 +575,8 @@ options! {DebuggingOptions, DebuggingSetter, basic_debugging_options,
|
||||||
"Parse only; do not compile, assemble, or link"),
|
"Parse only; do not compile, assemble, or link"),
|
||||||
no_trans: bool = (false, parse_bool,
|
no_trans: bool = (false, parse_bool,
|
||||||
"Run all passes except translation; no output"),
|
"Run all passes except translation; no output"),
|
||||||
|
treat_err_as_bug: bool = (false, parse_bool,
|
||||||
|
"Treat all errors that occur as bugs"),
|
||||||
no_analysis: bool = (false, parse_bool,
|
no_analysis: bool = (false, parse_bool,
|
||||||
"Parse and expand the source, but run no analysis"),
|
"Parse and expand the source, but run no analysis"),
|
||||||
extra_plugins: Vec<String> = (Vec::new(), parse_list,
|
extra_plugins: Vec<String> = (Vec::new(), parse_list,
|
||||||
|
@ -843,6 +847,7 @@ pub fn build_session_options(matches: &getopts::Matches) -> Options {
|
||||||
|
|
||||||
let parse_only = debugging_opts.parse_only;
|
let parse_only = debugging_opts.parse_only;
|
||||||
let no_trans = debugging_opts.no_trans;
|
let no_trans = debugging_opts.no_trans;
|
||||||
|
let treat_err_as_bug = debugging_opts.treat_err_as_bug;
|
||||||
let no_analysis = debugging_opts.no_analysis;
|
let no_analysis = debugging_opts.no_analysis;
|
||||||
|
|
||||||
if debugging_opts.debug_llvm {
|
if debugging_opts.debug_llvm {
|
||||||
|
@ -1030,6 +1035,7 @@ pub fn build_session_options(matches: &getopts::Matches) -> Options {
|
||||||
test: test,
|
test: test,
|
||||||
parse_only: parse_only,
|
parse_only: parse_only,
|
||||||
no_trans: no_trans,
|
no_trans: no_trans,
|
||||||
|
treat_err_as_bug: treat_err_as_bug,
|
||||||
no_analysis: no_analysis,
|
no_analysis: no_analysis,
|
||||||
debugging_opts: debugging_opts,
|
debugging_opts: debugging_opts,
|
||||||
write_dependency_info: write_dependency_info,
|
write_dependency_info: write_dependency_info,
|
||||||
|
|
|
@ -74,18 +74,27 @@ impl Session {
|
||||||
self.diagnostic().handler().fatal(msg)
|
self.diagnostic().handler().fatal(msg)
|
||||||
}
|
}
|
||||||
pub fn span_err(&self, sp: Span, msg: &str) {
|
pub fn span_err(&self, sp: Span, msg: &str) {
|
||||||
|
if self.opts.treat_err_as_bug {
|
||||||
|
self.span_bug(sp, msg);
|
||||||
|
}
|
||||||
match split_msg_into_multilines(msg) {
|
match split_msg_into_multilines(msg) {
|
||||||
Some(msg) => self.diagnostic().span_err(sp, &msg[..]),
|
Some(msg) => self.diagnostic().span_err(sp, &msg[..]),
|
||||||
None => self.diagnostic().span_err(sp, msg)
|
None => self.diagnostic().span_err(sp, msg)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
pub fn span_err_with_code(&self, sp: Span, msg: &str, code: &str) {
|
pub fn span_err_with_code(&self, sp: Span, msg: &str, code: &str) {
|
||||||
|
if self.opts.treat_err_as_bug {
|
||||||
|
self.span_bug(sp, msg);
|
||||||
|
}
|
||||||
match split_msg_into_multilines(msg) {
|
match split_msg_into_multilines(msg) {
|
||||||
Some(msg) => self.diagnostic().span_err_with_code(sp, &msg[..], code),
|
Some(msg) => self.diagnostic().span_err_with_code(sp, &msg[..], code),
|
||||||
None => self.diagnostic().span_err_with_code(sp, msg, code)
|
None => self.diagnostic().span_err_with_code(sp, msg, code)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
pub fn err(&self, msg: &str) {
|
pub fn err(&self, msg: &str) {
|
||||||
|
if self.opts.treat_err_as_bug {
|
||||||
|
self.bug(msg);
|
||||||
|
}
|
||||||
self.diagnostic().handler().err(msg)
|
self.diagnostic().handler().err(msg)
|
||||||
}
|
}
|
||||||
pub fn err_count(&self) -> uint {
|
pub fn err_count(&self) -> uint {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue