mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-22 06:44:35 +00:00
Rename Diagnostic
as DiagInner
.
I started by changing it to `DiagData`, but that didn't feel right. `DiagInner` felt much better.
This commit is contained in:
parent
1e4f9e302c
commit
6588f5b749
@ -1829,9 +1829,9 @@ impl Translate for SharedEmitter {
|
||||
}
|
||||
|
||||
impl Emitter for SharedEmitter {
|
||||
fn emit_diagnostic(&mut self, mut diag: rustc_errors::Diagnostic) {
|
||||
fn emit_diagnostic(&mut self, mut diag: rustc_errors::DiagInner) {
|
||||
// Check that we aren't missing anything interesting when converting to
|
||||
// the cut-down local `Diagnostic`.
|
||||
// the cut-down local `DiagInner`.
|
||||
assert_eq!(diag.span, MultiSpan::new());
|
||||
assert_eq!(diag.suggestions, Ok(vec![]));
|
||||
assert_eq!(diag.sort_span, rustc_span::DUMMY_SP);
|
||||
@ -1880,7 +1880,7 @@ impl SharedEmitterMain {
|
||||
// Convert it back to a full `Diagnostic` and emit.
|
||||
let dcx = sess.dcx();
|
||||
let mut d =
|
||||
rustc_errors::Diagnostic::new_with_messages(diag.level, diag.messages);
|
||||
rustc_errors::DiagInner::new_with_messages(diag.level, diag.messages);
|
||||
d.code = diag.code; // may be `None`, that's ok
|
||||
d.children = diag
|
||||
.children
|
||||
|
@ -9,7 +9,7 @@ use crate::emitter::FileWithAnnotatedLines;
|
||||
use crate::snippet::Line;
|
||||
use crate::translation::{to_fluent_args, Translate};
|
||||
use crate::{
|
||||
CodeSuggestion, Diagnostic, DiagnosticMessage, Emitter, ErrCode, FluentBundle,
|
||||
CodeSuggestion, DiagInner, DiagnosticMessage, Emitter, ErrCode, FluentBundle,
|
||||
LazyFallbackBundle, Level, MultiSpan, Style, SubDiagnostic,
|
||||
};
|
||||
use annotate_snippets::{Annotation, AnnotationType, Renderer, Slice, Snippet, SourceAnnotation};
|
||||
@ -44,7 +44,7 @@ impl Translate for AnnotateSnippetEmitter {
|
||||
|
||||
impl Emitter for AnnotateSnippetEmitter {
|
||||
/// The entry point for the diagnostics generation
|
||||
fn emit_diagnostic(&mut self, mut diag: Diagnostic) {
|
||||
fn emit_diagnostic(&mut self, mut diag: DiagInner) {
|
||||
let fluent_args = to_fluent_args(diag.args.iter());
|
||||
|
||||
let mut suggestions = diag.suggestions.unwrap_or(vec![]);
|
||||
@ -82,7 +82,7 @@ fn source_string(file: Lrc<SourceFile>, line: &Line) -> String {
|
||||
file.get_line(line.line_index - 1).map(|a| a.to_string()).unwrap_or_default()
|
||||
}
|
||||
|
||||
/// Maps `Diagnostic::Level` to `snippet::AnnotationType`
|
||||
/// Maps `diagnostic::Level` to `snippet::AnnotationType`
|
||||
fn annotation_type_for_level(level: Level) -> AnnotationType {
|
||||
match level {
|
||||
Level::Bug | Level::Fatal | Level::Error | Level::DelayedBug => AnnotationType::Error,
|
||||
|
@ -18,8 +18,8 @@ use std::ops::{Deref, DerefMut};
|
||||
use std::panic;
|
||||
use std::thread::panicking;
|
||||
|
||||
/// Error type for `Diagnostic`'s `suggestions` field, indicating that
|
||||
/// `.disable_suggestions()` was called on the `Diagnostic`.
|
||||
/// Error type for `DiagInner`'s `suggestions` field, indicating that
|
||||
/// `.disable_suggestions()` was called on the `DiagInner`.
|
||||
#[derive(Clone, Debug, PartialEq, Eq, Hash, Encodable, Decodable)]
|
||||
pub struct SuggestionsDisabled;
|
||||
|
||||
@ -267,7 +267,7 @@ impl StringPart {
|
||||
/// causes difficulties, e.g. when storing diagnostics within `DiagCtxt`.
|
||||
#[must_use]
|
||||
#[derive(Clone, Debug, Encodable, Decodable)]
|
||||
pub struct Diagnostic {
|
||||
pub struct DiagInner {
|
||||
// NOTE(eddyb) this is private to disallow arbitrary after-the-fact changes,
|
||||
// outside of what methods in this crate themselves allow.
|
||||
pub(crate) level: Level,
|
||||
@ -291,15 +291,15 @@ pub struct Diagnostic {
|
||||
pub(crate) emitted_at: DiagnosticLocation,
|
||||
}
|
||||
|
||||
impl Diagnostic {
|
||||
impl DiagInner {
|
||||
#[track_caller]
|
||||
pub fn new<M: Into<DiagnosticMessage>>(level: Level, message: M) -> Self {
|
||||
Diagnostic::new_with_messages(level, vec![(message.into(), Style::NoStyle)])
|
||||
DiagInner::new_with_messages(level, vec![(message.into(), Style::NoStyle)])
|
||||
}
|
||||
|
||||
#[track_caller]
|
||||
pub fn new_with_messages(level: Level, messages: Vec<(DiagnosticMessage, Style)>) -> Self {
|
||||
Diagnostic {
|
||||
DiagInner {
|
||||
level,
|
||||
messages,
|
||||
code: None,
|
||||
@ -433,7 +433,7 @@ impl Diagnostic {
|
||||
}
|
||||
}
|
||||
|
||||
impl Hash for Diagnostic {
|
||||
impl Hash for DiagInner {
|
||||
fn hash<H>(&self, state: &mut H)
|
||||
where
|
||||
H: Hasher,
|
||||
@ -442,7 +442,7 @@ impl Hash for Diagnostic {
|
||||
}
|
||||
}
|
||||
|
||||
impl PartialEq for Diagnostic {
|
||||
impl PartialEq for DiagInner {
|
||||
fn eq(&self, other: &Self) -> bool {
|
||||
self.keys() == other.keys()
|
||||
}
|
||||
@ -458,7 +458,7 @@ pub struct SubDiagnostic {
|
||||
}
|
||||
|
||||
/// Used for emitting structured error messages and other diagnostic information.
|
||||
/// Wraps a `Diagnostic`, adding some useful things.
|
||||
/// Wraps a `DiagInner`, adding some useful things.
|
||||
/// - The `dcx` field, allowing it to (a) emit itself, and (b) do a drop check
|
||||
/// that it has been emitted or cancelled.
|
||||
/// - The `EmissionGuarantee`, which determines the type returned from `emit`.
|
||||
@ -480,11 +480,11 @@ pub struct DiagnosticBuilder<'a, G: EmissionGuarantee = ErrorGuaranteed> {
|
||||
/// replaced with `None`. Then `drop` checks that it is `None`; if not, it
|
||||
/// panics because a diagnostic was built but not used.
|
||||
///
|
||||
/// Why the Box? `Diagnostic` is a large type, and `DiagnosticBuilder` is
|
||||
/// Why the Box? `DiagInner` is a large type, and `DiagnosticBuilder` is
|
||||
/// often used as a return value, especially within the frequently-used
|
||||
/// `PResult` type. In theory, return value optimization (RVO) should avoid
|
||||
/// unnecessary copying. In practice, it does not (at the time of writing).
|
||||
diag: Option<Box<Diagnostic>>,
|
||||
diag: Option<Box<DiagInner>>,
|
||||
|
||||
_marker: PhantomData<G>,
|
||||
}
|
||||
@ -499,15 +499,15 @@ rustc_data_structures::static_assert_size!(
|
||||
);
|
||||
|
||||
impl<G: EmissionGuarantee> Deref for DiagnosticBuilder<'_, G> {
|
||||
type Target = Diagnostic;
|
||||
type Target = DiagInner;
|
||||
|
||||
fn deref(&self) -> &Diagnostic {
|
||||
fn deref(&self) -> &DiagInner {
|
||||
self.diag.as_ref().unwrap()
|
||||
}
|
||||
}
|
||||
|
||||
impl<G: EmissionGuarantee> DerefMut for DiagnosticBuilder<'_, G> {
|
||||
fn deref_mut(&mut self) -> &mut Diagnostic {
|
||||
fn deref_mut(&mut self) -> &mut DiagInner {
|
||||
self.diag.as_mut().unwrap()
|
||||
}
|
||||
}
|
||||
@ -565,13 +565,13 @@ impl<'a, G: EmissionGuarantee> DiagnosticBuilder<'a, G> {
|
||||
#[rustc_lint_diagnostics]
|
||||
#[track_caller]
|
||||
pub fn new<M: Into<DiagnosticMessage>>(dcx: &'a DiagCtxt, level: Level, message: M) -> Self {
|
||||
Self::new_diagnostic(dcx, Diagnostic::new(level, message))
|
||||
Self::new_diagnostic(dcx, DiagInner::new(level, message))
|
||||
}
|
||||
|
||||
/// Creates a new `DiagnosticBuilder` with an already constructed
|
||||
/// diagnostic.
|
||||
#[track_caller]
|
||||
pub(crate) fn new_diagnostic(dcx: &'a DiagCtxt, diag: Diagnostic) -> Self {
|
||||
pub(crate) fn new_diagnostic(dcx: &'a DiagCtxt, diag: DiagInner) -> Self {
|
||||
debug!("Created new diagnostic");
|
||||
Self { dcx, diag: Some(Box::new(diag)), _marker: PhantomData }
|
||||
}
|
||||
@ -1238,7 +1238,7 @@ impl<'a, G: EmissionGuarantee> DiagnosticBuilder<'a, G> {
|
||||
/// Takes the diagnostic. For use by methods that consume the
|
||||
/// DiagnosticBuilder: `emit`, `cancel`, etc. Afterwards, `drop` is the
|
||||
/// only code that will be run on `self`.
|
||||
fn take_diag(&mut self) -> Diagnostic {
|
||||
fn take_diag(&mut self) -> DiagInner {
|
||||
Box::into_inner(self.diag.take().unwrap())
|
||||
}
|
||||
|
||||
@ -1257,7 +1257,7 @@ impl<'a, G: EmissionGuarantee> DiagnosticBuilder<'a, G> {
|
||||
// because delayed bugs have their level changed to `Bug` when they are
|
||||
// actually printed, so they produce an ICE.
|
||||
//
|
||||
// (Also, even though `level` isn't `pub`, the whole `Diagnostic` could
|
||||
// (Also, even though `level` isn't `pub`, the whole `DiagInner` could
|
||||
// be overwritten with a new one thanks to `DerefMut`. So this assert
|
||||
// protects against that, too.)
|
||||
assert!(
|
||||
@ -1325,7 +1325,7 @@ impl<G: EmissionGuarantee> Drop for DiagnosticBuilder<'_, G> {
|
||||
fn drop(&mut self) {
|
||||
match self.diag.take() {
|
||||
Some(diag) if !panicking() => {
|
||||
self.dcx.emit_diagnostic(Diagnostic::new(
|
||||
self.dcx.emit_diagnostic(DiagInner::new(
|
||||
Level::Bug,
|
||||
DiagnosticMessage::from("the following error was constructed but not emitted"),
|
||||
));
|
||||
|
@ -17,7 +17,7 @@ use crate::snippet::{
|
||||
use crate::styled_buffer::StyledBuffer;
|
||||
use crate::translation::{to_fluent_args, Translate};
|
||||
use crate::{
|
||||
diagnostic::DiagnosticLocation, CodeSuggestion, DiagCtxt, Diagnostic, DiagnosticMessage,
|
||||
diagnostic::DiagnosticLocation, CodeSuggestion, DiagCtxt, DiagInner, DiagnosticMessage,
|
||||
ErrCode, FluentBundle, LazyFallbackBundle, Level, MultiSpan, SubDiagnostic,
|
||||
SubstitutionHighlight, SuggestionStyle, TerminalUrl,
|
||||
};
|
||||
@ -194,7 +194,7 @@ pub type DynEmitter = dyn Emitter + DynSend;
|
||||
/// Emitter trait for emitting errors.
|
||||
pub trait Emitter: Translate {
|
||||
/// Emit a structured diagnostic.
|
||||
fn emit_diagnostic(&mut self, diag: Diagnostic);
|
||||
fn emit_diagnostic(&mut self, diag: DiagInner);
|
||||
|
||||
/// Emit a notification that an artifact has been output.
|
||||
/// Currently only supported for the JSON format.
|
||||
@ -202,7 +202,7 @@ pub trait Emitter: Translate {
|
||||
|
||||
/// Emit a report about future breakage.
|
||||
/// Currently only supported for the JSON format.
|
||||
fn emit_future_breakage_report(&mut self, _diags: Vec<Diagnostic>) {}
|
||||
fn emit_future_breakage_report(&mut self, _diags: Vec<DiagInner>) {}
|
||||
|
||||
/// Emit list of unused externs.
|
||||
/// Currently only supported for the JSON format.
|
||||
@ -229,12 +229,12 @@ pub trait Emitter: Translate {
|
||||
///
|
||||
/// There are a lot of conditions to this method, but in short:
|
||||
///
|
||||
/// * If the current `Diagnostic` has only one visible `CodeSuggestion`,
|
||||
/// * If the current `DiagInner` has only one visible `CodeSuggestion`,
|
||||
/// we format the `help` suggestion depending on the content of the
|
||||
/// substitutions. In that case, we modify the span and clear the
|
||||
/// suggestions.
|
||||
///
|
||||
/// * If the current `Diagnostic` has multiple suggestions,
|
||||
/// * If the current `DiagInner` has multiple suggestions,
|
||||
/// we leave `primary_span` and the suggestions untouched.
|
||||
fn primary_span_formatted(
|
||||
&mut self,
|
||||
@ -518,7 +518,7 @@ impl Emitter for HumanEmitter {
|
||||
self.sm.as_ref()
|
||||
}
|
||||
|
||||
fn emit_diagnostic(&mut self, mut diag: Diagnostic) {
|
||||
fn emit_diagnostic(&mut self, mut diag: DiagInner) {
|
||||
let fluent_args = to_fluent_args(diag.args.iter());
|
||||
|
||||
let mut suggestions = diag.suggestions.unwrap_or(vec![]);
|
||||
@ -597,7 +597,7 @@ impl Emitter for SilentEmitter {
|
||||
None
|
||||
}
|
||||
|
||||
fn emit_diagnostic(&mut self, mut diag: Diagnostic) {
|
||||
fn emit_diagnostic(&mut self, mut diag: DiagInner) {
|
||||
if diag.level == Level::Fatal {
|
||||
diag.sub(Level::Note, self.fatal_note.clone(), MultiSpan::new());
|
||||
self.fatal_dcx.emit_diagnostic(diag);
|
||||
|
@ -176,7 +176,7 @@ impl Translate for JsonEmitter {
|
||||
}
|
||||
|
||||
impl Emitter for JsonEmitter {
|
||||
fn emit_diagnostic(&mut self, diag: crate::Diagnostic) {
|
||||
fn emit_diagnostic(&mut self, diag: crate::DiagInner) {
|
||||
let data = Diagnostic::from_errors_diagnostic(diag, self);
|
||||
let result = self.emit(EmitTyped::Diagnostic(data));
|
||||
if let Err(e) = result {
|
||||
@ -192,7 +192,7 @@ impl Emitter for JsonEmitter {
|
||||
}
|
||||
}
|
||||
|
||||
fn emit_future_breakage_report(&mut self, diags: Vec<crate::Diagnostic>) {
|
||||
fn emit_future_breakage_report(&mut self, diags: Vec<crate::DiagInner>) {
|
||||
let data: Vec<FutureBreakageItem<'_>> = diags
|
||||
.into_iter()
|
||||
.map(|mut diag| {
|
||||
@ -340,7 +340,7 @@ struct UnusedExterns<'a, 'b, 'c> {
|
||||
}
|
||||
|
||||
impl Diagnostic {
|
||||
fn from_errors_diagnostic(diag: crate::Diagnostic, je: &JsonEmitter) -> Diagnostic {
|
||||
fn from_errors_diagnostic(diag: crate::DiagInner, je: &JsonEmitter) -> Diagnostic {
|
||||
let args = to_fluent_args(diag.args.iter());
|
||||
let sugg = diag.suggestions.iter().flatten().map(|sugg| {
|
||||
let translated_message =
|
||||
|
@ -37,7 +37,7 @@ extern crate self as rustc_errors;
|
||||
|
||||
pub use codes::*;
|
||||
pub use diagnostic::{
|
||||
AddToDiagnostic, BugAbort, DecorateLint, Diagnostic, DiagnosticArg, DiagnosticArgMap,
|
||||
AddToDiagnostic, BugAbort, DecorateLint, DiagInner, DiagnosticArg, DiagnosticArgMap,
|
||||
DiagnosticArgName, DiagnosticArgValue, DiagnosticBuilder, DiagnosticStyledString,
|
||||
EmissionGuarantee, FatalAbort, IntoDiagnostic, IntoDiagnosticArg, StringPart, SubDiagnostic,
|
||||
SubdiagnosticMessageOp,
|
||||
@ -476,9 +476,9 @@ struct DiagCtxtInner {
|
||||
/// add more information). All stashed diagnostics must be emitted with
|
||||
/// `emit_stashed_diagnostics` by the time the `DiagCtxtInner` is dropped,
|
||||
/// otherwise an assertion failure will occur.
|
||||
stashed_diagnostics: FxIndexMap<(Span, StashKey), Diagnostic>,
|
||||
stashed_diagnostics: FxIndexMap<(Span, StashKey), DiagInner>,
|
||||
|
||||
future_breakage_diagnostics: Vec<Diagnostic>,
|
||||
future_breakage_diagnostics: Vec<DiagInner>,
|
||||
|
||||
/// The [`Self::unstable_expect_diagnostics`] should be empty when this struct is
|
||||
/// dropped. However, it can have values if the compilation is stopped early
|
||||
@ -487,13 +487,13 @@ struct DiagCtxtInner {
|
||||
/// have been converted.
|
||||
check_unstable_expect_diagnostics: bool,
|
||||
|
||||
/// Expected [`Diagnostic`][struct@diagnostic::Diagnostic]s store a [`LintExpectationId`] as part of
|
||||
/// Expected [`DiagInner`][struct@diagnostic::DiagInner]s store a [`LintExpectationId`] as part of
|
||||
/// the lint level. [`LintExpectationId`]s created early during the compilation
|
||||
/// (before `HirId`s have been defined) are not stable and can therefore not be
|
||||
/// stored on disk. This buffer stores these diagnostics until the ID has been
|
||||
/// replaced by a stable [`LintExpectationId`]. The [`Diagnostic`][struct@diagnostic::Diagnostic]s are the
|
||||
/// submitted for storage and added to the list of fulfilled expectations.
|
||||
unstable_expect_diagnostics: Vec<Diagnostic>,
|
||||
/// replaced by a stable [`LintExpectationId`]. The [`DiagInner`][struct@diagnostic::DiagInner]s
|
||||
/// are submitted for storage and added to the list of fulfilled expectations.
|
||||
unstable_expect_diagnostics: Vec<DiagInner>,
|
||||
|
||||
/// expected diagnostic will have the level `Expect` which additionally
|
||||
/// carries the [`LintExpectationId`] of the expectation that can be
|
||||
@ -531,11 +531,11 @@ pub enum StashKey {
|
||||
UndeterminedMacroResolution,
|
||||
}
|
||||
|
||||
fn default_track_diagnostic(diag: Diagnostic, f: &mut dyn FnMut(Diagnostic)) {
|
||||
fn default_track_diagnostic(diag: DiagInner, f: &mut dyn FnMut(DiagInner)) {
|
||||
(*f)(diag)
|
||||
}
|
||||
|
||||
pub static TRACK_DIAGNOSTIC: AtomicRef<fn(Diagnostic, &mut dyn FnMut(Diagnostic))> =
|
||||
pub static TRACK_DIAGNOSTIC: AtomicRef<fn(DiagInner, &mut dyn FnMut(DiagInner))> =
|
||||
AtomicRef::new(&(default_track_diagnostic as _));
|
||||
|
||||
#[derive(Copy, Clone, Default)]
|
||||
@ -718,7 +718,7 @@ impl DiagCtxt {
|
||||
|
||||
/// Stash a given diagnostic with the given `Span` and [`StashKey`] as the key.
|
||||
/// Retrieve a stashed diagnostic with `steal_diagnostic`.
|
||||
pub fn stash_diagnostic(&self, span: Span, key: StashKey, diag: Diagnostic) {
|
||||
pub fn stash_diagnostic(&self, span: Span, key: StashKey, diag: DiagInner) {
|
||||
let mut inner = self.inner.borrow_mut();
|
||||
|
||||
let key = (span.with_parent(None), key);
|
||||
@ -824,16 +824,16 @@ impl DiagCtxt {
|
||||
(0, _) => {
|
||||
// Use `ForceWarning` rather than `Warning` to guarantee emission, e.g. with a
|
||||
// configuration like `--cap-lints allow --force-warn bare_trait_objects`.
|
||||
inner.emit_diagnostic(Diagnostic::new(
|
||||
inner.emit_diagnostic(DiagInner::new(
|
||||
ForceWarning(None),
|
||||
DiagnosticMessage::Str(warnings),
|
||||
));
|
||||
}
|
||||
(_, 0) => {
|
||||
inner.emit_diagnostic(Diagnostic::new(Error, errors));
|
||||
inner.emit_diagnostic(DiagInner::new(Error, errors));
|
||||
}
|
||||
(_, _) => {
|
||||
inner.emit_diagnostic(Diagnostic::new(Error, format!("{errors}; {warnings}")));
|
||||
inner.emit_diagnostic(DiagInner::new(Error, format!("{errors}; {warnings}")));
|
||||
}
|
||||
}
|
||||
|
||||
@ -864,14 +864,14 @@ impl DiagCtxt {
|
||||
"For more information about an error, try `rustc --explain {}`.",
|
||||
&error_codes[0]
|
||||
);
|
||||
inner.emit_diagnostic(Diagnostic::new(FailureNote, msg1));
|
||||
inner.emit_diagnostic(Diagnostic::new(FailureNote, msg2));
|
||||
inner.emit_diagnostic(DiagInner::new(FailureNote, msg1));
|
||||
inner.emit_diagnostic(DiagInner::new(FailureNote, msg2));
|
||||
} else {
|
||||
let msg = format!(
|
||||
"For more information about this error, try `rustc --explain {}`.",
|
||||
&error_codes[0]
|
||||
);
|
||||
inner.emit_diagnostic(Diagnostic::new(FailureNote, msg));
|
||||
inner.emit_diagnostic(DiagInner::new(FailureNote, msg));
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -896,7 +896,7 @@ impl DiagCtxt {
|
||||
self.inner.borrow_mut().taught_diagnostics.insert(code)
|
||||
}
|
||||
|
||||
pub fn emit_diagnostic(&self, diagnostic: Diagnostic) -> Option<ErrorGuaranteed> {
|
||||
pub fn emit_diagnostic(&self, diagnostic: DiagInner) -> Option<ErrorGuaranteed> {
|
||||
self.inner.borrow_mut().emit_diagnostic(diagnostic)
|
||||
}
|
||||
|
||||
@ -1305,7 +1305,7 @@ impl DiagCtxtInner {
|
||||
}
|
||||
|
||||
// Return value is only `Some` if the level is `Error` or `DelayedBug`.
|
||||
fn emit_diagnostic(&mut self, mut diagnostic: Diagnostic) -> Option<ErrorGuaranteed> {
|
||||
fn emit_diagnostic(&mut self, mut diagnostic: DiagInner) -> Option<ErrorGuaranteed> {
|
||||
assert!(diagnostic.level.can_be_top_or_sub().0);
|
||||
|
||||
if let Some(expectation_id) = diagnostic.level.get_expectation_id() {
|
||||
@ -1494,7 +1494,7 @@ impl DiagCtxtInner {
|
||||
|
||||
fn eagerly_translate_for_subdiag(
|
||||
&self,
|
||||
diag: &Diagnostic,
|
||||
diag: &DiagInner,
|
||||
msg: impl Into<SubdiagnosticMessage>,
|
||||
) -> SubdiagnosticMessage {
|
||||
let msg = diag.subdiagnostic_message_to_diagnostic_message(msg);
|
||||
@ -1539,8 +1539,8 @@ impl DiagCtxtInner {
|
||||
// could trigger `-Ztreat-err-as-bug`, which we don't want.
|
||||
let note1 = "no errors encountered even though delayed bugs were created";
|
||||
let note2 = "those delayed bugs will now be shown as internal compiler errors";
|
||||
self.emit_diagnostic(Diagnostic::new(Note, note1));
|
||||
self.emit_diagnostic(Diagnostic::new(Note, note2));
|
||||
self.emit_diagnostic(DiagInner::new(Note, note1));
|
||||
self.emit_diagnostic(DiagInner::new(Note, note2));
|
||||
}
|
||||
|
||||
let mut bug =
|
||||
@ -1551,7 +1551,7 @@ impl DiagCtxtInner {
|
||||
// NOTE(eddyb) not panicking here because we're already producing
|
||||
// an ICE, and the more information the merrier.
|
||||
//
|
||||
// We are at the `Diagnostic`/`DiagCtxtInner` level rather than
|
||||
// We are at the `DiagInner`/`DiagCtxtInner` level rather than
|
||||
// the usual `DiagnosticBuilder`/`DiagCtxt` level, so we must
|
||||
// augment `bug` in a lower-level fashion.
|
||||
bug.arg("level", bug.level);
|
||||
@ -1582,17 +1582,17 @@ impl DiagCtxtInner {
|
||||
}
|
||||
|
||||
struct DelayedDiagnostic {
|
||||
inner: Diagnostic,
|
||||
inner: DiagInner,
|
||||
note: Backtrace,
|
||||
}
|
||||
|
||||
impl DelayedDiagnostic {
|
||||
fn with_backtrace(diagnostic: Diagnostic, backtrace: Backtrace) -> Self {
|
||||
fn with_backtrace(diagnostic: DiagInner, backtrace: Backtrace) -> Self {
|
||||
DelayedDiagnostic { inner: diagnostic, note: backtrace }
|
||||
}
|
||||
|
||||
fn decorate(self, dcx: &DiagCtxtInner) -> Diagnostic {
|
||||
// We are at the `Diagnostic`/`DiagCtxtInner` level rather than the
|
||||
fn decorate(self, dcx: &DiagCtxtInner) -> DiagInner {
|
||||
// We are at the `DiagInner`/`DiagCtxtInner` level rather than the
|
||||
// usual `DiagnosticBuilder`/`DiagCtxt` level, so we must construct
|
||||
// `diag` in a lower-level fashion.
|
||||
let mut diag = self.inner;
|
||||
|
@ -9,7 +9,7 @@
|
||||
//! The functions in this file should fall back to the default set in their
|
||||
//! origin crate when the `TyCtxt` is not present in TLS.
|
||||
|
||||
use rustc_errors::{Diagnostic, TRACK_DIAGNOSTIC};
|
||||
use rustc_errors::{DiagInner, TRACK_DIAGNOSTIC};
|
||||
use rustc_middle::dep_graph::{DepNodeExt, TaskDepsRef};
|
||||
use rustc_middle::ty::tls;
|
||||
use rustc_query_system::dep_graph::dep_node::default_dep_kind_debug;
|
||||
@ -29,7 +29,7 @@ fn track_span_parent(def_id: rustc_span::def_id::LocalDefId) {
|
||||
/// This is a callback from `rustc_errors` as it cannot access the implicit state
|
||||
/// in `rustc_middle` otherwise. It is used when diagnostic messages are
|
||||
/// emitted and stores them in the current query, if there is one.
|
||||
fn track_diagnostic(diagnostic: Diagnostic, f: &mut dyn FnMut(Diagnostic)) {
|
||||
fn track_diagnostic(diagnostic: DiagInner, f: &mut dyn FnMut(DiagInner)) {
|
||||
tls::with_context_opt(|icx| {
|
||||
if let Some(icx) = icx {
|
||||
if let Some(diagnostics) = icx.diagnostics {
|
||||
|
@ -69,7 +69,7 @@ pub enum Applicability {
|
||||
}
|
||||
|
||||
/// Each lint expectation has a `LintExpectationId` assigned by the `LintLevelsBuilder`.
|
||||
/// Expected `Diagnostic`s get the lint level `Expect` which stores the `LintExpectationId`
|
||||
/// Expected diagnostics get the lint level `Expect` which stores the `LintExpectationId`
|
||||
/// to match it with the actual expectation later on.
|
||||
///
|
||||
/// The `LintExpectationId` has to be stable between compilations, as diagnostic
|
||||
|
@ -3,7 +3,7 @@ use super::{GlobalCtxt, TyCtxt};
|
||||
use crate::dep_graph::TaskDepsRef;
|
||||
use crate::query::plumbing::QueryJobId;
|
||||
use rustc_data_structures::sync::{self, Lock};
|
||||
use rustc_errors::Diagnostic;
|
||||
use rustc_errors::DiagInner;
|
||||
#[cfg(not(parallel_compiler))]
|
||||
use std::cell::Cell;
|
||||
use std::mem;
|
||||
@ -26,7 +26,7 @@ pub struct ImplicitCtxt<'a, 'tcx> {
|
||||
|
||||
/// Where to store diagnostics for the current query job, if any.
|
||||
/// This is updated by `JobOwner::start` in `ty::query::plumbing` when executing a query.
|
||||
pub diagnostics: Option<&'a Lock<ThinVec<Diagnostic>>>,
|
||||
pub diagnostics: Option<&'a Lock<ThinVec<DiagInner>>>,
|
||||
|
||||
/// Used to prevent queries from calling too deeply.
|
||||
pub query_depth: usize,
|
||||
|
@ -7,7 +7,7 @@ use crate::rustc_middle::ty::TyEncoder;
|
||||
use crate::QueryConfigRestored;
|
||||
use rustc_data_structures::stable_hasher::{Hash64, HashStable, StableHasher};
|
||||
use rustc_data_structures::sync::Lock;
|
||||
use rustc_errors::Diagnostic;
|
||||
use rustc_errors::DiagInner;
|
||||
|
||||
use rustc_index::Idx;
|
||||
use rustc_middle::dep_graph::dep_kinds;
|
||||
@ -125,7 +125,7 @@ impl QueryContext for QueryCtxt<'_> {
|
||||
self,
|
||||
token: QueryJobId,
|
||||
depth_limit: bool,
|
||||
diagnostics: Option<&Lock<ThinVec<Diagnostic>>>,
|
||||
diagnostics: Option<&Lock<ThinVec<DiagInner>>>,
|
||||
compute: impl FnOnce() -> R,
|
||||
) -> R {
|
||||
// The `TyCtxt` stored in TLS has the same global interner lifetime
|
||||
|
@ -21,7 +21,7 @@ use crate::dep_graph::DepKind;
|
||||
use crate::dep_graph::{DepNodeIndex, HasDepContext, SerializedDepNodeIndex};
|
||||
use rustc_data_structures::stable_hasher::Hash64;
|
||||
use rustc_data_structures::sync::Lock;
|
||||
use rustc_errors::Diagnostic;
|
||||
use rustc_errors::DiagInner;
|
||||
use rustc_hir::def::DefKind;
|
||||
use rustc_span::def_id::DefId;
|
||||
use rustc_span::Span;
|
||||
@ -89,7 +89,7 @@ pub struct QuerySideEffects {
|
||||
/// Stores any diagnostics emitted during query execution.
|
||||
/// These diagnostics will be re-emitted if we mark
|
||||
/// the query as green.
|
||||
pub(super) diagnostics: ThinVec<Diagnostic>,
|
||||
pub(super) diagnostics: ThinVec<DiagInner>,
|
||||
}
|
||||
|
||||
impl QuerySideEffects {
|
||||
@ -135,7 +135,7 @@ pub trait QueryContext: HasDepContext {
|
||||
self,
|
||||
token: QueryJobId,
|
||||
depth_limit: bool,
|
||||
diagnostics: Option<&Lock<ThinVec<Diagnostic>>>,
|
||||
diagnostics: Option<&Lock<ThinVec<DiagInner>>>,
|
||||
compute: impl FnOnce() -> R,
|
||||
) -> R;
|
||||
|
||||
|
@ -3,7 +3,7 @@ use rustc_data_structures::sync::{Lock, Lrc};
|
||||
use rustc_errors::{
|
||||
emitter::Emitter,
|
||||
translation::{to_fluent_args, Translate},
|
||||
Applicability, DiagCtxt, Diagnostic, LazyFallbackBundle,
|
||||
Applicability, DiagCtxt, DiagInner, LazyFallbackBundle,
|
||||
};
|
||||
use rustc_parse::parse_stream_from_source_str;
|
||||
use rustc_resolve::rustdoc::source_span_for_markdown_range;
|
||||
@ -156,7 +156,7 @@ impl Translate for BufferEmitter {
|
||||
}
|
||||
|
||||
impl Emitter for BufferEmitter {
|
||||
fn emit_diagnostic(&mut self, diag: Diagnostic) {
|
||||
fn emit_diagnostic(&mut self, diag: DiagInner) {
|
||||
let mut buffer = self.buffer.borrow_mut();
|
||||
|
||||
let fluent_args = to_fluent_args(diag.args.iter());
|
||||
|
@ -6,7 +6,7 @@ use rustc_data_structures::sync::{IntoDynSyncSend, Lrc};
|
||||
use rustc_errors::emitter::{DynEmitter, Emitter, HumanEmitter};
|
||||
use rustc_errors::translation::Translate;
|
||||
use rustc_errors::{
|
||||
ColorConfig, DiagCtxt, Diagnostic, DiagnosticBuilder, ErrorGuaranteed, Level as DiagnosticLevel,
|
||||
ColorConfig, DiagCtxt, DiagInner, DiagnosticBuilder, ErrorGuaranteed, Level as DiagnosticLevel,
|
||||
};
|
||||
use rustc_session::parse::ParseSess as RawParseSess;
|
||||
use rustc_span::{
|
||||
@ -58,7 +58,7 @@ impl Emitter for SilentEmitter {
|
||||
None
|
||||
}
|
||||
|
||||
fn emit_diagnostic(&mut self, _db: Diagnostic) {}
|
||||
fn emit_diagnostic(&mut self, _diag: DiagInner) {}
|
||||
}
|
||||
|
||||
fn silent_emitter() -> Box<DynEmitter> {
|
||||
@ -75,10 +75,10 @@ struct SilentOnIgnoredFilesEmitter {
|
||||
}
|
||||
|
||||
impl SilentOnIgnoredFilesEmitter {
|
||||
fn handle_non_ignoreable_error(&mut self, db: Diagnostic) {
|
||||
fn handle_non_ignoreable_error(&mut self, diag: DiagInner) {
|
||||
self.has_non_ignorable_parser_errors = true;
|
||||
self.can_reset.store(false, Ordering::Release);
|
||||
self.emitter.emit_diagnostic(db);
|
||||
self.emitter.emit_diagnostic(diag);
|
||||
}
|
||||
}
|
||||
|
||||
@ -97,11 +97,11 @@ impl Emitter for SilentOnIgnoredFilesEmitter {
|
||||
None
|
||||
}
|
||||
|
||||
fn emit_diagnostic(&mut self, db: Diagnostic) {
|
||||
if db.level() == DiagnosticLevel::Fatal {
|
||||
return self.handle_non_ignoreable_error(db);
|
||||
fn emit_diagnostic(&mut self, diag: DiagInner) {
|
||||
if diag.level() == DiagnosticLevel::Fatal {
|
||||
return self.handle_non_ignoreable_error(diag);
|
||||
}
|
||||
if let Some(primary_span) = &db.span.primary_span() {
|
||||
if let Some(primary_span) = &diag.span.primary_span() {
|
||||
let file_name = self.source_map.span_to_filename(*primary_span);
|
||||
if let rustc_span::FileName::Real(rustc_span::RealFileName::LocalPath(ref path)) =
|
||||
file_name
|
||||
@ -117,7 +117,7 @@ impl Emitter for SilentOnIgnoredFilesEmitter {
|
||||
}
|
||||
};
|
||||
}
|
||||
self.handle_non_ignoreable_error(db);
|
||||
self.handle_non_ignoreable_error(diag);
|
||||
}
|
||||
}
|
||||
|
||||
@ -380,13 +380,13 @@ mod tests {
|
||||
None
|
||||
}
|
||||
|
||||
fn emit_diagnostic(&mut self, _db: Diagnostic) {
|
||||
fn emit_diagnostic(&mut self, _diag: DiagInner) {
|
||||
self.num_emitted_errors.fetch_add(1, Ordering::Release);
|
||||
}
|
||||
}
|
||||
|
||||
fn build_diagnostic(level: DiagnosticLevel, span: Option<MultiSpan>) -> Diagnostic {
|
||||
let mut diag = Diagnostic::new(level, "");
|
||||
fn build_diagnostic(level: DiagnosticLevel, span: Option<MultiSpan>) -> DiagInner {
|
||||
let mut diag = DiagInner::new(level, "");
|
||||
diag.messages.clear();
|
||||
if let Some(span) = span {
|
||||
diag.span = span;
|
||||
|
@ -13,8 +13,8 @@ extern crate rustc_session;
|
||||
extern crate rustc_span;
|
||||
|
||||
use rustc_errors::{
|
||||
AddToDiagnostic, Diagnostic, DiagnosticBuilder, DiagnosticMessage, EmissionGuarantee, DiagCtxt,
|
||||
IntoDiagnostic, Level, SubdiagnosticMessageOp,
|
||||
AddToDiagnostic, DiagnosticBuilder, EmissionGuarantee, DiagCtxt, IntoDiagnostic, Level,
|
||||
SubdiagnosticMessageOp,
|
||||
};
|
||||
use rustc_macros::{Diagnostic, Subdiagnostic};
|
||||
use rustc_span::Span;
|
||||
|
Loading…
Reference in New Issue
Block a user