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