@@ -3009,10 +3009,10 @@ impl<'tcx> InferCtxtPrivExt<'tcx> for TypeErrCtxt<'_, 'tcx> {
3009
3009
// Try to report a help message
3010
3010
if is_fn_trait
3011
3011
&& let Ok ( ( implemented_kind, params) ) = self . type_implements_fn_trait (
3012
- obligation. param_env ,
3013
- trait_ref. self_ty ( ) ,
3014
- trait_predicate. skip_binder ( ) . polarity ,
3015
- )
3012
+ obligation. param_env ,
3013
+ trait_ref. self_ty ( ) ,
3014
+ trait_predicate. skip_binder ( ) . polarity ,
3015
+ )
3016
3016
{
3017
3017
self . add_help_message_for_fn_trait ( trait_ref, err, implemented_kind, params) ;
3018
3018
} else if !trait_ref. has_non_region_infer ( )
@@ -3031,6 +3031,15 @@ impl<'tcx> InferCtxtPrivExt<'tcx> for TypeErrCtxt<'_, 'tcx> {
3031
3031
None ,
3032
3032
obligation. cause . body_id ,
3033
3033
) ;
3034
+ } else if trait_ref. def_id ( ) . is_local ( )
3035
+ && self . tcx . trait_impls_of ( trait_ref. def_id ( ) ) . is_empty ( )
3036
+ && !self . tcx . trait_is_auto ( trait_ref. def_id ( ) )
3037
+ && !self . tcx . trait_is_alias ( trait_ref. def_id ( ) )
3038
+ {
3039
+ err. span_help (
3040
+ self . tcx . def_span ( trait_ref. def_id ( ) ) ,
3041
+ crate :: fluent_generated:: trait_selection_trait_has_no_impls,
3042
+ ) ;
3034
3043
} else if !suggested && !unsatisfied_const {
3035
3044
// Can't show anything else useful, try to find similar impls.
3036
3045
let impl_candidates = self . find_similar_impl_candidates ( * trait_predicate) ;
@@ -3041,7 +3050,12 @@ impl<'tcx> InferCtxtPrivExt<'tcx> for TypeErrCtxt<'_, 'tcx> {
3041
3050
err,
3042
3051
true ,
3043
3052
) {
3044
- self . report_similar_impl_candidates_for_root_obligation ( & obligation, * trait_predicate, body_def_id, err) ;
3053
+ self . report_similar_impl_candidates_for_root_obligation (
3054
+ & obligation,
3055
+ * trait_predicate,
3056
+ body_def_id,
3057
+ err,
3058
+ ) ;
3045
3059
}
3046
3060
3047
3061
self . suggest_convert_to_slice (
0 commit comments