@@ -603,7 +603,6 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> {
603
603
let explanation = get_explanation_based_on_obligation (
604
604
self . tcx ,
605
605
& obligation,
606
- leaf_trait_ref,
607
606
& leaf_trait_predicate,
608
607
pre_message,
609
608
) ;
@@ -759,7 +758,6 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> {
759
758
760
759
self . try_to_add_help_message (
761
760
& obligation,
762
- leaf_trait_ref,
763
761
& leaf_trait_predicate,
764
762
& mut err,
765
763
span,
@@ -3215,7 +3213,6 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> {
3215
3213
fn try_to_add_help_message (
3216
3214
& self ,
3217
3215
obligation : & PredicateObligation < ' tcx > ,
3218
- trait_ref : ty:: PolyTraitRef < ' tcx > ,
3219
3216
trait_predicate : & ty:: PolyTraitPredicate < ' tcx > ,
3220
3217
err : & mut Diag < ' _ > ,
3221
3218
span : Span ,
@@ -3233,15 +3230,21 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> {
3233
3230
} ;
3234
3231
3235
3232
// Try to report a help message
3233
+ let trait_def_id = trait_predicate. def_id ( ) ;
3236
3234
if is_fn_trait
3237
3235
&& let Ok ( ( implemented_kind, params) ) = self . type_implements_fn_trait (
3238
3236
obligation. param_env ,
3239
- trait_ref . self_ty ( ) ,
3237
+ trait_predicate . self_ty ( ) ,
3240
3238
trait_predicate. skip_binder ( ) . polarity ,
3241
3239
)
3242
3240
{
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 ( )
3245
3248
&& self . predicate_can_apply ( obligation. param_env , * trait_predicate)
3246
3249
{
3247
3250
// If a where-clause may be useful, remind the
@@ -3257,21 +3260,21 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> {
3257
3260
None ,
3258
3261
obligation. cause . body_id ,
3259
3262
) ;
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 )
3264
3267
{
3265
3268
err. span_help (
3266
- self . tcx . def_span ( trait_ref . def_id ( ) ) ,
3269
+ self . tcx . def_span ( trait_def_id ) ,
3267
3270
crate :: fluent_generated:: trait_selection_trait_has_no_impls,
3268
3271
) ;
3269
3272
} else if !suggested && !unsatisfied_const {
3270
3273
// Can't show anything else useful, try to find similar impls.
3271
3274
let impl_candidates = self . find_similar_impl_candidates ( * trait_predicate) ;
3272
3275
if !self . report_similar_impl_candidates (
3273
3276
& impl_candidates,
3274
- trait_ref ,
3277
+ trait_predicate . to_poly_trait_ref ( ) ,
3275
3278
body_def_id,
3276
3279
err,
3277
3280
true ,
@@ -3288,7 +3291,7 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> {
3288
3291
self . suggest_convert_to_slice (
3289
3292
err,
3290
3293
obligation,
3291
- trait_ref ,
3294
+ trait_predicate . to_poly_trait_ref ( ) ,
3292
3295
impl_candidates. as_slice ( ) ,
3293
3296
span,
3294
3297
) ;
0 commit comments