about summary refs log tree commit diff
path: root/compiler/rustc_trait_selection/src
diff options
context:
space:
mode:
authorOli Scherer <github333195615777966@oli-obk.de>2025-01-09 09:30:05 +0000
committerOli Scherer <github333195615777966@oli-obk.de>2025-01-15 08:58:17 +0000
commit767d4fe64e3644ffcd89b3265fdee6659d08786a (patch)
tree0478066f154db1ac142653f1dd6f6a1cc3212bbc /compiler/rustc_trait_selection/src
parent1952b87780758652477bcd8ae11acc850781e2b4 (diff)
downloadrust-767d4fe64e3644ffcd89b3265fdee6659d08786a.tar.gz
rust-767d4fe64e3644ffcd89b3265fdee6659d08786a.zip
Avoid notes that only make sense for unsafe functions
Diffstat (limited to 'compiler/rustc_trait_selection/src')
-rw-r--r--compiler/rustc_trait_selection/src/error_reporting/infer/note_and_explain.rs6
1 files changed, 4 insertions, 2 deletions
diff --git a/compiler/rustc_trait_selection/src/error_reporting/infer/note_and_explain.rs b/compiler/rustc_trait_selection/src/error_reporting/infer/note_and_explain.rs
index 2cfccc57c97..1dd09fe7aaf 100644
--- a/compiler/rustc_trait_selection/src/error_reporting/infer/note_and_explain.rs
+++ b/compiler/rustc_trait_selection/src/error_reporting/infer/note_and_explain.rs
@@ -461,9 +461,11 @@ impl<T> Trait<T> for X {
                     (ty::FnPtr(_, hdr), ty::FnDef(def_id, _))
                     | (ty::FnDef(def_id, _), ty::FnPtr(_, hdr)) => {
                         if tcx.fn_sig(def_id).skip_binder().safety() < hdr.safety {
-                            diag.note(
+                            if !tcx.codegen_fn_attrs(def_id).safe_target_features {
+                                diag.note(
                                 "unsafe functions cannot be coerced into safe function pointers",
-                            );
+                                );
+                            }
                         }
                     }
                     (ty::Adt(_, _), ty::Adt(def, args))