use rustc_errors::emitter::{Emitter, EmitterWriter, HumanReadableErrorType};
use rustc_errors::json::JsonEmitter;
use rustc_errors::registry::Registry;
-use rustc_errors::{Diagnostic, DiagnosticBuilder, DiagnosticId, ErrorReported};
+use rustc_errors::{Diagnostic, DiagnosticBuilder, DiagnosticId, ErrorGuaranteed};
use rustc_macros::HashStable_Generic;
pub use rustc_span::def_id::StableCrateId;
use rustc_span::edition::Edition;
pub trait SessionDiagnostic<'a> {
/// Write out as a diagnostic out of `sess`.
#[must_use]
- fn into_diagnostic(self, sess: &'a Session) -> DiagnosticBuilder<'a, ErrorReported>;
+ fn into_diagnostic(self, sess: &'a Session) -> DiagnosticBuilder<'a, ErrorGuaranteed>;
}
/// Diagnostic message ID, used by `Session.one_time_diagnostics` to avoid
pub fn struct_allow(&self, msg: &str) -> DiagnosticBuilder<'_, ()> {
self.diagnostic().struct_allow(msg)
}
+ pub fn struct_expect(
+ &self,
+ msg: &str,
+ id: lint::LintExpectationId,
+ ) -> DiagnosticBuilder<'_, ()> {
+ self.diagnostic().struct_expect(msg, id)
+ }
pub fn struct_span_err<S: Into<MultiSpan>>(
&self,
sp: S,
msg: &str,
- ) -> DiagnosticBuilder<'_, ErrorReported> {
+ ) -> DiagnosticBuilder<'_, ErrorGuaranteed> {
self.diagnostic().struct_span_err(sp, msg)
}
pub fn struct_span_err_with_code<S: Into<MultiSpan>>(
sp: S,
msg: &str,
code: DiagnosticId,
- ) -> DiagnosticBuilder<'_, ErrorReported> {
+ ) -> DiagnosticBuilder<'_, ErrorGuaranteed> {
self.diagnostic().struct_span_err_with_code(sp, msg, code)
}
// FIXME: This method should be removed (every error should have an associated error code).
- pub fn struct_err(&self, msg: &str) -> DiagnosticBuilder<'_, ErrorReported> {
+ pub fn struct_err(&self, msg: &str) -> DiagnosticBuilder<'_, ErrorGuaranteed> {
self.diagnostic().struct_err(msg)
}
pub fn struct_err_with_code(
&self,
msg: &str,
code: DiagnosticId,
- ) -> DiagnosticBuilder<'_, ErrorReported> {
+ ) -> DiagnosticBuilder<'_, ErrorGuaranteed> {
self.diagnostic().struct_err_with_code(msg, code)
}
pub fn struct_span_fatal<S: Into<MultiSpan>>(
&self,
sp: S,
msg: &str,
- ) -> DiagnosticBuilder<'_, ErrorReported> {
+ ) -> DiagnosticBuilder<'_, ErrorGuaranteed> {
self.diagnostic().struct_span_fatal(sp, msg)
}
pub fn struct_span_fatal_with_code<S: Into<MultiSpan>>(
sp: S,
msg: &str,
code: DiagnosticId,
- ) -> DiagnosticBuilder<'_, ErrorReported> {
+ ) -> DiagnosticBuilder<'_, ErrorGuaranteed> {
self.diagnostic().struct_span_fatal_with_code(sp, msg, code)
}
- pub fn struct_fatal(&self, msg: &str) -> DiagnosticBuilder<'_, ErrorReported> {
+ pub fn struct_fatal(&self, msg: &str) -> DiagnosticBuilder<'_, ErrorGuaranteed> {
self.diagnostic().struct_fatal(msg)
}
pub fn err(&self, msg: &str) {
self.diagnostic().err(msg)
}
- pub fn emit_err<'a>(&'a self, err: impl SessionDiagnostic<'a>) -> ErrorReported {
+ pub fn emit_err<'a>(&'a self, err: impl SessionDiagnostic<'a>) -> ErrorGuaranteed {
err.into_diagnostic(self).emit()
}
#[inline]
pub fn abort_if_errors(&self) {
self.diagnostic().abort_if_errors();
}
- pub fn compile_status(&self) -> Result<(), ErrorReported> {
+ pub fn compile_status(&self) -> Result<(), ErrorGuaranteed> {
if self.diagnostic().has_errors_or_lint_errors() {
self.diagnostic().emit_stashed_diagnostics();
- Err(ErrorReported)
+ Err(ErrorGuaranteed)
} else {
Ok(())
}
}
// FIXME(matthewjasper) Remove this method, it should never be needed.
- pub fn track_errors<F, T>(&self, f: F) -> Result<T, ErrorReported>
+ pub fn track_errors<F, T>(&self, f: F) -> Result<T, ErrorGuaranteed>
where
F: FnOnce() -> T,
{
let old_count = self.err_count();
let result = f();
- if self.err_count() == old_count { Ok(result) } else { Err(ErrorReported) }
+ if self.err_count() == old_count { Ok(result) } else { Err(ErrorGuaranteed) }
}
pub fn span_warn<S: Into<MultiSpan>>(&self, sp: S, msg: &str) {
self.diagnostic().span_warn(sp, msg)