Skip to content

Commit eab4c90

Browse files
committed
Sync fn_sig_for_fn_abi with upstream for generator resume args
Fixes #970
1 parent a802c7f commit eab4c90

File tree

2 files changed

+11
-6
lines changed

2 files changed

+11
-6
lines changed

example/std_example.rs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
#![feature(core_intrinsics)]
2-
#![feature(is_sorted)]
1+
#![feature(core_intrinsics, generators, generator_trait, is_sorted)]
32

43
use std::arch::x86_64::*;
54
use std::io::Write;
5+
use std::ops::Generator;
66

77
fn main() {
88
let mutex = std::sync::Mutex::new(());
@@ -89,6 +89,10 @@ fn main() {
8989
unsafe {
9090
test_simd();
9191
}
92+
93+
Box::pin(move |mut _task_context| {
94+
yield ();
95+
}).as_mut().resume(0);
9296
}
9397

9498
#[target_feature(enable = "sse2")]

src/abi/mod.rs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ use crate::prelude::*;
1212

1313
pub(crate) use self::returning::{can_return_to_ssa_var, codegen_return};
1414

15-
// Copied from https://github.com/rust-lang/rust/blob/c2f4c57296f0d929618baed0b0d6eb594abf01eb/src/librustc/ty/layout.rs#L2349
15+
// Copied from https://github.com/rust-lang/rust/blob/b2c1a606feb1fbdb0ac0acba76f881ef172ed474/src/librustc_middle/ty/layout.rs#L2287
1616
pub(crate) fn fn_sig_for_fn_abi<'tcx>(tcx: TyCtxt<'tcx>, instance: Instance<'tcx>) -> ty::PolyFnSig<'tcx> {
1717
let ty = instance.monomorphic_ty(tcx);
1818
match ty.kind {
@@ -43,7 +43,7 @@ pub(crate) fn fn_sig_for_fn_abi<'tcx>(tcx: TyCtxt<'tcx>, instance: Instance<'tcx
4343
sig.abi
4444
))
4545
}
46-
ty::Generator(_def_id, substs, _) => {
46+
ty::Generator(_, substs, _) => {
4747
let sig = substs.as_generator().poly_sig();
4848

4949
let env_region = ty::ReLateBound(ty::INNERMOST, ty::BrEnv);
@@ -63,8 +63,9 @@ pub(crate) fn fn_sig_for_fn_abi<'tcx>(tcx: TyCtxt<'tcx>, instance: Instance<'tcx
6363
]);
6464
let ret_ty = tcx.mk_adt(state_adt_ref, state_substs);
6565

66-
tcx.mk_fn_sig(std::iter::once(env_ty),
67-
ret_ty,
66+
tcx.mk_fn_sig(
67+
[env_ty, sig.resume_ty].iter(),
68+
&ret_ty,
6869
false,
6970
rustc_hir::Unsafety::Normal,
7071
rustc_target::spec::abi::Abi::Rust

0 commit comments

Comments
 (0)