Recover when failing to normalize closure signature.
This commit is contained in:
parent
2e45cd4b69
commit
0161ecd13f
7 changed files with 34 additions and 9 deletions
|
@ -496,12 +496,12 @@ impl<'tcx> Instance<'tcx> {
|
|||
def_id: DefId,
|
||||
substs: ty::SubstsRef<'tcx>,
|
||||
requested_kind: ty::ClosureKind,
|
||||
) -> Instance<'tcx> {
|
||||
) -> Option<Instance<'tcx>> {
|
||||
let actual_kind = substs.as_closure().kind();
|
||||
|
||||
match needs_fn_once_adapter_shim(actual_kind, requested_kind) {
|
||||
Ok(true) => Instance::fn_once_adapter_instance(tcx, def_id, substs),
|
||||
_ => Instance::new(def_id, substs),
|
||||
_ => Some(Instance::new(def_id, substs)),
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -515,7 +515,7 @@ impl<'tcx> Instance<'tcx> {
|
|||
tcx: TyCtxt<'tcx>,
|
||||
closure_did: DefId,
|
||||
substs: ty::SubstsRef<'tcx>,
|
||||
) -> Instance<'tcx> {
|
||||
) -> Option<Instance<'tcx>> {
|
||||
debug!("fn_once_adapter_shim({:?}, {:?})", closure_did, substs);
|
||||
let fn_once = tcx.require_lang_item(LangItem::FnOnce, None);
|
||||
let call_once = tcx
|
||||
|
@ -531,12 +531,13 @@ impl<'tcx> Instance<'tcx> {
|
|||
let self_ty = tcx.mk_closure(closure_did, substs);
|
||||
|
||||
let sig = substs.as_closure().sig();
|
||||
let sig = tcx.normalize_erasing_late_bound_regions(ty::ParamEnv::reveal_all(), sig);
|
||||
let sig =
|
||||
tcx.try_normalize_erasing_late_bound_regions(ty::ParamEnv::reveal_all(), sig).ok()?;
|
||||
assert_eq!(sig.inputs().len(), 1);
|
||||
let substs = tcx.mk_substs_trait(self_ty, &[sig.inputs()[0].into()]);
|
||||
|
||||
debug!("fn_once_adapter_shim: self_ty={:?} sig={:?}", self_ty, sig);
|
||||
Instance { def, substs }
|
||||
Some(Instance { def, substs })
|
||||
}
|
||||
|
||||
/// Depending on the kind of `InstanceDef`, the MIR body associated with an
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue