From 4e1f9bd528aef7215bb3b446fcdf43368371da37 Mon Sep 17 00:00:00 2001 From: Nicholas Nethercote Date: Fri, 23 Feb 2024 06:42:05 +1100 Subject: 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)`. --- .../src/annotate_snippet_emitter_writer.rs | 4 ++-- compiler/rustc_errors/src/diagnostic.rs | 10 +++++----- compiler/rustc_errors/src/emitter.rs | 20 ++++++++------------ compiler/rustc_errors/src/json.rs | 10 +++++----- compiler/rustc_errors/src/lib.rs | 4 ++-- 5 files changed, 22 insertions(+), 26 deletions(-) (limited to 'compiler/rustc_errors/src') diff --git a/compiler/rustc_errors/src/annotate_snippet_emitter_writer.rs b/compiler/rustc_errors/src/annotate_snippet_emitter_writer.rs index 90a15e290d2..e6668769b95 100644 --- a/compiler/rustc_errors/src/annotate_snippet_emitter_writer.rs +++ b/compiler/rustc_errors/src/annotate_snippet_emitter_writer.rs @@ -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, msp: &MultiSpan, - _children: &[SubDiagnostic], + _children: &[Subdiag], _suggestions: &[CodeSuggestion], ) { let message = self.translate_messages(messages, args); diff --git a/compiler/rustc_errors/src/diagnostic.rs b/compiler/rustc_errors/src/diagnostic.rs index d2011d419e9..38c0fbf6476 100644 --- a/compiler/rustc_errors/src/diagnostic.rs +++ b/compiler/rustc_errors/src/diagnostic.rs @@ -275,7 +275,7 @@ pub struct DiagInner { pub messages: Vec<(DiagnosticMessage, Style)>, pub code: Option, pub span: MultiSpan, - pub children: Vec, + pub children: Vec, pub suggestions: Result, SuggestionsDisabled>, pub args: DiagnosticArgMap, @@ -390,7 +390,7 @@ impl DiagInner { message: impl Into, 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, &MultiSpan, - &[SubDiagnostic], + &[Subdiag], &Result, SuggestionsDisabled>, Vec<(&DiagnosticArgName, &DiagnosticArgValue)>, &Option, @@ -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); } diff --git a/compiler/rustc_errors/src/emitter.rs b/compiler/rustc_errors/src/emitter.rs index bd5f2a77c4a..12eae0cd558 100644 --- a/compiler/rustc_errors/src/emitter.rs +++ b/compiler/rustc_errors/src/emitter.rs @@ -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, + children: &mut Vec, 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, + children: &mut Vec, 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, - ) { + fn fix_multispans_in_extern_macros(&self, span: &mut MultiSpan, children: &mut Vec) { 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, span: &MultiSpan, - children: &[SubDiagnostic], + children: &[Subdiag], suggestions: &[CodeSuggestion], emitted_at: Option<&DiagnosticLocation>, ) { diff --git a/compiler/rustc_errors/src/json.rs b/compiler/rustc_errors/src/json.rs index 99bdf9f99c8..88a83c8bf78 100644 --- a/compiler/rustc_errors/src/json.rs +++ b/compiler/rustc_errors/src/json.rs @@ -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, } diff --git a/compiler/rustc_errors/src/lib.rs b/compiler/rustc_errors/src/lib.rs index 40c51c5eded..6ce8dd4e6e4 100644 --- a/compiler/rustc_errors/src/lib.rs +++ b/compiler/rustc_errors/src/lib.rs @@ -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; -- cgit 1.4.1-3-g733a5