]> git.lizzy.rs Git - rust.git/commitdiff
Take resume argument from the right generator type
authorJonas Schievink <jonasschievink@gmail.com>
Tue, 4 Feb 2020 12:52:09 +0000 (13:52 +0100)
committerJonas Schievink <jonasschievink@gmail.com>
Tue, 4 Feb 2020 12:52:09 +0000 (13:52 +0100)
I suppose we could also just put `tcx.mk_unit()` here, but this
works too

src/librustc_mir_build/build/mod.rs

index 4c8d8e3a0eac84b5afc2e3702cfde475acaaf7ba..ccfee2d2bb2ee9b87e64a377a9b037087f653a3e 100644 (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),