Rename SubDiagnostic as Subdiag.

Note the change of the `D` to `d`, to match all the other names that
have `Subdiag` in them, such as `SubdiagnosticMessage` and
`derive(Subdiagnostic)`.
This commit is contained in:
Nicholas Nethercote 2024-02-23 06:42:05 +11:00
parent 366536ba2b
commit 4e1f9bd528
6 changed files with 23 additions and 27 deletions

View File

@ -1885,7 +1885,7 @@ impl SharedEmitterMain {
d.children = diag
.children
.into_iter()
.map(|sub| rustc_errors::SubDiagnostic {
.map(|sub| rustc_errors::Subdiag {
level: sub.level,
messages: sub.messages,
span: MultiSpan::new(),

View File

@ -10,7 +10,7 @@ use crate::snippet::Line;
use crate::translation::{to_fluent_args, Translate};
use crate::{
CodeSuggestion, DiagInner, DiagnosticMessage, Emitter, ErrCode, FluentBundle,
LazyFallbackBundle, Level, MultiSpan, Style, SubDiagnostic,
LazyFallbackBundle, Level, MultiSpan, Style, Subdiag,
};
use annotate_snippets::{Annotation, AnnotationType, Renderer, Slice, Snippet, SourceAnnotation};
use rustc_data_structures::sync::Lrc;
@ -129,7 +129,7 @@ impl AnnotateSnippetEmitter {
args: &FluentArgs<'_>,
code: &Option<ErrCode>,
msp: &MultiSpan,
_children: &[SubDiagnostic],
_children: &[Subdiag],
_suggestions: &[CodeSuggestion],
) {
let message = self.translate_messages(messages, args);

View File

@ -275,7 +275,7 @@ pub struct DiagInner {
pub messages: Vec<(DiagnosticMessage, Style)>,
pub code: Option<ErrCode>,
pub span: MultiSpan,
pub children: Vec<SubDiagnostic>,
pub children: Vec<Subdiag>,
pub suggestions: Result<Vec<CodeSuggestion>, SuggestionsDisabled>,
pub args: DiagnosticArgMap,
@ -390,7 +390,7 @@ impl DiagInner {
message: impl Into<SubdiagnosticMessage>,
span: MultiSpan,
) {
let sub = SubDiagnostic {
let sub = Subdiag {
level,
messages: vec![(
self.subdiagnostic_message_to_diagnostic_message(message),
@ -413,7 +413,7 @@ impl DiagInner {
&[(DiagnosticMessage, Style)],
&Option<ErrCode>,
&MultiSpan,
&[SubDiagnostic],
&[Subdiag],
&Result<Vec<CodeSuggestion>, SuggestionsDisabled>,
Vec<(&DiagnosticArgName, &DiagnosticArgValue)>,
&Option<IsLint>,
@ -451,7 +451,7 @@ impl PartialEq for DiagInner {
/// A "sub"-diagnostic attached to a parent diagnostic.
/// For example, a note attached to an error.
#[derive(Clone, Debug, PartialEq, Hash, Encodable, Decodable)]
pub struct SubDiagnostic {
pub struct Subdiag {
pub level: Level,
pub messages: Vec<(DiagnosticMessage, Style)>,
pub span: MultiSpan,
@ -1231,7 +1231,7 @@ impl<'a, G: EmissionGuarantee> DiagnosticBuilder<'a, G> {
.into_iter()
.map(|m| (self.subdiagnostic_message_to_diagnostic_message(m.content), m.style))
.collect();
let sub = SubDiagnostic { level, messages, span };
let sub = Subdiag { level, messages, span };
self.children.push(sub);
}

View File

@ -18,8 +18,8 @@ use crate::styled_buffer::StyledBuffer;
use crate::translation::{to_fluent_args, Translate};
use crate::{
diagnostic::DiagnosticLocation, CodeSuggestion, DiagCtxt, DiagInner, DiagnosticMessage,
ErrCode, FluentBundle, LazyFallbackBundle, Level, MultiSpan, SubDiagnostic,
SubstitutionHighlight, SuggestionStyle, TerminalUrl,
ErrCode, FluentBundle, LazyFallbackBundle, Level, MultiSpan, Subdiag, SubstitutionHighlight,
SuggestionStyle, TerminalUrl,
};
use rustc_lint_defs::pluralize;
@ -303,7 +303,7 @@ pub trait Emitter: Translate {
fn fix_multispans_in_extern_macros_and_render_macro_backtrace(
&self,
span: &mut MultiSpan,
children: &mut Vec<SubDiagnostic>,
children: &mut Vec<Subdiag>,
level: &Level,
backtrace: bool,
) {
@ -350,7 +350,7 @@ pub trait Emitter: Translate {
(in Nightly builds, run with -Z macro-backtrace for more info)",
);
children.push(SubDiagnostic {
children.push(Subdiag {
level: Level::Note,
messages: vec![(DiagnosticMessage::from(msg), Style::NoStyle)],
span: MultiSpan::new(),
@ -362,7 +362,7 @@ pub trait Emitter: Translate {
fn render_multispans_macro_backtrace(
&self,
span: &mut MultiSpan,
children: &mut Vec<SubDiagnostic>,
children: &mut Vec<Subdiag>,
backtrace: bool,
) {
for span in iter::once(span).chain(children.iter_mut().map(|child| &mut child.span)) {
@ -461,11 +461,7 @@ pub trait Emitter: Translate {
// This does a small "fix" for multispans by looking to see if it can find any that
// point directly at external macros. Since these are often difficult to read,
// this will change the span to point at the use site.
fn fix_multispans_in_extern_macros(
&self,
span: &mut MultiSpan,
children: &mut Vec<SubDiagnostic>,
) {
fn fix_multispans_in_extern_macros(&self, span: &mut MultiSpan, children: &mut Vec<Subdiag>) {
debug!("fix_multispans_in_extern_macros: before: span={:?} children={:?}", span, children);
self.fix_multispan_in_extern_macros(span);
for child in children.iter_mut() {
@ -1235,7 +1231,7 @@ impl HumanEmitter {
max
}
fn get_max_line_num(&mut self, span: &MultiSpan, children: &[SubDiagnostic]) -> usize {
fn get_max_line_num(&mut self, span: &MultiSpan, children: &[Subdiag]) -> usize {
let primary = self.get_multispan_max_line_num(span);
children
.iter()
@ -2098,7 +2094,7 @@ impl HumanEmitter {
args: &FluentArgs<'_>,
code: &Option<ErrCode>,
span: &MultiSpan,
children: &[SubDiagnostic],
children: &[Subdiag],
suggestions: &[CodeSuggestion],
emitted_at: Option<&DiagnosticLocation>,
) {

View File

@ -17,7 +17,7 @@ use crate::registry::Registry;
use crate::translation::{to_fluent_args, Translate};
use crate::{
diagnostic::IsLint, CodeSuggestion, FluentBundle, LazyFallbackBundle, MultiSpan, SpanLabel,
SubDiagnostic, TerminalUrl,
Subdiag, TerminalUrl,
};
use rustc_lint_defs::Applicability;
@ -431,16 +431,16 @@ impl Diagnostic {
}
fn from_sub_diagnostic(
diag: &SubDiagnostic,
subdiag: &Subdiag,
args: &FluentArgs<'_>,
je: &JsonEmitter,
) -> Diagnostic {
let translated_message = je.translate_messages(&diag.messages, args);
let translated_message = je.translate_messages(&subdiag.messages, args);
Diagnostic {
message: translated_message.to_string(),
code: None,
level: diag.level.to_str(),
spans: DiagnosticSpan::from_multispan(&diag.span, args, je),
level: subdiag.level.to_str(),
spans: DiagnosticSpan::from_multispan(&subdiag.span, args, je),
children: vec![],
rendered: None,
}

View File

@ -39,7 +39,7 @@ pub use codes::*;
pub use diagnostic::{
AddToDiagnostic, BugAbort, DecorateLint, DiagInner, DiagnosticArg, DiagnosticArgMap,
DiagnosticArgName, DiagnosticArgValue, DiagnosticBuilder, DiagnosticStyledString,
EmissionGuarantee, FatalAbort, IntoDiagnostic, IntoDiagnosticArg, StringPart, SubDiagnostic,
EmissionGuarantee, FatalAbort, IntoDiagnostic, IntoDiagnosticArg, StringPart, Subdiag,
SubdiagnosticMessageOp,
};
pub use diagnostic_impls::{
@ -1393,7 +1393,7 @@ impl DiagCtxtInner {
debug!(?diagnostic);
debug!(?self.emitted_diagnostics);
let already_emitted_sub = |sub: &mut SubDiagnostic| {
let already_emitted_sub = |sub: &mut Subdiag| {
debug!(?sub);
if sub.level != OnceNote && sub.level != OnceHelp {
return false;