Only implement Fn* traits for extern "Rust" safe function pointers.
This commit is contained in:
parent
84c47b8279
commit
fb9e171ab7
4 changed files with 98 additions and 2 deletions
|
@ -2,6 +2,7 @@ use rustc_data_structures::fx::FxHashMap;
|
|||
use rustc_hir::{def_id::DefId, Movability, Mutability};
|
||||
use rustc_infer::traits::query::NoSolution;
|
||||
use rustc_middle::ty::{self, Ty, TyCtxt, TypeFoldable, TypeFolder, TypeSuperFoldable};
|
||||
use rustc_target::spec::abi::Abi;
|
||||
|
||||
use crate::solve::EvalCtxt;
|
||||
|
||||
|
@ -194,7 +195,20 @@ pub(crate) fn extract_tupled_inputs_and_output_from_callable<'tcx>(
|
|||
.subst(tcx, substs)
|
||||
.map_bound(|sig| (tcx.mk_tup(sig.inputs()), sig.output())),
|
||||
)),
|
||||
ty::FnPtr(sig) => Ok(Some(sig.map_bound(|sig| (tcx.mk_tup(sig.inputs()), sig.output())))),
|
||||
// keep this in sync with assemble_fn_pointer_candidates until the old solver is removed.
|
||||
ty::FnPtr(sig) => {
|
||||
if let ty::FnSig {
|
||||
unsafety: rustc_hir::Unsafety::Normal,
|
||||
abi: Abi::Rust,
|
||||
c_variadic: false,
|
||||
..
|
||||
} = sig.skip_binder()
|
||||
{
|
||||
Ok(Some(sig.map_bound(|sig| (tcx.mk_tup(sig.inputs()), sig.output()))))
|
||||
} else {
|
||||
Err(NoSolution)
|
||||
}
|
||||
}
|
||||
ty::Closure(_, substs) => {
|
||||
let closure_substs = substs.as_closure();
|
||||
match closure_substs.kind_ty().to_opt_closure_kind() {
|
||||
|
|
|
@ -291,6 +291,9 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
|
|||
return;
|
||||
}
|
||||
|
||||
// Keep this funtion in sync with extract_tupled_inputs_and_output_from_callable
|
||||
// until the old solver (and thus this function) is removed.
|
||||
|
||||
// Okay to skip binder because what we are inspecting doesn't involve bound regions.
|
||||
let self_ty = obligation.self_ty().skip_binder();
|
||||
match *self_ty.kind() {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue