@@ -66,6 +66,7 @@ use rustc_span::{DUMMY_SP, Span};
6666use tracing:: debug;
6767
6868use crate :: emitter:: TimingEvent ;
69+ use crate :: formatting:: DiagMessageAddArg ;
6970pub use crate :: formatting:: format_diag_message;
7071use crate :: timings:: TimingRecord ;
7172
@@ -482,16 +483,6 @@ impl DiagCtxt {
482483 self . inner . borrow_mut ( ) . emitter = emitter;
483484 }
484485
485- /// Format `message` eagerly with `args` to `DiagMessage::Eager`.
486- pub fn eagerly_format < ' a > (
487- & self ,
488- message : DiagMessage ,
489- args : impl Iterator < Item = DiagArg < ' a > > ,
490- ) -> DiagMessage {
491- let inner = self . inner . borrow ( ) ;
492- inner. eagerly_format ( message, args)
493- }
494-
495486 /// Format `message` eagerly with `args` to `String`.
496487 pub fn eagerly_format_to_string < ' a > (
497488 & self ,
@@ -1417,15 +1408,6 @@ impl DiagCtxtInner {
14171408 self . has_errors ( ) . or_else ( || self . delayed_bugs . get ( 0 ) . map ( |( _, guar) | guar) . copied ( ) )
14181409 }
14191410
1420- /// Format `message` eagerly with `args` to `DiagMessage::Eager`.
1421- fn eagerly_format < ' a > (
1422- & self ,
1423- message : DiagMessage ,
1424- args : impl Iterator < Item = DiagArg < ' a > > ,
1425- ) -> DiagMessage {
1426- DiagMessage :: Str ( Cow :: from ( self . eagerly_format_to_string ( message, args) ) )
1427- }
1428-
14291411 /// Format `message` eagerly with `args` to `String`.
14301412 fn eagerly_format_to_string < ' a > (
14311413 & self ,
@@ -1436,14 +1418,6 @@ impl DiagCtxtInner {
14361418 format_diag_message ( & message, & args) . to_string ( )
14371419 }
14381420
1439- fn eagerly_format_for_subdiag (
1440- & self ,
1441- diag : & DiagInner ,
1442- msg : impl Into < DiagMessage > ,
1443- ) -> DiagMessage {
1444- self . eagerly_format ( msg. into ( ) , diag. args . iter ( ) )
1445- }
1446-
14471421 fn flush_delayed ( & mut self ) {
14481422 // Stashed diagnostics must be emitted before delayed bugs are flushed.
14491423 // Otherwise, we might ICE prematurely when errors would have
@@ -1493,7 +1467,7 @@ impl DiagCtxtInner {
14931467 ) ;
14941468 }
14951469
1496- let mut bug = if decorate { bug. decorate ( self ) } else { bug. inner } ;
1470+ let mut bug = if decorate { bug. decorate ( ) } else { bug. inner } ;
14971471
14981472 // "Undelay" the delayed bugs into plain bugs.
14991473 if bug. level != DelayedBug {
@@ -1503,11 +1477,9 @@ impl DiagCtxtInner {
15031477 // We are at the `DiagInner`/`DiagCtxtInner` level rather than
15041478 // the usual `Diag`/`DiagCtxt` level, so we must augment `bug`
15051479 // in a lower-level fashion.
1506- bug. arg ( "level" , bug. level ) ;
15071480 let msg = msg ! (
15081481 "`flushed_delayed` got diagnostic with level {$level}, instead of the expected `DelayedBug`"
1509- ) ;
1510- let msg = self . eagerly_format_for_subdiag ( & bug, msg) ; // after the `arg` call
1482+ ) . arg ( "level" , bug. level ) . format ( ) ;
15111483 bug. sub ( Note , msg, bug. span . primary_span ( ) . unwrap ( ) . into ( ) ) ;
15121484 }
15131485 bug. level = Bug ;
@@ -1542,7 +1514,7 @@ impl DelayedDiagInner {
15421514 DelayedDiagInner { inner : diagnostic, note : backtrace }
15431515 }
15441516
1545- fn decorate ( self , dcx : & DiagCtxtInner ) -> DiagInner {
1517+ fn decorate ( self ) -> DiagInner {
15461518 // We are at the `DiagInner`/`DiagCtxtInner` level rather than the
15471519 // usual `Diag`/`DiagCtxt` level, so we must construct `diag` in a
15481520 // lower-level fashion.
@@ -1555,10 +1527,10 @@ impl DelayedDiagInner {
15551527 // Avoid the needless newline when no backtrace has been captured,
15561528 // the display impl should just be a single line.
15571529 _ => msg ! ( "delayed at {$emitted_at} - {$note}" ) ,
1558- } ;
1559- diag . arg ( "emitted_at" , diag. emitted_at . clone ( ) ) ;
1560- diag . arg ( "note" , self . note ) ;
1561- let msg = dcx . eagerly_format_for_subdiag ( & diag , msg ) ; // after the `arg` calls
1530+ }
1531+ . arg ( "emitted_at" , diag. emitted_at . clone ( ) )
1532+ . arg ( "note" , self . note )
1533+ . format ( ) ;
15621534 diag. sub ( Note , msg, diag. span . primary_span ( ) . unwrap_or ( DUMMY_SP ) . into ( ) ) ;
15631535 diag
15641536 }
0 commit comments