@@ -601,7 +601,6 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> {
601601 let explanation = get_explanation_based_on_obligation (
602602 self . tcx ,
603603 & obligation,
604- main_trait_ref,
605604 & main_trait_predicate,
606605 pre_message,
607606 ) ;
@@ -753,7 +752,6 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> {
753752
754753 self . try_to_add_help_message (
755754 & obligation,
756- main_trait_ref,
757755 & main_trait_predicate,
758756 & mut err,
759757 span,
@@ -3205,7 +3203,6 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> {
32053203 fn try_to_add_help_message (
32063204 & self ,
32073205 obligation : & PredicateObligation < ' tcx > ,
3208- trait_ref : ty:: PolyTraitRef < ' tcx > ,
32093206 trait_predicate : & ty:: PolyTraitPredicate < ' tcx > ,
32103207 err : & mut Diag < ' _ > ,
32113208 span : Span ,
@@ -3223,15 +3220,21 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> {
32233220 } ;
32243221
32253222 // Try to report a help message
3223+ let trait_def_id = trait_predicate. def_id ( ) ;
32263224 if is_fn_trait
32273225 && let Ok ( ( implemented_kind, params) ) = self . type_implements_fn_trait (
32283226 obligation. param_env ,
3229- trait_ref . self_ty ( ) ,
3227+ trait_predicate . self_ty ( ) ,
32303228 trait_predicate. skip_binder ( ) . polarity ,
32313229 )
32323230 {
3233- self . add_help_message_for_fn_trait ( trait_ref, err, implemented_kind, params) ;
3234- } else if !trait_ref. has_non_region_infer ( )
3231+ self . add_help_message_for_fn_trait (
3232+ trait_predicate. to_poly_trait_ref ( ) ,
3233+ err,
3234+ implemented_kind,
3235+ params,
3236+ ) ;
3237+ } else if !trait_predicate. has_non_region_infer ( )
32353238 && self . predicate_can_apply ( obligation. param_env , * trait_predicate)
32363239 {
32373240 // If a where-clause may be useful, remind the
@@ -3247,21 +3250,21 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> {
32473250 None ,
32483251 obligation. cause . body_id ,
32493252 ) ;
3250- } else if trait_ref . def_id ( ) . is_local ( )
3251- && self . tcx . trait_impls_of ( trait_ref . def_id ( ) ) . is_empty ( )
3252- && !self . tcx . trait_is_auto ( trait_ref . def_id ( ) )
3253- && !self . tcx . trait_is_alias ( trait_ref . def_id ( ) )
3253+ } else if trait_def_id . is_local ( )
3254+ && self . tcx . trait_impls_of ( trait_def_id ) . is_empty ( )
3255+ && !self . tcx . trait_is_auto ( trait_def_id )
3256+ && !self . tcx . trait_is_alias ( trait_def_id )
32543257 {
32553258 err. span_help (
3256- self . tcx . def_span ( trait_ref . def_id ( ) ) ,
3259+ self . tcx . def_span ( trait_def_id ) ,
32573260 crate :: fluent_generated:: trait_selection_trait_has_no_impls,
32583261 ) ;
32593262 } else if !suggested && !unsatisfied_const {
32603263 // Can't show anything else useful, try to find similar impls.
32613264 let impl_candidates = self . find_similar_impl_candidates ( * trait_predicate) ;
32623265 if !self . report_similar_impl_candidates (
32633266 & impl_candidates,
3264- trait_ref ,
3267+ trait_predicate . to_poly_trait_ref ( ) ,
32653268 body_def_id,
32663269 err,
32673270 true ,
@@ -3278,7 +3281,7 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> {
32783281 self . suggest_convert_to_slice (
32793282 err,
32803283 obligation,
3281- trait_ref ,
3284+ trait_predicate . to_poly_trait_ref ( ) ,
32823285 impl_candidates. as_slice ( ) ,
32833286 span,
32843287 ) ;
0 commit comments