1
Fork 0

Avoid notes that only make sense for unsafe functions

This commit is contained in:
Oli Scherer 2025-01-09 09:30:05 +00:00
parent 1952b87780
commit 767d4fe64e
4 changed files with 9 additions and 17 deletions

View file

@ -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))