1
Fork 0

rename ErrorReported -> ErrorGuaranteed

This commit is contained in:
mark 2022-01-23 12:34:26 -06:00
parent c42d846add
commit e489a94dee
112 changed files with 580 additions and 559 deletions

View file

@ -7,7 +7,7 @@ use rustc_ast::node_id::NodeId;
use rustc_data_structures::fx::{FxHashMap, FxHashSet};
use rustc_data_structures::sync::{Lock, Lrc};
use rustc_errors::{emitter::SilentEmitter, ColorConfig, Handler};
use rustc_errors::{error_code, Applicability, Diagnostic, DiagnosticBuilder, ErrorReported};
use rustc_errors::{error_code, Applicability, Diagnostic, DiagnosticBuilder, ErrorGuaranteed};
use rustc_feature::{find_feature_issue, GateIssue, UnstableFeatures};
use rustc_span::edition::Edition;
use rustc_span::hygiene::ExpnId;
@ -82,7 +82,7 @@ pub fn feature_err<'a>(
feature: Symbol,
span: impl Into<MultiSpan>,
explain: &str,
) -> DiagnosticBuilder<'a, ErrorReported> {
) -> DiagnosticBuilder<'a, ErrorGuaranteed> {
feature_err_issue(sess, feature, span, GateIssue::Language, explain)
}
@ -96,7 +96,7 @@ pub fn feature_err_issue<'a>(
span: impl Into<MultiSpan>,
issue: GateIssue,
explain: &str,
) -> DiagnosticBuilder<'a, ErrorReported> {
) -> DiagnosticBuilder<'a, ErrorGuaranteed> {
let mut err = sess.span_diagnostic.struct_span_err_with_code(span, explain, error_code!(E0658));
if let Some(n) = find_feature_issue(feature, issue) {

View file

@ -19,7 +19,7 @@ use rustc_errors::annotate_snippet_emitter_writer::AnnotateSnippetEmitterWriter;
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;
@ -221,7 +221,7 @@ enum DiagnosticBuilderMethod {
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
@ -335,7 +335,7 @@ impl Session {
&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>>(
@ -343,25 +343,25 @@ impl Session {
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>>(
@ -369,10 +369,10 @@ impl Session {
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)
}
@ -406,7 +406,7 @@ impl Session {
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]
@ -422,22 +422,22 @@ impl Session {
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)