@@ -41,8 +41,8 @@ pub use diagnostic::{
41
41
SubdiagMessageOp , Subdiagnostic ,
42
42
} ;
43
43
pub use diagnostic_impls:: {
44
- DiagArgFromDisplay , DiagSymbolList , ExpectedLifetimeParameter , IndicateAnonymousLifetime ,
45
- SingleLabelManySpans ,
44
+ DiagArgFromDisplay , DiagSymbolList , ElidedLifetimeInPathSubdiag , ExpectedLifetimeParameter ,
45
+ IndicateAnonymousLifetime , SingleLabelManySpans ,
46
46
} ;
47
47
pub use emitter:: ColorConfig ;
48
48
pub use rustc_error_messages:: {
@@ -1912,27 +1912,24 @@ impl Level {
1912
1912
}
1913
1913
1914
1914
// 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 (
1916
1916
source_map : & SourceMap ,
1917
- diag : & mut Diag < ' _ , G > ,
1918
1917
n : usize ,
1919
1918
path_span : Span ,
1920
1919
incl_angl_brckt : bool ,
1921
1920
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 }
1936
1933
}
1937
1934
1938
1935
pub fn report_ambiguity_error < ' a , G : EmissionGuarantee > (
0 commit comments