@@ -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
) ;
@@ -755,7 +754,6 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> {
755
754
756
755
self . try_to_add_help_message (
757
756
& obligation,
758
- leaf_trait_ref,
759
757
& leaf_trait_predicate,
760
758
& mut err,
761
759
span,
@@ -3207,7 +3205,6 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> {
3207
3205
fn try_to_add_help_message (
3208
3206
& self ,
3209
3207
obligation : & PredicateObligation < ' tcx > ,
3210
- trait_ref : ty:: PolyTraitRef < ' tcx > ,
3211
3208
trait_predicate : & ty:: PolyTraitPredicate < ' tcx > ,
3212
3209
err : & mut Diag < ' _ > ,
3213
3210
span : Span ,
@@ -3225,15 +3222,21 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> {
3225
3222
} ;
3226
3223
3227
3224
// Try to report a help message
3225
+ let trait_def_id = trait_predicate. def_id ( ) ;
3228
3226
if is_fn_trait
3229
3227
&& let Ok ( ( implemented_kind, params) ) = self . type_implements_fn_trait (
3230
3228
obligation. param_env ,
3231
- trait_ref . self_ty ( ) ,
3229
+ trait_predicate . self_ty ( ) ,
3232
3230
trait_predicate. skip_binder ( ) . polarity ,
3233
3231
)
3234
3232
{
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 ( )
3237
3240
&& self . predicate_can_apply ( obligation. param_env , * trait_predicate)
3238
3241
{
3239
3242
// If a where-clause may be useful, remind the
@@ -3249,21 +3252,21 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> {
3249
3252
None ,
3250
3253
obligation. cause . body_id ,
3251
3254
) ;
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 )
3256
3259
{
3257
3260
err. span_help (
3258
- self . tcx . def_span ( trait_ref . def_id ( ) ) ,
3261
+ self . tcx . def_span ( trait_def_id ) ,
3259
3262
crate :: fluent_generated:: trait_selection_trait_has_no_impls,
3260
3263
) ;
3261
3264
} else if !suggested && !unsatisfied_const {
3262
3265
// Can't show anything else useful, try to find similar impls.
3263
3266
let impl_candidates = self . find_similar_impl_candidates ( * trait_predicate) ;
3264
3267
if !self . report_similar_impl_candidates (
3265
3268
& impl_candidates,
3266
- trait_ref ,
3269
+ trait_predicate . to_poly_trait_ref ( ) ,
3267
3270
body_def_id,
3268
3271
err,
3269
3272
true ,
@@ -3280,7 +3283,7 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> {
3280
3283
self . suggest_convert_to_slice (
3281
3284
err,
3282
3285
obligation,
3283
- trait_ref ,
3286
+ trait_predicate . to_poly_trait_ref ( ) ,
3284
3287
impl_candidates. as_slice ( ) ,
3285
3288
span,
3286
3289
) ;
0 commit comments