rename ErrorReported -> ErrorGuaranteed
This commit is contained in:
parent
c42d846add
commit
e489a94dee
112 changed files with 580 additions and 559 deletions
|
@ -1,4 +1,4 @@
|
|||
use crate::{Diagnostic, DiagnosticId, DiagnosticStyledString, ErrorReported};
|
||||
use crate::{Diagnostic, DiagnosticId, DiagnosticStyledString, ErrorGuaranteed};
|
||||
use crate::{Handler, Level, StashKey};
|
||||
use rustc_lint_defs::Applicability;
|
||||
|
||||
|
@ -96,7 +96,7 @@ mod sealed_level_is_error {
|
|||
impl IsError<{ Level::Error { lint: false } }> for () {}
|
||||
}
|
||||
|
||||
impl<'a> DiagnosticBuilder<'a, ErrorReported> {
|
||||
impl<'a> DiagnosticBuilder<'a, ErrorGuaranteed> {
|
||||
/// Convenience function for internal use, clients should use one of the
|
||||
/// `struct_*` methods on [`Handler`].
|
||||
crate fn new_guaranteeing_error<const L: Level>(handler: &'a Handler, message: &str) -> Self
|
||||
|
@ -120,8 +120,8 @@ impl<'a> DiagnosticBuilder<'a, ErrorReported> {
|
|||
}
|
||||
}
|
||||
|
||||
// FIXME(eddyb) make `ErrorReported` impossible to create outside `.emit()`.
|
||||
impl EmissionGuarantee for ErrorReported {
|
||||
// FIXME(eddyb) make `ErrorGuaranteed` impossible to create outside `.emit()`.
|
||||
impl EmissionGuarantee for ErrorGuaranteed {
|
||||
fn diagnostic_builder_emit_producing_guarantee(db: &mut DiagnosticBuilder<'_, Self>) -> Self {
|
||||
match db.inner.state {
|
||||
// First `.emit()` call, the `&Handler` is still available.
|
||||
|
@ -136,10 +136,10 @@ impl EmissionGuarantee for ErrorReported {
|
|||
assert!(
|
||||
db.inner.diagnostic.is_error(),
|
||||
"emitted non-error ({:?}) diagnostic \
|
||||
from `DiagnosticBuilder<ErrorReported>`",
|
||||
from `DiagnosticBuilder<ErrorGuaranteed>`",
|
||||
db.inner.diagnostic.level,
|
||||
);
|
||||
ErrorReported
|
||||
ErrorGuaranteed
|
||||
}
|
||||
// `.emit()` was previously called, disallowed from repeating it,
|
||||
// but can take advantage of the previous `.emit()`'s guarantee
|
||||
|
@ -150,11 +150,11 @@ impl EmissionGuarantee for ErrorReported {
|
|||
// can be overwritten with a new one, thanks to `DerefMut`.
|
||||
assert!(
|
||||
db.inner.diagnostic.is_error(),
|
||||
"`DiagnosticBuilder<ErrorReported>`'s diagnostic \
|
||||
"`DiagnosticBuilder<ErrorGuaranteed>`'s diagnostic \
|
||||
became non-error ({:?}), after original `.emit()`",
|
||||
db.inner.diagnostic.level,
|
||||
);
|
||||
ErrorReported
|
||||
ErrorGuaranteed
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -182,7 +182,7 @@ impl<'a> DiagnosticBuilder<'a, ()> {
|
|||
}
|
||||
}
|
||||
|
||||
// FIXME(eddyb) should there be a `Option<ErrorReported>` impl as well?
|
||||
// FIXME(eddyb) should there be a `Option<ErrorGuaranteed>` impl as well?
|
||||
impl EmissionGuarantee for () {
|
||||
fn diagnostic_builder_emit_producing_guarantee(db: &mut DiagnosticBuilder<'_, Self>) -> Self {
|
||||
match db.inner.state {
|
||||
|
|
|
@ -54,7 +54,7 @@ mod snippet;
|
|||
mod styled_buffer;
|
||||
pub use snippet::Style;
|
||||
|
||||
pub type PResult<'a, T> = Result<T, DiagnosticBuilder<'a, ErrorReported>>;
|
||||
pub type PResult<'a, T> = Result<T, DiagnosticBuilder<'a, ErrorGuaranteed>>;
|
||||
|
||||
// `PResult` is used a lot. Make sure it doesn't unintentionally get bigger.
|
||||
// (See also the comment on `DiagnosticBuilder`'s `diagnostic` field.)
|
||||
|
@ -682,7 +682,7 @@ impl Handler {
|
|||
&self,
|
||||
span: impl Into<MultiSpan>,
|
||||
msg: &str,
|
||||
) -> DiagnosticBuilder<'_, ErrorReported> {
|
||||
) -> DiagnosticBuilder<'_, ErrorGuaranteed> {
|
||||
let mut result = self.struct_err(msg);
|
||||
result.set_span(span);
|
||||
result
|
||||
|
@ -694,7 +694,7 @@ impl Handler {
|
|||
span: impl Into<MultiSpan>,
|
||||
msg: &str,
|
||||
code: DiagnosticId,
|
||||
) -> DiagnosticBuilder<'_, ErrorReported> {
|
||||
) -> DiagnosticBuilder<'_, ErrorGuaranteed> {
|
||||
let mut result = self.struct_span_err(span, msg);
|
||||
result.code(code);
|
||||
result
|
||||
|
@ -702,7 +702,7 @@ impl Handler {
|
|||
|
||||
/// Construct a builder at the `Error` level with the `msg`.
|
||||
// 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> {
|
||||
DiagnosticBuilder::new_guaranteeing_error::<{ Level::Error { lint: false } }>(self, msg)
|
||||
}
|
||||
|
||||
|
@ -717,7 +717,7 @@ impl Handler {
|
|||
&self,
|
||||
msg: &str,
|
||||
code: DiagnosticId,
|
||||
) -> DiagnosticBuilder<'_, ErrorReported> {
|
||||
) -> DiagnosticBuilder<'_, ErrorGuaranteed> {
|
||||
let mut result = self.struct_err(msg);
|
||||
result.code(code);
|
||||
result
|
||||
|
@ -728,7 +728,7 @@ impl Handler {
|
|||
&self,
|
||||
span: impl Into<MultiSpan>,
|
||||
msg: &str,
|
||||
) -> DiagnosticBuilder<'_, ErrorReported> {
|
||||
) -> DiagnosticBuilder<'_, ErrorGuaranteed> {
|
||||
let mut result = self.struct_fatal(msg);
|
||||
result.set_span(span);
|
||||
result
|
||||
|
@ -740,14 +740,14 @@ impl Handler {
|
|||
span: impl Into<MultiSpan>,
|
||||
msg: &str,
|
||||
code: DiagnosticId,
|
||||
) -> DiagnosticBuilder<'_, ErrorReported> {
|
||||
) -> DiagnosticBuilder<'_, ErrorGuaranteed> {
|
||||
let mut result = self.struct_span_fatal(span, msg);
|
||||
result.code(code);
|
||||
result
|
||||
}
|
||||
|
||||
/// Construct a builder at the `Error` level with the `msg`.
|
||||
pub fn struct_fatal(&self, msg: &str) -> DiagnosticBuilder<'_, ErrorReported> {
|
||||
pub fn struct_fatal(&self, msg: &str) -> DiagnosticBuilder<'_, ErrorGuaranteed> {
|
||||
DiagnosticBuilder::new_guaranteeing_error::<{ Level::Fatal }>(self, msg)
|
||||
}
|
||||
|
||||
|
@ -1343,6 +1343,6 @@ pub fn add_elided_lifetime_in_path_suggestion(
|
|||
// Useful type to use with `Result<>` indicate that an error has already
|
||||
// been reported to the user, so no need to continue checking.
|
||||
#[derive(Clone, Copy, Debug, Encodable, Decodable, Hash, PartialEq, Eq)]
|
||||
pub struct ErrorReported;
|
||||
pub struct ErrorGuaranteed;
|
||||
|
||||
rustc_data_structures::impl_stable_hash_via_hash!(ErrorReported);
|
||||
rustc_data_structures::impl_stable_hash_via_hash!(ErrorGuaranteed);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue