@@ -214,6 +214,9 @@ fn lint_map_unit_fn(
214214 } ;
215215 let fn_arg = & map_args. 1 [ 0 ] ;
216216
217+ #[ expect( clippy:: items_after_statements, reason = "the const is only used below" ) ]
218+ const SUGG_MSG : & str = "use `if let` instead" ;
219+
217220 if is_unit_function ( cx, fn_arg) {
218221 let mut applicability = Applicability :: MachineApplicable ;
219222 let msg = suggestion_msg ( "function" , map_type) ;
@@ -226,7 +229,7 @@ fn lint_map_unit_fn(
226229 ) ;
227230
228231 span_lint_and_then ( cx, lint, expr. span , msg, |diag| {
229- diag. span_suggestion ( stmt. span , "try" , suggestion, applicability) ;
232+ diag. span_suggestion_verbose ( stmt. span , SUGG_MSG , suggestion, applicability) ;
230233 } ) ;
231234 } else if let Some ( ( binding, closure_expr) ) = unit_closure ( cx, fn_arg) {
232235 let msg = suggestion_msg ( "closure" , map_type) ;
@@ -242,15 +245,15 @@ fn lint_map_unit_fn(
242245 snippet_with_applicability( cx, var_arg. span, "_" , & mut applicability) ,
243246 snippet_with_context( cx, reduced_expr_span, var_arg. span. ctxt( ) , "_" , & mut applicability) . 0 ,
244247 ) ;
245- diag. span_suggestion ( stmt. span , "try" , suggestion, applicability) ;
248+ diag. span_suggestion_verbose ( stmt. span , SUGG_MSG , suggestion, applicability) ;
246249 } else {
247250 let suggestion = format ! (
248251 "if let {0}({1}) = {2} {{ ... }}" ,
249252 variant,
250253 snippet( cx, binding. pat. span, "_" ) ,
251254 snippet( cx, var_arg. span, "_" ) ,
252255 ) ;
253- diag. span_suggestion ( stmt. span , "try" , suggestion, Applicability :: HasPlaceholders ) ;
256+ diag. span_suggestion_verbose ( stmt. span , SUGG_MSG , suggestion, Applicability :: HasPlaceholders ) ;
254257 }
255258 } ) ;
256259 }
0 commit comments