@@ -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 ;
@@ -375,13 +377,16 @@ pub struct ExplicitBug;
375
377
/// rather than a failed assertion, etc.
376
378
pub struct DelayedBugPanic ;
377
379
380
+ use crate :: diagnostic_impls:: { DelayedAtWithNewline , DelayedAtWithoutNewline } ;
378
381
pub use diagnostic:: {
379
382
AddToDiagnostic , DecorateLint , Diagnostic , DiagnosticArg , DiagnosticArgValue , DiagnosticId ,
380
383
DiagnosticStyledString , IntoDiagnosticArg , SubDiagnostic ,
381
384
} ;
382
385
pub use diagnostic_builder:: { DiagnosticBuilder , EmissionGuarantee , Noted } ;
383
386
pub use diagnostic_impls:: {
384
- DiagnosticArgFromDisplay , DiagnosticSymbolList , LabelKind , SingleLabelManySpans ,
387
+ DiagnosticArgFromDisplay , DiagnosticSymbolList , ExpectedLifetimeParameter ,
388
+ IndicateAnonymousLifetime , InvalidFlushedDelayedDiagnosticLevel , LabelKind ,
389
+ SingleLabelManySpans ,
385
390
} ;
386
391
use std:: backtrace:: { Backtrace , BacktraceStatus } ;
387
392
@@ -1670,11 +1675,10 @@ impl HandlerInner {
1670
1675
if bug. level != Level :: DelayedBug {
1671
1676
// NOTE(eddyb) not panicking here because we're already producing
1672
1677
// 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
+ } ) ;
1678
1682
}
1679
1683
bug. level = Level :: Bug ;
1680
1684
@@ -1741,12 +1745,22 @@ impl DelayedDiagnostic {
1741
1745
fn decorate ( mut self ) -> Diagnostic {
1742
1746
match self . note . status ( ) {
1743
1747
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
+ } ) ;
1745
1754
}
1746
1755
// Avoid the needless newline when no backtrace has been captured,
1747
1756
// the display impl should just be a single line.
1748
1757
_ => {
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
+ } ) ;
1750
1764
}
1751
1765
}
1752
1766
@@ -1838,20 +1852,20 @@ pub fn add_elided_lifetime_in_path_suggestion(
1838
1852
incl_angl_brckt : bool ,
1839
1853
insertion_span : Span ,
1840
1854
) {
1841
- diag. span_label ( path_span , format ! ( "expected lifetime parameter{}" , pluralize! ( n ) ) ) ;
1855
+ diag. subdiagnostic ( ExpectedLifetimeParameter { span : path_span , count : n } ) ;
1842
1856
if !source_map. is_span_accessible ( insertion_span) {
1843
1857
// Do not try to suggest anything if generated by a proc-macro.
1844
1858
return ;
1845
1859
}
1846
1860
let anon_lts = vec ! [ "'_" ; n] . join ( ", " ) ;
1847
1861
let suggestion =
1848
1862
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,
1852
1867
suggestion,
1853
- Applicability :: MachineApplicable ,
1854
- ) ;
1868
+ } ) ;
1855
1869
}
1856
1870
1857
1871
#[ derive( Clone , Copy , PartialEq , Hash , Debug ) ]
0 commit comments