@@ -22,6 +22,8 @@ extern crate rustc_macros;
22
22
#[ macro_use]
23
23
extern crate tracing;
24
24
25
+ extern crate self as rustc_errors;
26
+
25
27
pub use emitter:: ColorConfig ;
26
28
27
29
use rustc_lint_defs:: LintExpectationId ;
@@ -377,13 +379,16 @@ pub struct ExplicitBug;
377
379
/// rather than a failed assertion, etc.
378
380
pub struct DelayedBugPanic ;
379
381
382
+ use crate :: diagnostic_impls:: { DelayedAtWithNewline , DelayedAtWithoutNewline } ;
380
383
pub use diagnostic:: {
381
384
AddToDiagnostic , DecorateLint , Diagnostic , DiagnosticArg , DiagnosticArgValue , DiagnosticId ,
382
385
DiagnosticStyledString , IntoDiagnosticArg , SubDiagnostic ,
383
386
} ;
384
387
pub use diagnostic_builder:: { DiagnosticBuilder , EmissionGuarantee , Noted } ;
385
388
pub use diagnostic_impls:: {
386
- DiagnosticArgFromDisplay , DiagnosticSymbolList , LabelKind , SingleLabelManySpans ,
389
+ DiagnosticArgFromDisplay , DiagnosticSymbolList , ExpectedLifetimeParameter ,
390
+ IndicateAnonymousLifetime , InvalidFlushedDelayedDiagnosticLevel , LabelKind ,
391
+ SingleLabelManySpans ,
387
392
} ;
388
393
use std:: backtrace:: { Backtrace , BacktraceStatus } ;
389
394
@@ -1673,11 +1678,10 @@ impl HandlerInner {
1673
1678
if bug. level != Level :: DelayedBug {
1674
1679
// NOTE(eddyb) not panicking here because we're already producing
1675
1680
// an ICE, and the more information the merrier.
1676
- bug. note ( format ! (
1677
- "`flushed_delayed` got diagnostic with level {:?}, \
1678
- instead of the expected `DelayedBug`",
1679
- bug. level,
1680
- ) ) ;
1681
+ bug. subdiagnostic ( InvalidFlushedDelayedDiagnosticLevel {
1682
+ span : bug. span . primary_span ( ) . unwrap ( ) ,
1683
+ level : bug. level ,
1684
+ } ) ;
1681
1685
}
1682
1686
bug. level = Level :: Bug ;
1683
1687
@@ -1744,12 +1748,22 @@ impl DelayedDiagnostic {
1744
1748
fn decorate ( mut self ) -> Diagnostic {
1745
1749
match self . note . status ( ) {
1746
1750
BacktraceStatus :: Captured => {
1747
- self . inner . note ( format ! ( "delayed at {}\n {}" , self . inner. emitted_at, self . note) ) ;
1751
+ let inner = & self . inner ;
1752
+ self . inner . subdiagnostic ( DelayedAtWithNewline {
1753
+ span : inner. span . primary_span ( ) . unwrap ( ) ,
1754
+ emitted_at : inner. emitted_at . clone ( ) ,
1755
+ note : self . note ,
1756
+ } ) ;
1748
1757
}
1749
1758
// Avoid the needless newline when no backtrace has been captured,
1750
1759
// the display impl should just be a single line.
1751
1760
_ => {
1752
- self . inner . note ( format ! ( "delayed at {} - {}" , self . inner. emitted_at, self . note) ) ;
1761
+ let inner = & self . inner ;
1762
+ self . inner . subdiagnostic ( DelayedAtWithoutNewline {
1763
+ span : inner. span . primary_span ( ) . unwrap ( ) ,
1764
+ emitted_at : inner. emitted_at . clone ( ) ,
1765
+ note : self . note ,
1766
+ } ) ;
1753
1767
}
1754
1768
}
1755
1769
@@ -1841,20 +1855,20 @@ pub fn add_elided_lifetime_in_path_suggestion(
1841
1855
incl_angl_brckt : bool ,
1842
1856
insertion_span : Span ,
1843
1857
) {
1844
- diag. span_label ( path_span , format ! ( "expected lifetime parameter{}" , pluralize! ( n ) ) ) ;
1858
+ diag. subdiagnostic ( ExpectedLifetimeParameter { span : path_span , count : n } ) ;
1845
1859
if !source_map. is_span_accessible ( insertion_span) {
1846
1860
// Do not try to suggest anything if generated by a proc-macro.
1847
1861
return ;
1848
1862
}
1849
1863
let anon_lts = vec ! [ "'_" ; n] . join ( ", " ) ;
1850
1864
let suggestion =
1851
1865
if incl_angl_brckt { format ! ( "<{}>" , anon_lts) } else { format ! ( "{}, " , anon_lts) } ;
1852
- diag. span_suggestion_verbose (
1853
- insertion_span. shrink_to_hi ( ) ,
1854
- format ! ( "indicate the anonymous lifetime{}" , pluralize!( n) ) ,
1866
+
1867
+ diag. subdiagnostic ( IndicateAnonymousLifetime {
1868
+ span : insertion_span. shrink_to_hi ( ) ,
1869
+ count : n,
1855
1870
suggestion,
1856
- Applicability :: MachineApplicable ,
1857
- ) ;
1871
+ } ) ;
1858
1872
}
1859
1873
1860
1874
#[ derive( Clone , Copy , PartialEq , Hash , Debug ) ]
0 commit comments