@@ -3009,10 +3009,10 @@ impl<'tcx> InferCtxtPrivExt<'tcx> for TypeErrCtxt<'_, 'tcx> {
30093009 // Try to report a help message
30103010 if is_fn_trait
30113011 && 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+ )
30163016 {
30173017 self . add_help_message_for_fn_trait ( trait_ref, err, implemented_kind, params) ;
30183018 } else if !trait_ref. has_non_region_infer ( )
@@ -3031,6 +3031,15 @@ impl<'tcx> InferCtxtPrivExt<'tcx> for TypeErrCtxt<'_, 'tcx> {
30313031 None ,
30323032 obligation. cause . body_id ,
30333033 ) ;
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+ ) ;
30343043 } else if !suggested && !unsatisfied_const {
30353044 // Can't show anything else useful, try to find similar impls.
30363045 let impl_candidates = self . find_similar_impl_candidates ( * trait_predicate) ;
@@ -3041,7 +3050,12 @@ impl<'tcx> InferCtxtPrivExt<'tcx> for TypeErrCtxt<'_, 'tcx> {
30413050 err,
30423051 true ,
30433052 ) {
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+ ) ;
30453059 }
30463060
30473061 self . suggest_convert_to_slice (
0 commit comments