about summary refs log tree commit diff
path: root/compiler/rustc_trait_selection/src
diff options
context:
space:
mode:
Diffstat (limited to 'compiler/rustc_trait_selection/src')
-rw-r--r--compiler/rustc_trait_selection/src/error_reporting/traits/fulfillment_errors.rs3
-rw-r--r--compiler/rustc_trait_selection/src/error_reporting/traits/on_unimplemented.rs12
2 files changed, 11 insertions, 4 deletions
diff --git a/compiler/rustc_trait_selection/src/error_reporting/traits/fulfillment_errors.rs b/compiler/rustc_trait_selection/src/error_reporting/traits/fulfillment_errors.rs
index 961719f263c..5021fd8bf83 100644
--- a/compiler/rustc_trait_selection/src/error_reporting/traits/fulfillment_errors.rs
+++ b/compiler/rustc_trait_selection/src/error_reporting/traits/fulfillment_errors.rs
@@ -462,6 +462,9 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> {
                             err.note(
                                 "`#[target_feature]` functions do not implement the `Fn` traits",
                             );
+                            err.note(
+                                "try casting the function to a `fn` pointer or wrapping it in a closure",
+                            );
                         }
 
                         self.try_to_add_help_message(
diff --git a/compiler/rustc_trait_selection/src/error_reporting/traits/on_unimplemented.rs b/compiler/rustc_trait_selection/src/error_reporting/traits/on_unimplemented.rs
index 2d932e36470..4e0b097db4c 100644
--- a/compiler/rustc_trait_selection/src/error_reporting/traits/on_unimplemented.rs
+++ b/compiler/rustc_trait_selection/src/error_reporting/traits/on_unimplemented.rs
@@ -13,7 +13,7 @@ use rustc_middle::ty::print::PrintTraitRefExt as _;
 use rustc_middle::ty::{self, GenericArgsRef, GenericParamDefKind, TyCtxt};
 use rustc_parse_format::{ParseMode, Parser, Piece, Position};
 use rustc_session::lint::builtin::UNKNOWN_OR_MALFORMED_DIAGNOSTIC_ATTRIBUTES;
-use rustc_span::{Span, Symbol, kw, sym};
+use rustc_span::{Ident, Span, Symbol, kw, sym};
 use tracing::{debug, info};
 use {rustc_attr_parsing as attr, rustc_hir as hir};
 
@@ -375,7 +375,7 @@ impl IgnoredDiagnosticOption {
 #[help]
 pub struct UnknownFormatParameterForOnUnimplementedAttr {
     argument_name: Symbol,
-    trait_name: Symbol,
+    trait_name: Ident,
 }
 
 #[derive(LintDiagnostic)]
@@ -792,7 +792,7 @@ impl<'tcx> OnUnimplementedFormatString {
             tcx.trait_id_of_impl(item_def_id)
                 .expect("expected `on_unimplemented` to correspond to a trait")
         };
-        let trait_name = tcx.item_name(trait_def_id);
+        let trait_name = tcx.item_ident(trait_def_id);
         let generics = tcx.generics_of(item_def_id);
         let s = self.symbol.as_str();
         let mut parser = Parser::new(s, None, None, false, ParseMode::Format);
@@ -821,7 +821,11 @@ impl<'tcx> OnUnimplementedFormatString {
                         Position::ArgumentNamed(s) => {
                             match Symbol::intern(s) {
                                 // `{ThisTraitsName}` is allowed
-                                s if s == trait_name && !self.is_diagnostic_namespace_variant => (),
+                                s if s == trait_name.name
+                                    && !self.is_diagnostic_namespace_variant =>
+                                {
+                                    ()
+                                }
                                 s if ALLOWED_FORMAT_SYMBOLS.contains(&s)
                                     && !self.is_diagnostic_namespace_variant =>
                                 {