@@ -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 ) ;
@@ -759,7 +758,6 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> {
759758
760759 self . try_to_add_help_message (
761760 & obligation,
762- leaf_trait_ref,
763761 & leaf_trait_predicate,
764762 & mut err,
765763 span,
@@ -3215,7 +3213,6 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> {
32153213 fn try_to_add_help_message (
32163214 & self ,
32173215 obligation : & PredicateObligation < ' tcx > ,
3218- trait_ref : ty:: PolyTraitRef < ' tcx > ,
32193216 trait_predicate : & ty:: PolyTraitPredicate < ' tcx > ,
32203217 err : & mut Diag < ' _ > ,
32213218 span : Span ,
@@ -3233,15 +3230,21 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> {
32333230 } ;
32343231
32353232 // Try to report a help message
3233+ let trait_def_id = trait_predicate. def_id ( ) ;
32363234 if is_fn_trait
32373235 && let Ok ( ( implemented_kind, params) ) = self . type_implements_fn_trait (
32383236 obligation. param_env ,
3239- trait_ref . self_ty ( ) ,
3237+ trait_predicate . self_ty ( ) ,
32403238 trait_predicate. skip_binder ( ) . polarity ,
32413239 )
32423240 {
3243- self . add_help_message_for_fn_trait ( trait_ref, err, implemented_kind, params) ;
3244- } else if !trait_ref. has_non_region_infer ( )
3241+ self . add_help_message_for_fn_trait (
3242+ trait_predicate. to_poly_trait_ref ( ) ,
3243+ err,
3244+ implemented_kind,
3245+ params,
3246+ ) ;
3247+ } else if !trait_predicate. has_non_region_infer ( )
32453248 && self . predicate_can_apply ( obligation. param_env , * trait_predicate)
32463249 {
32473250 // If a where-clause may be useful, remind the
@@ -3257,21 +3260,21 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> {
32573260 None ,
32583261 obligation. cause . body_id ,
32593262 ) ;
3260- } else if trait_ref . def_id ( ) . is_local ( )
3261- && self . tcx . trait_impls_of ( trait_ref . def_id ( ) ) . is_empty ( )
3262- && !self . tcx . trait_is_auto ( trait_ref . def_id ( ) )
3263- && !self . tcx . trait_is_alias ( trait_ref . def_id ( ) )
3263+ } else if trait_def_id . is_local ( )
3264+ && self . tcx . trait_impls_of ( trait_def_id ) . is_empty ( )
3265+ && !self . tcx . trait_is_auto ( trait_def_id )
3266+ && !self . tcx . trait_is_alias ( trait_def_id )
32643267 {
32653268 err. span_help (
3266- self . tcx . def_span ( trait_ref . def_id ( ) ) ,
3269+ self . tcx . def_span ( trait_def_id ) ,
32673270 crate :: fluent_generated:: trait_selection_trait_has_no_impls,
32683271 ) ;
32693272 } else if !suggested && !unsatisfied_const {
32703273 // Can't show anything else useful, try to find similar impls.
32713274 let impl_candidates = self . find_similar_impl_candidates ( * trait_predicate) ;
32723275 if !self . report_similar_impl_candidates (
32733276 & impl_candidates,
3274- trait_ref ,
3277+ trait_predicate . to_poly_trait_ref ( ) ,
32753278 body_def_id,
32763279 err,
32773280 true ,
@@ -3288,7 +3291,7 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> {
32883291 self . suggest_convert_to_slice (
32893292 err,
32903293 obligation,
3291- trait_ref ,
3294+ trait_predicate . to_poly_trait_ref ( ) ,
32923295 impl_candidates. as_slice ( ) ,
32933296 span,
32943297 ) ;
0 commit comments