Take resume argument from the right generator type

I suppose we could also just put `tcx.mk_unit()` here, but this
works too
This commit is contained in:
Jonas Schievink 2020-02-04 13:52:09 +01:00
parent 72776e6b5d
commit 895aab2263

View File

@ -83,12 +83,18 @@ fn mir_build(tcx: TyCtxt<'_>, def_id: DefId) -> BodyAndCache<'_> {
abi = Abi::Rust;
vec![ArgInfo(liberated_closure_env_ty(tcx, id, body_id), None, None, None)]
}
ty::Generator(def_id, substs, _) => {
ty::Generator(def_id, _, _) => {
let gen_ty = tcx.body_tables(body_id).node_type(id);
let resume_ty = substs.as_generator().resume_ty(def_id, tcx);
// The resume argument may be missing, in that case we need to provide it here.
if body.params.is_empty() {
let resume_ty = match gen_ty.kind {
ty::Generator(_, substs, _) => {
substs.as_generator().resume_ty(def_id, tcx)
}
_ => bug!(),
};
vec![
ArgInfo(gen_ty, None, None, None),
ArgInfo(resume_ty, None, None, None),