@@ -1451,9 +1451,13 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
14511451 let ty:: Adt ( callee_adt, _) = callee_ty. peel_refs ( ) . kind ( ) else {
14521452 return ;
14531453 } ;
1454- if !self . tcx . is_diagnostic_item ( sym:: Option , callee_adt. did ( ) ) {
1454+ let adt_name = if self . tcx . is_diagnostic_item ( sym:: Option , callee_adt. did ( ) ) {
1455+ "Option"
1456+ } else if self . tcx . is_diagnostic_item ( sym:: Result , callee_adt. did ( ) ) {
1457+ "Result"
1458+ } else {
14551459 return ;
1456- }
1460+ } ;
14571461
14581462 if call_ident. map_or ( true , |ident| ident. name != sym:: unwrap_or) {
14591463 return ;
@@ -1484,14 +1488,9 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
14841488 Ok ( snip) => ( snip, Applicability :: MachineApplicable ) ,
14851489 Err ( _) => ( "/* _ */" . to_owned ( ) , Applicability :: MaybeIncorrect ) ,
14861490 } ;
1487- let sugg = & format ! ( "map_or({provided_snip}, |v| v)" ) ;
1488- err. span_suggestion_verbose (
1489- error_span,
1490- "use `Option::map_or` to deref inner value of `Option`" ,
1491- sugg,
1492- applicability,
1493- ) ;
1494- return ;
1491+ let sugg = format ! ( "map_or({provided_snip}, |v| v)" ) ;
1492+ let msg = format ! ( "use `{adt_name}::map_or` to deref inner value of `{adt_name}`" ) ;
1493+ err. span_suggestion_verbose ( error_span, msg, sugg, applicability) ;
14951494 }
14961495
14971496 /// Suggest wrapping the block in square brackets instead of curly braces
0 commit comments