@@ -41,8 +41,8 @@ pub use diagnostic::{
4141 SubdiagMessageOp , Subdiagnostic ,
4242} ;
4343pub use diagnostic_impls:: {
44- DiagArgFromDisplay , DiagSymbolList , ExpectedLifetimeParameter , IndicateAnonymousLifetime ,
45- SingleLabelManySpans ,
44+ DiagArgFromDisplay , DiagSymbolList , ElidedLifetimeInPathSubdiag , ExpectedLifetimeParameter ,
45+ IndicateAnonymousLifetime , SingleLabelManySpans ,
4646} ;
4747pub use emitter:: ColorConfig ;
4848pub use rustc_error_messages:: {
@@ -1912,27 +1912,24 @@ impl Level {
19121912}
19131913
19141914// FIXME(eddyb) this doesn't belong here AFAICT, should be moved to callsite.
1915- pub fn add_elided_lifetime_in_path_suggestion < G : EmissionGuarantee > (
1915+ pub fn elided_lifetime_in_path_suggestion (
19161916 source_map : & SourceMap ,
1917- diag : & mut Diag < ' _ , G > ,
19181917 n : usize ,
19191918 path_span : Span ,
19201919 incl_angl_brckt : bool ,
19211920 insertion_span : Span ,
1922- ) {
1923- diag. subdiagnostic ( diag. dcx , ExpectedLifetimeParameter { span : path_span, count : n } ) ;
1924- if !source_map. is_span_accessible ( insertion_span) {
1925- // Do not try to suggest anything if generated by a proc-macro.
1926- return ;
1927- }
1928- let anon_lts = vec ! [ "'_" ; n] . join ( ", " ) ;
1929- let suggestion =
1930- if incl_angl_brckt { format ! ( "<{anon_lts}>" ) } else { format ! ( "{anon_lts}, " ) } ;
1931-
1932- diag. subdiagnostic (
1933- diag. dcx ,
1934- IndicateAnonymousLifetime { span : insertion_span. shrink_to_hi ( ) , count : n, suggestion } ,
1935- ) ;
1921+ ) -> ElidedLifetimeInPathSubdiag {
1922+ let expected = ExpectedLifetimeParameter { span : path_span, count : n } ;
1923+ // Do not try to suggest anything if generated by a proc-macro.
1924+ let indicate = source_map. is_span_accessible ( insertion_span) . then ( || {
1925+ let anon_lts = vec ! [ "'_" ; n] . join ( ", " ) ;
1926+ let suggestion =
1927+ if incl_angl_brckt { format ! ( "<{anon_lts}>" ) } else { format ! ( "{anon_lts}, " ) } ;
1928+
1929+ IndicateAnonymousLifetime { span : insertion_span. shrink_to_hi ( ) , count : n, suggestion }
1930+ } ) ;
1931+
1932+ ElidedLifetimeInPathSubdiag { expected, indicate }
19361933}
19371934
19381935pub fn report_ambiguity_error < ' a , G : EmissionGuarantee > (
0 commit comments