Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 31 additions & 0 deletions tests/pass/coroutine.rs
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,38 @@ fn smoke_resume_arg() {
});
}

fn uninit_fields() {
// Test that uninhabited saved local doesn't make the entire variant uninhabited.
// (https://github.com/rust-lang/rust/issues/115145, https://github.com/rust-lang/rust/pull/118871)
fn conjure<T>() -> T {
loop {}
}

fn run<T>(x: bool, y: bool) {
let mut c = || {
if x {
let _a: T;
if y {
_a = conjure::<T>();
}
yield ();
} else {
let _a: T;
if y {
_a = conjure::<T>();
}
yield ();
}
};
assert!(matches!(Pin::new(&mut c).resume(()), CoroutineState::Yielded(())));
assert!(matches!(Pin::new(&mut c).resume(()), CoroutineState::Complete(())));
}

run::<!>(false, false);
}

fn main() {
basic();
smoke_resume_arg();
uninit_fields();
}