@@ -18,8 +18,8 @@ use std::ops::{Deref, DerefMut};
1818use std:: panic;
1919use 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 ) ]
2424pub 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
501501impl < 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
509509impl < 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 ) ) ;
0 commit comments