Test and note unsafe ctor to fn ptr coercion
Also remove a note that I don't consider to be very useful in context.
This commit is contained in:
parent
0100a94231
commit
bf66723c0e
18 changed files with 29 additions and 22 deletions
|
@ -266,12 +266,10 @@ impl<T> Trait<T> for X {
|
|||
}
|
||||
}
|
||||
}
|
||||
(ty::FnPtr(_), ty::FnDef(def, _))
|
||||
if let hir::def::DefKind::Fn = tcx.def_kind(def) => {
|
||||
diag.note(
|
||||
"when the arguments and return types match, functions can be coerced \
|
||||
to function pointers",
|
||||
);
|
||||
(ty::FnPtr(sig), ty::FnDef(def_id, _)) | (ty::FnDef(def_id, _), ty::FnPtr(sig)) => {
|
||||
if tcx.fn_sig(*def_id).skip_binder().unsafety() < sig.unsafety() {
|
||||
diag.note("unsafe functions cannot be coerced into safe function pointers");
|
||||
}
|
||||
}
|
||||
_ => {}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue