Auto merge of #97012 - oli-obk:🦀_intrinsics, r=davidtwco
Add a query for checking whether a function is an intrinsic. work towards #93145 This will reduce churn when we add more ways to declare intrinsics r? `@scottmcm`
This commit is contained in:
commit
735efc0c70
17 changed files with 52 additions and 45 deletions
|
@ -775,17 +775,19 @@ impl<'f, 'tcx> Coerce<'f, 'tcx> {
|
|||
match b.kind() {
|
||||
ty::FnPtr(b_sig) => {
|
||||
let a_sig = a.fn_sig(self.tcx);
|
||||
// Intrinsics are not coercible to function pointers
|
||||
if a_sig.abi() == Abi::RustIntrinsic || a_sig.abi() == Abi::PlatformIntrinsic {
|
||||
return Err(TypeError::IntrinsicCast);
|
||||
}
|
||||
if let ty::FnDef(def_id, _) = *a.kind() {
|
||||
// Intrinsics are not coercible to function pointers
|
||||
if self.tcx.is_intrinsic(def_id) {
|
||||
return Err(TypeError::IntrinsicCast);
|
||||
}
|
||||
|
||||
// Safe `#[target_feature]` functions are not assignable to safe fn pointers (RFC 2396).
|
||||
if let ty::FnDef(def_id, _) = *a.kind()
|
||||
&& b_sig.unsafety() == hir::Unsafety::Normal
|
||||
&& !self.tcx.codegen_fn_attrs(def_id).target_features.is_empty()
|
||||
{
|
||||
return Err(TypeError::TargetFeatureCast(def_id));
|
||||
// Safe `#[target_feature]` functions are not assignable to safe fn pointers (RFC 2396).
|
||||
|
||||
if b_sig.unsafety() == hir::Unsafety::Normal
|
||||
&& !self.tcx.codegen_fn_attrs(def_id).target_features.is_empty()
|
||||
{
|
||||
return Err(TypeError::TargetFeatureCast(def_id));
|
||||
}
|
||||
}
|
||||
|
||||
let InferOk { value: a_sig, obligations: o1 } =
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue