@@ -650,41 +650,14 @@ impl<'tcx> TypeErrCtxtExt<'tcx> for TypeErrCtxt<'_, 'tcx> {
650650 ) )
651651 ) ;
652652
653- if is_try_conversion {
654- let none_error = self
655- . tcx
656- . get_diagnostic_item ( sym:: none_error)
657- . map ( |def_id| tcx. type_of ( def_id) ) ;
658- let should_convert_option_to_result =
659- Some ( trait_ref. skip_binder ( ) . substs . type_at ( 1 ) ) == none_error;
660- let should_convert_result_to_option =
661- Some ( trait_ref. self_ty ( ) . skip_binder ( ) ) == none_error;
662- if should_convert_option_to_result {
663- err. span_suggestion_verbose (
664- span. shrink_to_lo ( ) ,
665- "consider converting the `Option<T>` into a `Result<T, _>` \
666- using `Option::ok_or` or `Option::ok_or_else`",
667- ".ok_or_else(|| /* error value */)" ,
668- Applicability :: HasPlaceholders ,
669- ) ;
670- } else if should_convert_result_to_option {
671- err. span_suggestion_verbose (
672- span. shrink_to_lo ( ) ,
673- "consider converting the `Result<T, _>` into an `Option<T>` \
674- using `Result::ok`",
675- ".ok()" ,
676- Applicability :: MachineApplicable ,
677- ) ;
678- }
679- if let Some ( ret_span) = self . return_type_span ( & obligation) {
680- err. span_label (
681- ret_span,
682- & format ! (
683- "expected `{}` because of this" ,
684- trait_ref. skip_binder( ) . self_ty( )
685- ) ,
686- ) ;
687- }
653+ if is_try_conversion && let Some ( ret_span) = self . return_type_span ( & obligation) {
654+ err. span_label (
655+ ret_span,
656+ & format ! (
657+ "expected `{}` because of this" ,
658+ trait_ref. skip_binder( ) . self_ty( )
659+ ) ,
660+ ) ;
688661 }
689662
690663 if Some ( trait_ref. def_id ( ) ) == tcx. lang_items ( ) . tuple_trait ( ) {
0 commit comments