@@ -603,7 +603,6 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> {
603603 let explanation = get_explanation_based_on_obligation (
604604 self . tcx ,
605605 & obligation,
606- leaf_trait_ref,
607606 & leaf_trait_predicate,
608607 pre_message,
609608 ) ;
@@ -755,7 +754,6 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> {
755754
756755 self . try_to_add_help_message (
757756 & obligation,
758- leaf_trait_ref,
759757 & leaf_trait_predicate,
760758 & mut err,
761759 span,
@@ -3207,7 +3205,6 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> {
32073205 fn try_to_add_help_message (
32083206 & self ,
32093207 obligation : & PredicateObligation < ' tcx > ,
3210- trait_ref : ty:: PolyTraitRef < ' tcx > ,
32113208 trait_predicate : & ty:: PolyTraitPredicate < ' tcx > ,
32123209 err : & mut Diag < ' _ > ,
32133210 span : Span ,
@@ -3225,15 +3222,21 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> {
32253222 } ;
32263223
32273224 // Try to report a help message
3225+ let trait_def_id = trait_predicate. def_id ( ) ;
32283226 if is_fn_trait
32293227 && let Ok ( ( implemented_kind, params) ) = self . type_implements_fn_trait (
32303228 obligation. param_env ,
3231- trait_ref . self_ty ( ) ,
3229+ trait_predicate . self_ty ( ) ,
32323230 trait_predicate. skip_binder ( ) . polarity ,
32333231 )
32343232 {
3235- self . add_help_message_for_fn_trait ( trait_ref, err, implemented_kind, params) ;
3236- } else if !trait_ref. has_non_region_infer ( )
3233+ self . add_help_message_for_fn_trait (
3234+ trait_predicate. to_poly_trait_ref ( ) ,
3235+ err,
3236+ implemented_kind,
3237+ params,
3238+ ) ;
3239+ } else if !trait_predicate. has_non_region_infer ( )
32373240 && self . predicate_can_apply ( obligation. param_env , * trait_predicate)
32383241 {
32393242 // If a where-clause may be useful, remind the
@@ -3249,21 +3252,21 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> {
32493252 None ,
32503253 obligation. cause . body_id ,
32513254 ) ;
3252- } else if trait_ref . def_id ( ) . is_local ( )
3253- && self . tcx . trait_impls_of ( trait_ref . def_id ( ) ) . is_empty ( )
3254- && !self . tcx . trait_is_auto ( trait_ref . def_id ( ) )
3255- && !self . tcx . trait_is_alias ( trait_ref . def_id ( ) )
3255+ } else if trait_def_id . is_local ( )
3256+ && self . tcx . trait_impls_of ( trait_def_id ) . is_empty ( )
3257+ && !self . tcx . trait_is_auto ( trait_def_id )
3258+ && !self . tcx . trait_is_alias ( trait_def_id )
32563259 {
32573260 err. span_help (
3258- self . tcx . def_span ( trait_ref . def_id ( ) ) ,
3261+ self . tcx . def_span ( trait_def_id ) ,
32593262 crate :: fluent_generated:: trait_selection_trait_has_no_impls,
32603263 ) ;
32613264 } else if !suggested && !unsatisfied_const {
32623265 // Can't show anything else useful, try to find similar impls.
32633266 let impl_candidates = self . find_similar_impl_candidates ( * trait_predicate) ;
32643267 if !self . report_similar_impl_candidates (
32653268 & impl_candidates,
3266- trait_ref ,
3269+ trait_predicate . to_poly_trait_ref ( ) ,
32673270 body_def_id,
32683271 err,
32693272 true ,
@@ -3280,7 +3283,7 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> {
32803283 self . suggest_convert_to_slice (
32813284 err,
32823285 obligation,
3283- trait_ref ,
3286+ trait_predicate . to_poly_trait_ref ( ) ,
32843287 impl_candidates. as_slice ( ) ,
32853288 span,
32863289 ) ;
0 commit comments