From dbf6ed922155cad7306dc4f93e1951e2f35443ab Mon Sep 17 00:00:00 2001 From: Brian Anderson Date: Fri, 13 Jan 2012 18:35:16 -0800 Subject: [PATCH] rustc: Remove emit_fatal/error/warning/note functions --- src/comp/driver/diagnostic.rs | 34 +++++++++++----------------------- src/comp/driver/driver.rs | 2 +- 2 files changed, 12 insertions(+), 24 deletions(-) diff --git a/src/comp/driver/diagnostic.rs b/src/comp/driver/diagnostic.rs index 261a934f3a6e..e1c360daf12a 100644 --- a/src/comp/driver/diagnostic.rs +++ b/src/comp/driver/diagnostic.rs @@ -3,7 +3,8 @@ import io::writer_util; import syntax::codemap; import codemap::span; -export emit_warning, emit_error, emit_note; +export emit_diagnostic; +export diagnostictype, fatal, error, warning, note; export handler, mk_codemap_handler; iface handler { @@ -30,19 +31,19 @@ type codemap_t = @{ impl codemap_handler of handler for codemap_t { fn span_fatal(sp: span, msg: str) -> ! { - emit_fatal(some((self.cm, sp)), msg); + emit_diagnostic(some((self.cm, sp)), msg, fatal); fail; } fn fatal(msg: str) -> ! { - emit_fatal(none, msg); + emit_diagnostic(none, msg, fatal); fail; } fn span_err(sp: span, msg: str) { - emit_error(some((self.cm, sp)), msg); + emit_diagnostic(some((self.cm, sp)), msg, error); self.err_count += 1u; } fn err(msg: str) { - emit_error(none, msg); + emit_diagnostic(none, msg, error); self.err_count += 1u; } fn has_errors() -> bool { self.err_count > 0u } @@ -52,16 +53,16 @@ impl codemap_handler of handler for codemap_t { } } fn span_warn(sp: span, msg: str) { - emit_warning(some((self.cm, sp)), msg); + emit_diagnostic(some((self.cm, sp)), msg, warning); } fn warn(msg: str) { - emit_warning(none, msg); + emit_diagnostic(none, msg, warning); } fn span_note(sp: span, msg: str) { - emit_note(some((self.cm, sp)), msg); + emit_diagnostic(some((self.cm, sp)), msg, note); } fn note(msg: str) { - emit_note(none, msg); + emit_diagnostic(none, msg, note); } fn span_bug(sp: span, msg: str) -> ! { self.span_fatal(sp, #fmt["internal compiler error %s", msg]); @@ -148,7 +149,7 @@ fn highlight_lines(cm: codemap::codemap, sp: span, let file = alt io::read_whole_file_str(lines.name) { result::ok(file) { file } result::err(e) { - emit_error(none, e); + emit_diagnostic(none, e, fatal); fail; } }; @@ -204,16 +205,3 @@ fn highlight_lines(cm: codemap::codemap, sp: span, io::stdout().write_str(s + "\n"); } } - -fn emit_fatal(cmsp: option<(codemap::codemap, span)>, msg: str) { - emit_diagnostic(cmsp, msg, fatal); -} -fn emit_error(cmsp: option<(codemap::codemap, span)>, msg: str) { - emit_diagnostic(cmsp, msg, error); -} -fn emit_warning(cmsp: option<(codemap::codemap, span)>, msg: str) { - emit_diagnostic(cmsp, msg, warning); -} -fn emit_note(cmsp: option<(codemap::codemap, span)>, msg: str) { - emit_diagnostic(cmsp, msg, note); -} diff --git a/src/comp/driver/driver.rs b/src/comp/driver/driver.rs index 2e5807ce2d1e..278ffb9b6059 100644 --- a/src/comp/driver/driver.rs +++ b/src/comp/driver/driver.rs @@ -585,7 +585,7 @@ fn build_output_filenames(ifile: str, } fn early_error(msg: str) -> ! { - diagnostic::emit_error(none, msg); + diagnostic::emit_diagnostic(none, msg, diagnostic::fatal); fail; }