@@ -6,7 +6,7 @@ use crate::astconv::{
66use crate :: errors:: AssocTypeBindingNotAllowed ;
77use crate :: structured_errors:: { GenericArgsInfo , StructuredDiagnostic , WrongNumberOfGenericArgs } ;
88use rustc_ast:: ast:: ParamKindOrd ;
9- use rustc_errors:: { struct_span_err, Applicability , Diagnostic , MultiSpan } ;
9+ use rustc_errors:: { struct_span_err, Applicability , Diagnostic } ;
1010use rustc_hir as hir;
1111use rustc_hir:: def:: { DefKind , Res } ;
1212use rustc_hir:: def_id:: DefId ;
@@ -15,7 +15,6 @@ use rustc_infer::infer::TyCtxtInferExt;
1515use rustc_middle:: ty:: {
1616 self , subst, subst:: SubstsRef , GenericParamDef , GenericParamDefKind , IsSuggestable , Ty , TyCtxt ,
1717} ;
18- use rustc_session:: lint:: builtin:: LATE_BOUND_LIFETIME_ARGUMENTS ;
1918use rustc_span:: { symbol:: kw, Span } ;
2019use smallvec:: SmallVec ;
2120
@@ -623,7 +622,6 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
623622 args : & hir:: GenericArgs < ' _ > ,
624623 position : GenericArgPosition ,
625624 ) -> ExplicitLateBound {
626- let param_counts = def. own_counts ( ) ;
627625 let infer_lifetimes = position != GenericArgPosition :: Type && !args. has_lifetime_params ( ) ;
628626
629627 if infer_lifetimes {
@@ -634,25 +632,20 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
634632 let msg = "cannot specify lifetime arguments explicitly \
635633 if late bound lifetime parameters are present";
636634 let note = "the late bound lifetime parameter is introduced here" ;
637- let span = args. args [ 0 ] . span ( ) ;
638-
639- if position == GenericArgPosition :: Value
640- && args. num_lifetime_params ( ) != param_counts. lifetimes
641- {
642- let mut err = tcx. sess . struct_span_err ( span, msg) ;
643- err. span_note ( span_late, note) ;
644- err. emit ( ) ;
645- } else {
646- let mut multispan = MultiSpan :: from_span ( span) ;
647- multispan. push_span_label ( span_late, note) ;
648- tcx. struct_span_lint_hir (
649- LATE_BOUND_LIFETIME_ARGUMENTS ,
650- args. args [ 0 ] . hir_id ( ) ,
651- multispan,
652- msg,
653- |lint| lint,
654- ) ;
655- }
635+ let help = format ! (
636+ "remove the explicit lifetime argument{}" ,
637+ rustc_errors:: pluralize!( args. num_lifetime_params( ) )
638+ ) ;
639+ let spans: Vec < _ > = args
640+ . args
641+ . iter ( )
642+ . filter_map ( |arg| match arg {
643+ hir:: GenericArg :: Lifetime ( l) => Some ( l. span ) ,
644+ _ => None ,
645+ } )
646+ . collect ( ) ;
647+
648+ tcx. sess . struct_span_err ( spans, msg) . span_note ( span_late, note) . help ( help) . emit ( ) ;
656649
657650 ExplicitLateBound :: Yes
658651 } else {
0 commit comments