@@ -819,6 +819,43 @@ pub trait LintContext: Sized {
819819 "see issue #89122 <https://github.com/rust-lang/rust/issues/89122> for more information" ,
820820 ) ;
821821 } ,
822+ BuiltinLintDiagnostics :: SingleUseLifetime {
823+ param_span,
824+ use_span : Some ( ( use_span, elide) ) ,
825+ deletion_span,
826+ } => {
827+ debug ! ( ?param_span, ?use_span, ?deletion_span) ;
828+ db. span_label ( param_span, "this lifetime..." ) ;
829+ db. span_label ( use_span, "...is used only here" ) ;
830+ let msg = "elide the single-use lifetime" ;
831+ let ( use_span, replace_lt) = if elide {
832+ let use_span = sess. source_map ( ) . span_extend_while (
833+ use_span,
834+ char:: is_whitespace,
835+ ) . unwrap_or ( use_span) ;
836+ ( use_span, String :: new ( ) )
837+ } else {
838+ ( use_span, "'_" . to_owned ( ) )
839+ } ;
840+ db. multipart_suggestion (
841+ msg,
842+ vec ! [ ( deletion_span, String :: new( ) ) , ( use_span, replace_lt) ] ,
843+ Applicability :: MachineApplicable ,
844+ ) ;
845+ } ,
846+ BuiltinLintDiagnostics :: SingleUseLifetime {
847+ param_span : _,
848+ use_span : None ,
849+ deletion_span,
850+ } => {
851+ debug ! ( ?deletion_span) ;
852+ db. span_suggestion (
853+ deletion_span,
854+ "elide the unused lifetime" ,
855+ String :: new ( ) ,
856+ Applicability :: MachineApplicable ,
857+ ) ;
858+ } ,
822859 }
823860 // Rewrap `db`, and pass control to the user.
824861 decorate ( LintDiagnosticBuilder :: new ( db) ) ;
0 commit comments