about summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--src/comp/driver/diagnostic.rs2
-rw-r--r--src/comp/driver/driver.rs2
-rw-r--r--src/comp/driver/session.rs40
3 files changed, 21 insertions, 23 deletions
diff --git a/src/comp/driver/diagnostic.rs b/src/comp/driver/diagnostic.rs
index 28818c38fa0..83ca4181448 100644
--- a/src/comp/driver/diagnostic.rs
+++ b/src/comp/driver/diagnostic.rs
@@ -4,7 +4,7 @@ import syntax::codemap;
 import codemap::span;
 
 export emit_warning, emit_error, emit_note;
-export handler, codemap_handler;
+export handler, mk_codemap_handler;
 
 iface handler {
     fn span_fatal(sp: span, msg: str) -> !;
diff --git a/src/comp/driver/driver.rs b/src/comp/driver/driver.rs
index e9c8cd54c3f..af911e06646 100644
--- a/src/comp/driver/driver.rs
+++ b/src/comp/driver/driver.rs
@@ -459,7 +459,7 @@ fn build_session(sopts: @session::options, input: str) -> session::session {
       codemap: codemap,
       // For a library crate, this is always none
       mutable main_fn: none,
-      mutable err_count: 0u,
+      diagnostic: diagnostic::mk_codemap_handler(codemap),
       filesearch: filesearch,
       mutable building_library: false,
       working_dir: fs::dirname(input)}
diff --git a/src/comp/driver/session.rs b/src/comp/driver/session.rs
index fc8bc444e20..b68be2c2f18 100644
--- a/src/comp/driver/session.rs
+++ b/src/comp/driver/session.rs
@@ -58,56 +58,54 @@ type session = @{targ_cfg: @config,
                  codemap: codemap::codemap,
                  // For a library crate, this is always none
                  mutable main_fn: option::t<node_id>,
-                 mutable err_count: uint,
+                 diagnostic: diagnostic::handler,
                  filesearch: filesearch::filesearch,
                  mutable building_library: bool,
                  working_dir: str};
 
 impl session for session {
     fn span_fatal(sp: span, msg: str) -> ! {
-        diagnostic::emit_error(some((self.parse_sess.cm, sp)), msg);
-        fail;
+        self.diagnostic.span_fatal(sp, msg)
     }
     fn fatal(msg: str) -> ! {
-        diagnostic::emit_error(none, msg);
-        fail;
+        self.diagnostic.fatal(msg)
     }
     fn span_err(sp: span, msg: str) {
-        diagnostic::emit_error(some((self.parse_sess.cm, sp)), msg);
-        self.err_count += 1u;
+        self.diagnostic.span_err(sp, msg)
     }
     fn err(msg: str) {
-        diagnostic::emit_error(none, msg);
-        self.err_count += 1u;
+        self.diagnostic.err(msg)
+    }
+    fn has_errors() -> bool {
+        self.diagnostic.has_errors()
     }
-    fn has_errors() -> bool { self.err_count > 0u }
     fn abort_if_errors() {
-        if self.err_count > 0u {
-            self.fatal("aborting due to previous errors");
-        }
+        self.diagnostic.abort_if_errors()
     }
     fn span_warn(sp: span, msg: str) {
-        diagnostic::emit_warning(some((self.parse_sess.cm, sp)), msg);
+        self.diagnostic.span_warn(sp, msg)
     }
     fn warn(msg: str) {
-        diagnostic::emit_warning(none, msg);
+        self.diagnostic.warn(msg)
     }
     fn span_note(sp: span, msg: str) {
-        diagnostic::emit_note(some((self.parse_sess.cm, sp)), msg);
+        self.diagnostic.span_note(sp, msg)
     }
     fn note(msg: str) {
-        diagnostic::emit_note(none, msg);
+        self.diagnostic.note(msg)
     }
     fn span_bug(sp: span, msg: str) -> ! {
-        self.span_fatal(sp, #fmt["internal compiler error %s", msg]);
+        self.diagnostic.span_bug(sp, msg)
     }
     fn bug(msg: str) -> ! {
-        self.fatal(#fmt["internal compiler error %s", msg]);
+        self.diagnostic.bug(msg)
     }
     fn span_unimpl(sp: span, msg: str) -> ! {
-        self.span_bug(sp, "unimplemented " + msg);
+        self.diagnostic.span_unimpl(sp, msg)
+    }
+    fn unimpl(msg: str) -> ! {
+        self.diagnostic.unimpl(msg)
     }
-    fn unimpl(msg: str) -> ! { self.bug("unimplemented " + msg); }
     fn next_node_id() -> ast::node_id {
         ret syntax::parse::parser::next_node_id(self.parse_sess);
     }