diff options
| author | Oli Scherer <github333195615777966@oli-obk.de> | 2025-01-09 09:30:05 +0000 |
|---|---|---|
| committer | Oli Scherer <github333195615777966@oli-obk.de> | 2025-01-15 08:58:17 +0000 |
| commit | 767d4fe64e3644ffcd89b3265fdee6659d08786a (patch) | |
| tree | 0478066f154db1ac142653f1dd6f6a1cc3212bbc /compiler/rustc_trait_selection/src | |
| parent | 1952b87780758652477bcd8ae11acc850781e2b4 (diff) | |
| download | rust-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.rs | 6 |
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)) |
