Rollup merge of #63208 - tmandry:issue-62658, r=cramertj

Round generator sizes to a multiple of their alignment

Fixes #62658.

r? @cramertj
cc @eddyb
This commit is contained in:
Mazdak Farrokhzad 2019-08-03 00:09:11 +02:00 committed by GitHub
commit 109b21f7b7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 31 additions and 0 deletions

View File

@ -1540,6 +1540,8 @@ fn generator_layout(
Ok(variant)
}).collect::<Result<IndexVec<VariantIdx, _>, _>>()?;
size = size.align_to(align.abi);
let abi = if prefix.abi.is_uninhabited() ||
variants.iter().all(|v| v.abi.is_uninhabited()) {
Abi::Uninhabited

View File

@ -0,0 +1,29 @@
// This test created a generator whose size was not rounded to a multiple of its
// alignment. This caused an assertion error in codegen.
// build-pass
// edition:2018
#![feature(async_await)]
async fn noop() {}
async fn foo() {
// This suspend should be the largest variant.
{
let x = [0u8; 17];
noop().await;
println!("{:?}", x);
}
// Add one variant that's aligned to 8 bytes.
{
let x = 0u64;
noop().await;
println!("{:?}", x);
}
}
fn main() {
let _ = foo();
}