-use errors::{Diagnostic, DiagnosticBuilder};
+use errors::Diagnostic;
use rustc_data_structures::stable_hasher::{HashStable, StableHasher};
use rustc_data_structures::fx::{FxHashMap, FxHashSet};
use rustc_data_structures::indexed_vec::{Idx, IndexVec};
let handle = tcx.sess.diagnostic();
for diagnostic in diagnostics {
- DiagnosticBuilder::new_diagnostic(handle, diagnostic).emit();
+ handle.emit_diagnostic(&diagnostic);
}
// Mark the node as green now that diagnostics are emitted
let mut i = 0;
while let Some(query) = current_query {
- let mut db = DiagnosticBuilder::new(icx.tcx.sess.diagnostic(),
- Level::FailureNote,
+ let mut diag = Diagnostic::new(Level::FailureNote,
&format!("#{} [{}] {}",
i,
query.info.query.name(),
query.info.query.describe(icx.tcx)));
- db.set_span(icx.tcx.sess.source_map().def_span(query.info.span));
- icx.tcx.sess.diagnostic().force_print_db(db);
+ diag.span = icx.tcx.sess.source_map().def_span(query.info.span).into();
+ icx.tcx.sess.diagnostic().force_print_diagnostic(diag);
current_query = query.parent.clone();
i += 1;
/// Convenience function for internal use, clients should use one of the
/// struct_* methods on Handler.
- pub fn new(handler: &'a Handler, level: Level, message: &str) -> DiagnosticBuilder<'a> {
+ crate fn new(handler: &'a Handler, level: Level, message: &str) -> DiagnosticBuilder<'a> {
DiagnosticBuilder::new_with_code(handler, level, None, message)
}
/// Creates a new `DiagnosticBuilder` with an already constructed
/// diagnostic.
- pub fn new_diagnostic(handler: &'a Handler, diagnostic: Diagnostic) -> DiagnosticBuilder<'a> {
+ crate fn new_diagnostic(handler: &'a Handler, diagnostic: Diagnostic)
+ -> DiagnosticBuilder<'a> {
DiagnosticBuilder(Box::new(DiagnosticBuilderInner {
handler,
diagnostic,
self.taught_diagnostics.borrow_mut().insert(code.clone())
}
- pub fn force_print_db(&self, mut db: DiagnosticBuilder<'_>) {
+ pub fn force_print_diagnostic(&self, db: Diagnostic) {
self.emitter.borrow_mut().emit_diagnostic(&db);
- db.cancel();
}
- fn emit_diagnostic(&self, diagnostic: &Diagnostic) {
+ pub fn emit_diagnostic(&self, diagnostic: &Diagnostic) {
if diagnostic.cancelled() {
return;
}
}
for diag in mbcx.errors_buffer.drain(..) {
- DiagnosticBuilder::new_diagnostic(mbcx.infcx.tcx.sess.diagnostic(), diag).emit();
+ mbcx.infcx.tcx.sess.diagnostic().emit_diagnostic(&diag);
}
}
// substitutions.
use crate::check::FnCtxt;
-use errors::DiagnosticBuilder;
use rustc::hir;
use rustc::hir::def_id::{DefId, DefIndex};
use rustc::hir::intravisit::{self, NestedVisitorMap, Visitor};
if !errors_buffer.is_empty() {
errors_buffer.sort_by_key(|diag| diag.span.primary_span());
for diag in errors_buffer.drain(..) {
- DiagnosticBuilder::new_diagnostic(self.tcx().sess.diagnostic(), diag).emit();
+ self.tcx().sess.diagnostic().emit_diagnostic(&diag);
}
}
}
use crate::parse::lexer::comments;
use crate::tokenstream::{self, DelimSpan, IsJoint::*, TokenStream, TreeAndJoint};
-use errors::{Diagnostic, DiagnosticBuilder};
+use errors::Diagnostic;
use rustc_data_structures::sync::Lrc;
use syntax_pos::{BytePos, FileName, MultiSpan, Pos, SourceFile, Span};
use syntax_pos::symbol::{kw, sym, Symbol};
diag.sub(level.to_internal(), msg, MultiSpan::from_spans(spans), None);
}
fn emit(&mut self, diag: Self::Diagnostic) {
- DiagnosticBuilder::new_diagnostic(&self.sess.span_diagnostic, diag).emit()
+ self.sess.span_diagnostic.emit_diagnostic(&diag);
}
}
macro_rules! panictry_buffer {
($handler:expr, $e:expr) => ({
use std::result::Result::{Ok, Err};
- use errors::{FatalError, DiagnosticBuilder};
+ use errors::FatalError;
match $e {
Ok(e) => e,
Err(errs) => {
for e in errs {
- DiagnosticBuilder::new_diagnostic($handler, e).emit();
+ $handler.emit_diagnostic(&e);
}
FatalError.raise()
}
match try_file_to_source_file(sess, path, spanopt) {
Ok(source_file) => source_file,
Err(d) => {
- DiagnosticBuilder::new_diagnostic(&sess.span_diagnostic, d).emit();
+ sess.span_diagnostic.emit_diagnostic(&d);
FatalError.raise();
}
}