Skip to content

Commit 4e1f9bd

Browse files
committed
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)`.
1 parent 366536b commit 4e1f9bd

File tree

6 files changed

+23
-27
lines changed

6 files changed

+23
-27
lines changed

compiler/rustc_codegen_ssa/src/back/write.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1885,7 +1885,7 @@ impl SharedEmitterMain {
18851885
d.children = diag
18861886
.children
18871887
.into_iter()
1888-
.map(|sub| rustc_errors::SubDiagnostic {
1888+
.map(|sub| rustc_errors::Subdiag {
18891889
level: sub.level,
18901890
messages: sub.messages,
18911891
span: MultiSpan::new(),

compiler/rustc_errors/src/annotate_snippet_emitter_writer.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ use crate::snippet::Line;
1010
use crate::translation::{to_fluent_args, Translate};
1111
use crate::{
1212
CodeSuggestion, DiagInner, DiagnosticMessage, Emitter, ErrCode, FluentBundle,
13-
LazyFallbackBundle, Level, MultiSpan, Style, SubDiagnostic,
13+
LazyFallbackBundle, Level, MultiSpan, Style, Subdiag,
1414
};
1515
use annotate_snippets::{Annotation, AnnotationType, Renderer, Slice, Snippet, SourceAnnotation};
1616
use rustc_data_structures::sync::Lrc;
@@ -129,7 +129,7 @@ impl AnnotateSnippetEmitter {
129129
args: &FluentArgs<'_>,
130130
code: &Option<ErrCode>,
131131
msp: &MultiSpan,
132-
_children: &[SubDiagnostic],
132+
_children: &[Subdiag],
133133
_suggestions: &[CodeSuggestion],
134134
) {
135135
let message = self.translate_messages(messages, args);

compiler/rustc_errors/src/diagnostic.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -275,7 +275,7 @@ pub struct DiagInner {
275275
pub messages: Vec<(DiagnosticMessage, Style)>,
276276
pub code: Option<ErrCode>,
277277
pub span: MultiSpan,
278-
pub children: Vec<SubDiagnostic>,
278+
pub children: Vec<Subdiag>,
279279
pub suggestions: Result<Vec<CodeSuggestion>, SuggestionsDisabled>,
280280
pub args: DiagnosticArgMap,
281281

@@ -390,7 +390,7 @@ impl DiagInner {
390390
message: impl Into<SubdiagnosticMessage>,
391391
span: MultiSpan,
392392
) {
393-
let sub = SubDiagnostic {
393+
let sub = Subdiag {
394394
level,
395395
messages: vec![(
396396
self.subdiagnostic_message_to_diagnostic_message(message),
@@ -413,7 +413,7 @@ impl DiagInner {
413413
&[(DiagnosticMessage, Style)],
414414
&Option<ErrCode>,
415415
&MultiSpan,
416-
&[SubDiagnostic],
416+
&[Subdiag],
417417
&Result<Vec<CodeSuggestion>, SuggestionsDisabled>,
418418
Vec<(&DiagnosticArgName, &DiagnosticArgValue)>,
419419
&Option<IsLint>,
@@ -451,7 +451,7 @@ impl PartialEq for DiagInner {
451451
/// A "sub"-diagnostic attached to a parent diagnostic.
452452
/// For example, a note attached to an error.
453453
#[derive(Clone, Debug, PartialEq, Hash, Encodable, Decodable)]
454-
pub struct SubDiagnostic {
454+
pub struct Subdiag {
455455
pub level: Level,
456456
pub messages: Vec<(DiagnosticMessage, Style)>,
457457
pub span: MultiSpan,
@@ -1231,7 +1231,7 @@ impl<'a, G: EmissionGuarantee> DiagnosticBuilder<'a, G> {
12311231
.into_iter()
12321232
.map(|m| (self.subdiagnostic_message_to_diagnostic_message(m.content), m.style))
12331233
.collect();
1234-
let sub = SubDiagnostic { level, messages, span };
1234+
let sub = Subdiag { level, messages, span };
12351235
self.children.push(sub);
12361236
}
12371237

compiler/rustc_errors/src/emitter.rs

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@ use crate::styled_buffer::StyledBuffer;
1818
use crate::translation::{to_fluent_args, Translate};
1919
use crate::{
2020
diagnostic::DiagnosticLocation, CodeSuggestion, DiagCtxt, DiagInner, DiagnosticMessage,
21-
ErrCode, FluentBundle, LazyFallbackBundle, Level, MultiSpan, SubDiagnostic,
22-
SubstitutionHighlight, SuggestionStyle, TerminalUrl,
21+
ErrCode, FluentBundle, LazyFallbackBundle, Level, MultiSpan, Subdiag, SubstitutionHighlight,
22+
SuggestionStyle, TerminalUrl,
2323
};
2424
use rustc_lint_defs::pluralize;
2525

@@ -303,7 +303,7 @@ pub trait Emitter: Translate {
303303
fn fix_multispans_in_extern_macros_and_render_macro_backtrace(
304304
&self,
305305
span: &mut MultiSpan,
306-
children: &mut Vec<SubDiagnostic>,
306+
children: &mut Vec<Subdiag>,
307307
level: &Level,
308308
backtrace: bool,
309309
) {
@@ -350,7 +350,7 @@ pub trait Emitter: Translate {
350350
(in Nightly builds, run with -Z macro-backtrace for more info)",
351351
);
352352

353-
children.push(SubDiagnostic {
353+
children.push(Subdiag {
354354
level: Level::Note,
355355
messages: vec![(DiagnosticMessage::from(msg), Style::NoStyle)],
356356
span: MultiSpan::new(),
@@ -362,7 +362,7 @@ pub trait Emitter: Translate {
362362
fn render_multispans_macro_backtrace(
363363
&self,
364364
span: &mut MultiSpan,
365-
children: &mut Vec<SubDiagnostic>,
365+
children: &mut Vec<Subdiag>,
366366
backtrace: bool,
367367
) {
368368
for span in iter::once(span).chain(children.iter_mut().map(|child| &mut child.span)) {
@@ -461,11 +461,7 @@ pub trait Emitter: Translate {
461461
// This does a small "fix" for multispans by looking to see if it can find any that
462462
// point directly at external macros. Since these are often difficult to read,
463463
// this will change the span to point at the use site.
464-
fn fix_multispans_in_extern_macros(
465-
&self,
466-
span: &mut MultiSpan,
467-
children: &mut Vec<SubDiagnostic>,
468-
) {
464+
fn fix_multispans_in_extern_macros(&self, span: &mut MultiSpan, children: &mut Vec<Subdiag>) {
469465
debug!("fix_multispans_in_extern_macros: before: span={:?} children={:?}", span, children);
470466
self.fix_multispan_in_extern_macros(span);
471467
for child in children.iter_mut() {
@@ -1235,7 +1231,7 @@ impl HumanEmitter {
12351231
max
12361232
}
12371233

1238-
fn get_max_line_num(&mut self, span: &MultiSpan, children: &[SubDiagnostic]) -> usize {
1234+
fn get_max_line_num(&mut self, span: &MultiSpan, children: &[Subdiag]) -> usize {
12391235
let primary = self.get_multispan_max_line_num(span);
12401236
children
12411237
.iter()
@@ -2098,7 +2094,7 @@ impl HumanEmitter {
20982094
args: &FluentArgs<'_>,
20992095
code: &Option<ErrCode>,
21002096
span: &MultiSpan,
2101-
children: &[SubDiagnostic],
2097+
children: &[Subdiag],
21022098
suggestions: &[CodeSuggestion],
21032099
emitted_at: Option<&DiagnosticLocation>,
21042100
) {

compiler/rustc_errors/src/json.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ use crate::registry::Registry;
1717
use crate::translation::{to_fluent_args, Translate};
1818
use crate::{
1919
diagnostic::IsLint, CodeSuggestion, FluentBundle, LazyFallbackBundle, MultiSpan, SpanLabel,
20-
SubDiagnostic, TerminalUrl,
20+
Subdiag, TerminalUrl,
2121
};
2222
use rustc_lint_defs::Applicability;
2323

@@ -431,16 +431,16 @@ impl Diagnostic {
431431
}
432432

433433
fn from_sub_diagnostic(
434-
diag: &SubDiagnostic,
434+
subdiag: &Subdiag,
435435
args: &FluentArgs<'_>,
436436
je: &JsonEmitter,
437437
) -> Diagnostic {
438-
let translated_message = je.translate_messages(&diag.messages, args);
438+
let translated_message = je.translate_messages(&subdiag.messages, args);
439439
Diagnostic {
440440
message: translated_message.to_string(),
441441
code: None,
442-
level: diag.level.to_str(),
443-
spans: DiagnosticSpan::from_multispan(&diag.span, args, je),
442+
level: subdiag.level.to_str(),
443+
spans: DiagnosticSpan::from_multispan(&subdiag.span, args, je),
444444
children: vec![],
445445
rendered: None,
446446
}

compiler/rustc_errors/src/lib.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ pub use codes::*;
3939
pub use diagnostic::{
4040
AddToDiagnostic, BugAbort, DecorateLint, DiagInner, DiagnosticArg, DiagnosticArgMap,
4141
DiagnosticArgName, DiagnosticArgValue, DiagnosticBuilder, DiagnosticStyledString,
42-
EmissionGuarantee, FatalAbort, IntoDiagnostic, IntoDiagnosticArg, StringPart, SubDiagnostic,
42+
EmissionGuarantee, FatalAbort, IntoDiagnostic, IntoDiagnosticArg, StringPart, Subdiag,
4343
SubdiagnosticMessageOp,
4444
};
4545
pub use diagnostic_impls::{
@@ -1393,7 +1393,7 @@ impl DiagCtxtInner {
13931393
debug!(?diagnostic);
13941394
debug!(?self.emitted_diagnostics);
13951395

1396-
let already_emitted_sub = |sub: &mut SubDiagnostic| {
1396+
let already_emitted_sub = |sub: &mut Subdiag| {
13971397
debug!(?sub);
13981398
if sub.level != OnceNote && sub.level != OnceHelp {
13991399
return false;

0 commit comments

Comments
 (0)