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 d.children = diag
.children .children
.into_iter() .into_iter()
.map(|sub| rustc_errors::SubDiagnostic { .map(|sub| rustc_errors::Subdiag {
level: sub.level, level: sub.level,
messages: sub.messages, messages: sub.messages,
span: MultiSpan::new(), span: MultiSpan::new(),

View File

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

View File

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

View File

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

View File

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

View File

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