@@ -22,6 +22,8 @@ extern crate rustc_macros;
2222#[ macro_use]
2323extern crate tracing;
2424
25+ extern crate self as rustc_errors;
26+
2527pub use emitter:: ColorConfig ;
2628
2729use rustc_lint_defs:: LintExpectationId ;
@@ -375,13 +377,16 @@ pub struct ExplicitBug;
375377/// rather than a failed assertion, etc.
376378pub struct DelayedBugPanic ;
377379
380+ use crate :: diagnostic_impls:: { DelayedAtWithNewline , DelayedAtWithoutNewline } ;
378381pub use diagnostic:: {
379382 AddToDiagnostic , DecorateLint , Diagnostic , DiagnosticArg , DiagnosticArgValue , DiagnosticId ,
380383 DiagnosticStyledString , IntoDiagnosticArg , SubDiagnostic ,
381384} ;
382385pub use diagnostic_builder:: { DiagnosticBuilder , EmissionGuarantee , Noted } ;
383386pub use diagnostic_impls:: {
384- DiagnosticArgFromDisplay , DiagnosticSymbolList , LabelKind , SingleLabelManySpans ,
387+ DiagnosticArgFromDisplay , DiagnosticSymbolList , ExpectedLifetimeParameter ,
388+ IndicateAnonymousLifetime , InvalidFlushedDelayedDiagnosticLevel , LabelKind ,
389+ SingleLabelManySpans ,
385390} ;
386391use std:: backtrace:: { Backtrace , BacktraceStatus } ;
387392
@@ -1670,11 +1675,10 @@ impl HandlerInner {
16701675 if bug. level != Level :: DelayedBug {
16711676 // NOTE(eddyb) not panicking here because we're already producing
16721677 // an ICE, and the more information the merrier.
1673- bug. note ( format ! (
1674- "`flushed_delayed` got diagnostic with level {:?}, \
1675- instead of the expected `DelayedBug`",
1676- bug. level,
1677- ) ) ;
1678+ bug. subdiagnostic ( InvalidFlushedDelayedDiagnosticLevel {
1679+ span : bug. span . primary_span ( ) . unwrap ( ) ,
1680+ level : bug. level ,
1681+ } ) ;
16781682 }
16791683 bug. level = Level :: Bug ;
16801684
@@ -1741,12 +1745,22 @@ impl DelayedDiagnostic {
17411745 fn decorate ( mut self ) -> Diagnostic {
17421746 match self . note . status ( ) {
17431747 BacktraceStatus :: Captured => {
1744- self . inner . note ( format ! ( "delayed at {}\n {}" , self . inner. emitted_at, self . note) ) ;
1748+ let inner = & self . inner ;
1749+ self . inner . subdiagnostic ( DelayedAtWithNewline {
1750+ span : inner. span . primary_span ( ) . unwrap ( ) ,
1751+ emitted_at : inner. emitted_at . clone ( ) ,
1752+ note : self . note ,
1753+ } ) ;
17451754 }
17461755 // Avoid the needless newline when no backtrace has been captured,
17471756 // the display impl should just be a single line.
17481757 _ => {
1749- self . inner . note ( format ! ( "delayed at {} - {}" , self . inner. emitted_at, self . note) ) ;
1758+ let inner = & self . inner ;
1759+ self . inner . subdiagnostic ( DelayedAtWithoutNewline {
1760+ span : inner. span . primary_span ( ) . unwrap ( ) ,
1761+ emitted_at : inner. emitted_at . clone ( ) ,
1762+ note : self . note ,
1763+ } ) ;
17501764 }
17511765 }
17521766
@@ -1838,20 +1852,20 @@ pub fn add_elided_lifetime_in_path_suggestion(
18381852 incl_angl_brckt : bool ,
18391853 insertion_span : Span ,
18401854) {
1841- diag. span_label ( path_span , format ! ( "expected lifetime parameter{}" , pluralize! ( n ) ) ) ;
1855+ diag. subdiagnostic ( ExpectedLifetimeParameter { span : path_span , count : n } ) ;
18421856 if !source_map. is_span_accessible ( insertion_span) {
18431857 // Do not try to suggest anything if generated by a proc-macro.
18441858 return ;
18451859 }
18461860 let anon_lts = vec ! [ "'_" ; n] . join ( ", " ) ;
18471861 let suggestion =
18481862 if incl_angl_brckt { format ! ( "<{}>" , anon_lts) } else { format ! ( "{}, " , anon_lts) } ;
1849- diag. span_suggestion_verbose (
1850- insertion_span. shrink_to_hi ( ) ,
1851- format ! ( "indicate the anonymous lifetime{}" , pluralize!( n) ) ,
1863+
1864+ diag. subdiagnostic ( IndicateAnonymousLifetime {
1865+ span : insertion_span. shrink_to_hi ( ) ,
1866+ count : n,
18521867 suggestion,
1853- Applicability :: MachineApplicable ,
1854- ) ;
1868+ } ) ;
18551869}
18561870
18571871#[ derive( Clone , Copy , PartialEq , Hash , Debug ) ]
0 commit comments