@@ -18,8 +18,8 @@ use std::ops::{Deref, DerefMut};
18
18
use std:: panic;
19
19
use std:: thread:: panicking;
20
20
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 `.
23
23
#[ derive( Clone , Debug , PartialEq , Eq , Hash , Encodable , Decodable ) ]
24
24
pub struct SuggestionsDisabled ;
25
25
@@ -267,7 +267,7 @@ impl StringPart {
267
267
/// causes difficulties, e.g. when storing diagnostics within `DiagCtxt`.
268
268
#[ must_use]
269
269
#[ derive( Clone , Debug , Encodable , Decodable ) ]
270
- pub struct Diagnostic {
270
+ pub struct DiagInner {
271
271
// NOTE(eddyb) this is private to disallow arbitrary after-the-fact changes,
272
272
// outside of what methods in this crate themselves allow.
273
273
pub ( crate ) level : Level ,
@@ -291,15 +291,15 @@ pub struct Diagnostic {
291
291
pub ( crate ) emitted_at : DiagnosticLocation ,
292
292
}
293
293
294
- impl Diagnostic {
294
+ impl DiagInner {
295
295
#[ track_caller]
296
296
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 ) ] )
298
298
}
299
299
300
300
#[ track_caller]
301
301
pub fn new_with_messages ( level : Level , messages : Vec < ( DiagnosticMessage , Style ) > ) -> Self {
302
- Diagnostic {
302
+ DiagInner {
303
303
level,
304
304
messages,
305
305
code : None ,
@@ -433,7 +433,7 @@ impl Diagnostic {
433
433
}
434
434
}
435
435
436
- impl Hash for Diagnostic {
436
+ impl Hash for DiagInner {
437
437
fn hash < H > ( & self , state : & mut H )
438
438
where
439
439
H : Hasher ,
@@ -442,7 +442,7 @@ impl Hash for Diagnostic {
442
442
}
443
443
}
444
444
445
- impl PartialEq for Diagnostic {
445
+ impl PartialEq for DiagInner {
446
446
fn eq ( & self , other : & Self ) -> bool {
447
447
self . keys ( ) == other. keys ( )
448
448
}
@@ -458,7 +458,7 @@ pub struct SubDiagnostic {
458
458
}
459
459
460
460
/// 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.
462
462
/// - The `dcx` field, allowing it to (a) emit itself, and (b) do a drop check
463
463
/// that it has been emitted or cancelled.
464
464
/// - The `EmissionGuarantee`, which determines the type returned from `emit`.
@@ -480,11 +480,11 @@ pub struct DiagnosticBuilder<'a, G: EmissionGuarantee = ErrorGuaranteed> {
480
480
/// replaced with `None`. Then `drop` checks that it is `None`; if not, it
481
481
/// panics because a diagnostic was built but not used.
482
482
///
483
- /// Why the Box? `Diagnostic ` is a large type, and `DiagnosticBuilder` is
483
+ /// Why the Box? `DiagInner ` is a large type, and `DiagnosticBuilder` is
484
484
/// often used as a return value, especially within the frequently-used
485
485
/// `PResult` type. In theory, return value optimization (RVO) should avoid
486
486
/// unnecessary copying. In practice, it does not (at the time of writing).
487
- diag : Option < Box < Diagnostic > > ,
487
+ diag : Option < Box < DiagInner > > ,
488
488
489
489
_marker : PhantomData < G > ,
490
490
}
@@ -499,15 +499,15 @@ rustc_data_structures::static_assert_size!(
499
499
) ;
500
500
501
501
impl < G : EmissionGuarantee > Deref for DiagnosticBuilder < ' _ , G > {
502
- type Target = Diagnostic ;
502
+ type Target = DiagInner ;
503
503
504
- fn deref ( & self ) -> & Diagnostic {
504
+ fn deref ( & self ) -> & DiagInner {
505
505
self . diag . as_ref ( ) . unwrap ( )
506
506
}
507
507
}
508
508
509
509
impl < G : EmissionGuarantee > DerefMut for DiagnosticBuilder < ' _ , G > {
510
- fn deref_mut ( & mut self ) -> & mut Diagnostic {
510
+ fn deref_mut ( & mut self ) -> & mut DiagInner {
511
511
self . diag . as_mut ( ) . unwrap ( )
512
512
}
513
513
}
@@ -565,13 +565,13 @@ impl<'a, G: EmissionGuarantee> DiagnosticBuilder<'a, G> {
565
565
#[ rustc_lint_diagnostics]
566
566
#[ track_caller]
567
567
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) )
569
569
}
570
570
571
571
/// Creates a new `DiagnosticBuilder` with an already constructed
572
572
/// diagnostic.
573
573
#[ 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 {
575
575
debug ! ( "Created new diagnostic" ) ;
576
576
Self { dcx, diag : Some ( Box :: new ( diag) ) , _marker : PhantomData }
577
577
}
@@ -1238,7 +1238,7 @@ impl<'a, G: EmissionGuarantee> DiagnosticBuilder<'a, G> {
1238
1238
/// Takes the diagnostic. For use by methods that consume the
1239
1239
/// DiagnosticBuilder: `emit`, `cancel`, etc. Afterwards, `drop` is the
1240
1240
/// only code that will be run on `self`.
1241
- fn take_diag ( & mut self ) -> Diagnostic {
1241
+ fn take_diag ( & mut self ) -> DiagInner {
1242
1242
Box :: into_inner ( self . diag . take ( ) . unwrap ( ) )
1243
1243
}
1244
1244
@@ -1257,7 +1257,7 @@ impl<'a, G: EmissionGuarantee> DiagnosticBuilder<'a, G> {
1257
1257
// because delayed bugs have their level changed to `Bug` when they are
1258
1258
// actually printed, so they produce an ICE.
1259
1259
//
1260
- // (Also, even though `level` isn't `pub`, the whole `Diagnostic ` could
1260
+ // (Also, even though `level` isn't `pub`, the whole `DiagInner ` could
1261
1261
// be overwritten with a new one thanks to `DerefMut`. So this assert
1262
1262
// protects against that, too.)
1263
1263
assert ! (
@@ -1325,7 +1325,7 @@ impl<G: EmissionGuarantee> Drop for DiagnosticBuilder<'_, G> {
1325
1325
fn drop ( & mut self ) {
1326
1326
match self . diag . take ( ) {
1327
1327
Some ( diag) if !panicking ( ) => {
1328
- self . dcx . emit_diagnostic ( Diagnostic :: new (
1328
+ self . dcx . emit_diagnostic ( DiagInner :: new (
1329
1329
Level :: Bug ,
1330
1330
DiagnosticMessage :: from ( "the following error was constructed but not emitted" ) ,
1331
1331
) ) ;
0 commit comments