Skip to content

Commit 29e1120

Browse files
committed
Rename Diagnostic as DiagInner.
I started by changing it to `DiagData`, but that didn't feel right. `DiagInner` felt much better.
1 parent 397937d commit 29e1120

File tree

14 files changed

+87
-87
lines changed

14 files changed

+87
-87
lines changed

compiler/rustc_codegen_ssa/src/back/write.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1829,9 +1829,9 @@ impl Translate for SharedEmitter {
18291829
}
18301830

18311831
impl Emitter for SharedEmitter {
1832-
fn emit_diagnostic(&mut self, mut diag: rustc_errors::Diagnostic) {
1832+
fn emit_diagnostic(&mut self, mut diag: rustc_errors::DiagInner) {
18331833
// Check that we aren't missing anything interesting when converting to
1834-
// the cut-down local `Diagnostic`.
1834+
// the cut-down local `DiagInner`.
18351835
assert_eq!(diag.span, MultiSpan::new());
18361836
assert_eq!(diag.suggestions, Ok(vec![]));
18371837
assert_eq!(diag.sort_span, rustc_span::DUMMY_SP);
@@ -1880,7 +1880,7 @@ impl SharedEmitterMain {
18801880
// Convert it back to a full `Diagnostic` and emit.
18811881
let dcx = sess.dcx();
18821882
let mut d =
1883-
rustc_errors::Diagnostic::new_with_messages(diag.level, diag.messages);
1883+
rustc_errors::DiagInner::new_with_messages(diag.level, diag.messages);
18841884
d.code = diag.code; // may be `None`, that's ok
18851885
d.children = diag
18861886
.children

compiler/rustc_errors/src/annotate_snippet_emitter_writer.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ use crate::emitter::FileWithAnnotatedLines;
99
use crate::snippet::Line;
1010
use crate::translation::{to_fluent_args, Translate};
1111
use crate::{
12-
CodeSuggestion, Diagnostic, DiagnosticMessage, Emitter, ErrCode, FluentBundle,
12+
CodeSuggestion, DiagInner, DiagnosticMessage, Emitter, ErrCode, FluentBundle,
1313
LazyFallbackBundle, Level, MultiSpan, Style, SubDiagnostic,
1414
};
1515
use annotate_snippets::{Annotation, AnnotationType, Renderer, Slice, Snippet, SourceAnnotation};
@@ -44,7 +44,7 @@ impl Translate for AnnotateSnippetEmitter {
4444

4545
impl Emitter for AnnotateSnippetEmitter {
4646
/// The entry point for the diagnostics generation
47-
fn emit_diagnostic(&mut self, mut diag: Diagnostic) {
47+
fn emit_diagnostic(&mut self, mut diag: DiagInner) {
4848
let fluent_args = to_fluent_args(diag.args.iter());
4949

5050
let mut suggestions = diag.suggestions.unwrap_or(vec![]);
@@ -82,7 +82,7 @@ fn source_string(file: Lrc<SourceFile>, line: &Line) -> String {
8282
file.get_line(line.line_index - 1).map(|a| a.to_string()).unwrap_or_default()
8383
}
8484

85-
/// Maps `Diagnostic::Level` to `snippet::AnnotationType`
85+
/// Maps `diagnostic::Level` to `snippet::AnnotationType`
8686
fn annotation_type_for_level(level: Level) -> AnnotationType {
8787
match level {
8888
Level::Bug | Level::Fatal | Level::Error | Level::DelayedBug => AnnotationType::Error,

compiler/rustc_errors/src/diagnostic.rs

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@ use std::ops::{Deref, DerefMut};
1818
use std::panic;
1919
use std::thread::panicking;
2020

21-
/// Error type for `Diagnostic`'s `suggestions` field, indicating that
22-
/// `.disable_suggestions()` was called on the `Diagnostic`.
21+
/// Error type for `DiagInner`'s `suggestions` field, indicating that
22+
/// `.disable_suggestions()` was called on the `DiagInner`.
2323
#[derive(Clone, Debug, PartialEq, Eq, Hash, Encodable, Decodable)]
2424
pub struct SuggestionsDisabled;
2525

@@ -267,7 +267,7 @@ impl StringPart {
267267
/// causes difficulties, e.g. when storing diagnostics within `DiagCtxt`.
268268
#[must_use]
269269
#[derive(Clone, Debug, Encodable, Decodable)]
270-
pub struct Diagnostic {
270+
pub struct DiagInner {
271271
// NOTE(eddyb) this is private to disallow arbitrary after-the-fact changes,
272272
// outside of what methods in this crate themselves allow.
273273
pub(crate) level: Level,
@@ -291,15 +291,15 @@ pub struct Diagnostic {
291291
pub(crate) emitted_at: DiagnosticLocation,
292292
}
293293

294-
impl Diagnostic {
294+
impl DiagInner {
295295
#[track_caller]
296296
pub fn new<M: Into<DiagnosticMessage>>(level: Level, message: M) -> Self {
297-
Diagnostic::new_with_messages(level, vec![(message.into(), Style::NoStyle)])
297+
DiagInner::new_with_messages(level, vec![(message.into(), Style::NoStyle)])
298298
}
299299

300300
#[track_caller]
301301
pub fn new_with_messages(level: Level, messages: Vec<(DiagnosticMessage, Style)>) -> Self {
302-
Diagnostic {
302+
DiagInner {
303303
level,
304304
messages,
305305
code: None,
@@ -433,7 +433,7 @@ impl Diagnostic {
433433
}
434434
}
435435

436-
impl Hash for Diagnostic {
436+
impl Hash for DiagInner {
437437
fn hash<H>(&self, state: &mut H)
438438
where
439439
H: Hasher,
@@ -442,7 +442,7 @@ impl Hash for Diagnostic {
442442
}
443443
}
444444

445-
impl PartialEq for Diagnostic {
445+
impl PartialEq for DiagInner {
446446
fn eq(&self, other: &Self) -> bool {
447447
self.keys() == other.keys()
448448
}
@@ -458,7 +458,7 @@ pub struct SubDiagnostic {
458458
}
459459

460460
/// Used for emitting structured error messages and other diagnostic information.
461-
/// Wraps a `Diagnostic`, adding some useful things.
461+
/// Wraps a `DiagInner`, adding some useful things.
462462
/// - The `dcx` field, allowing it to (a) emit itself, and (b) do a drop check
463463
/// that it has been emitted or cancelled.
464464
/// - The `EmissionGuarantee`, which determines the type returned from `emit`.
@@ -480,11 +480,11 @@ pub struct DiagnosticBuilder<'a, G: EmissionGuarantee = ErrorGuaranteed> {
480480
/// replaced with `None`. Then `drop` checks that it is `None`; if not, it
481481
/// panics because a diagnostic was built but not used.
482482
///
483-
/// Why the Box? `Diagnostic` is a large type, and `DiagnosticBuilder` is
483+
/// Why the Box? `DiagInner` is a large type, and `DiagnosticBuilder` is
484484
/// often used as a return value, especially within the frequently-used
485485
/// `PResult` type. In theory, return value optimization (RVO) should avoid
486486
/// unnecessary copying. In practice, it does not (at the time of writing).
487-
diag: Option<Box<Diagnostic>>,
487+
diag: Option<Box<DiagInner>>,
488488

489489
_marker: PhantomData<G>,
490490
}
@@ -499,15 +499,15 @@ rustc_data_structures::static_assert_size!(
499499
);
500500

501501
impl<G: EmissionGuarantee> Deref for DiagnosticBuilder<'_, G> {
502-
type Target = Diagnostic;
502+
type Target = DiagInner;
503503

504-
fn deref(&self) -> &Diagnostic {
504+
fn deref(&self) -> &DiagInner {
505505
self.diag.as_ref().unwrap()
506506
}
507507
}
508508

509509
impl<G: EmissionGuarantee> DerefMut for DiagnosticBuilder<'_, G> {
510-
fn deref_mut(&mut self) -> &mut Diagnostic {
510+
fn deref_mut(&mut self) -> &mut DiagInner {
511511
self.diag.as_mut().unwrap()
512512
}
513513
}
@@ -565,13 +565,13 @@ impl<'a, G: EmissionGuarantee> DiagnosticBuilder<'a, G> {
565565
#[rustc_lint_diagnostics]
566566
#[track_caller]
567567
pub fn new<M: Into<DiagnosticMessage>>(dcx: &'a DiagCtxt, level: Level, message: M) -> Self {
568-
Self::new_diagnostic(dcx, Diagnostic::new(level, message))
568+
Self::new_diagnostic(dcx, DiagInner::new(level, message))
569569
}
570570

571571
/// Creates a new `DiagnosticBuilder` with an already constructed
572572
/// diagnostic.
573573
#[track_caller]
574-
pub(crate) fn new_diagnostic(dcx: &'a DiagCtxt, diag: Diagnostic) -> Self {
574+
pub(crate) fn new_diagnostic(dcx: &'a DiagCtxt, diag: DiagInner) -> Self {
575575
debug!("Created new diagnostic");
576576
Self { dcx, diag: Some(Box::new(diag)), _marker: PhantomData }
577577
}
@@ -1238,7 +1238,7 @@ impl<'a, G: EmissionGuarantee> DiagnosticBuilder<'a, G> {
12381238
/// Takes the diagnostic. For use by methods that consume the
12391239
/// DiagnosticBuilder: `emit`, `cancel`, etc. Afterwards, `drop` is the
12401240
/// only code that will be run on `self`.
1241-
fn take_diag(&mut self) -> Diagnostic {
1241+
fn take_diag(&mut self) -> DiagInner {
12421242
Box::into_inner(self.diag.take().unwrap())
12431243
}
12441244

@@ -1257,7 +1257,7 @@ impl<'a, G: EmissionGuarantee> DiagnosticBuilder<'a, G> {
12571257
// because delayed bugs have their level changed to `Bug` when they are
12581258
// actually printed, so they produce an ICE.
12591259
//
1260-
// (Also, even though `level` isn't `pub`, the whole `Diagnostic` could
1260+
// (Also, even though `level` isn't `pub`, the whole `DiagInner` could
12611261
// be overwritten with a new one thanks to `DerefMut`. So this assert
12621262
// protects against that, too.)
12631263
assert!(
@@ -1325,7 +1325,7 @@ impl<G: EmissionGuarantee> Drop for DiagnosticBuilder<'_, G> {
13251325
fn drop(&mut self) {
13261326
match self.diag.take() {
13271327
Some(diag) if !panicking() => {
1328-
self.dcx.emit_diagnostic(Diagnostic::new(
1328+
self.dcx.emit_diagnostic(DiagInner::new(
13291329
Level::Bug,
13301330
DiagnosticMessage::from("the following error was constructed but not emitted"),
13311331
));

compiler/rustc_errors/src/emitter.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ use crate::snippet::{
1717
use crate::styled_buffer::StyledBuffer;
1818
use crate::translation::{to_fluent_args, Translate};
1919
use crate::{
20-
diagnostic::DiagnosticLocation, CodeSuggestion, DiagCtxt, Diagnostic, DiagnosticMessage,
20+
diagnostic::DiagnosticLocation, CodeSuggestion, DiagCtxt, DiagInner, DiagnosticMessage,
2121
ErrCode, FluentBundle, LazyFallbackBundle, Level, MultiSpan, SubDiagnostic,
2222
SubstitutionHighlight, SuggestionStyle, TerminalUrl,
2323
};
@@ -194,15 +194,15 @@ pub type DynEmitter = dyn Emitter + DynSend;
194194
/// Emitter trait for emitting errors.
195195
pub trait Emitter: Translate {
196196
/// Emit a structured diagnostic.
197-
fn emit_diagnostic(&mut self, diag: Diagnostic);
197+
fn emit_diagnostic(&mut self, diag: DiagInner);
198198

199199
/// Emit a notification that an artifact has been output.
200200
/// Currently only supported for the JSON format.
201201
fn emit_artifact_notification(&mut self, _path: &Path, _artifact_type: &str) {}
202202

203203
/// Emit a report about future breakage.
204204
/// Currently only supported for the JSON format.
205-
fn emit_future_breakage_report(&mut self, _diags: Vec<Diagnostic>) {}
205+
fn emit_future_breakage_report(&mut self, _diags: Vec<DiagInner>) {}
206206

207207
/// Emit list of unused externs.
208208
/// Currently only supported for the JSON format.
@@ -229,12 +229,12 @@ pub trait Emitter: Translate {
229229
///
230230
/// There are a lot of conditions to this method, but in short:
231231
///
232-
/// * If the current `Diagnostic` has only one visible `CodeSuggestion`,
232+
/// * If the current `DiagInner` has only one visible `CodeSuggestion`,
233233
/// we format the `help` suggestion depending on the content of the
234234
/// substitutions. In that case, we modify the span and clear the
235235
/// suggestions.
236236
///
237-
/// * If the current `Diagnostic` has multiple suggestions,
237+
/// * If the current `DiagInner` has multiple suggestions,
238238
/// we leave `primary_span` and the suggestions untouched.
239239
fn primary_span_formatted(
240240
&mut self,
@@ -518,7 +518,7 @@ impl Emitter for HumanEmitter {
518518
self.sm.as_ref()
519519
}
520520

521-
fn emit_diagnostic(&mut self, mut diag: Diagnostic) {
521+
fn emit_diagnostic(&mut self, mut diag: DiagInner) {
522522
let fluent_args = to_fluent_args(diag.args.iter());
523523

524524
let mut suggestions = diag.suggestions.unwrap_or(vec![]);
@@ -597,7 +597,7 @@ impl Emitter for SilentEmitter {
597597
None
598598
}
599599

600-
fn emit_diagnostic(&mut self, mut diag: Diagnostic) {
600+
fn emit_diagnostic(&mut self, mut diag: DiagInner) {
601601
if diag.level == Level::Fatal {
602602
diag.sub(Level::Note, self.fatal_note.clone(), MultiSpan::new());
603603
self.fatal_dcx.emit_diagnostic(diag);

compiler/rustc_errors/src/json.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,7 @@ impl Translate for JsonEmitter {
176176
}
177177

178178
impl Emitter for JsonEmitter {
179-
fn emit_diagnostic(&mut self, diag: crate::Diagnostic) {
179+
fn emit_diagnostic(&mut self, diag: crate::DiagInner) {
180180
let data = Diagnostic::from_errors_diagnostic(diag, self);
181181
let result = self.emit(EmitTyped::Diagnostic(data));
182182
if let Err(e) = result {
@@ -192,7 +192,7 @@ impl Emitter for JsonEmitter {
192192
}
193193
}
194194

195-
fn emit_future_breakage_report(&mut self, diags: Vec<crate::Diagnostic>) {
195+
fn emit_future_breakage_report(&mut self, diags: Vec<crate::DiagInner>) {
196196
let data: Vec<FutureBreakageItem<'_>> = diags
197197
.into_iter()
198198
.map(|mut diag| {
@@ -340,7 +340,7 @@ struct UnusedExterns<'a, 'b, 'c> {
340340
}
341341

342342
impl Diagnostic {
343-
fn from_errors_diagnostic(diag: crate::Diagnostic, je: &JsonEmitter) -> Diagnostic {
343+
fn from_errors_diagnostic(diag: crate::DiagInner, je: &JsonEmitter) -> Diagnostic {
344344
let args = to_fluent_args(diag.args.iter());
345345
let sugg = diag.suggestions.iter().flatten().map(|sugg| {
346346
let translated_message =

0 commit comments

Comments
 (0)