diff options
| author | Mazdak Farrokhzad <twingoow@gmail.com> | 2019-08-03 00:09:11 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2019-08-03 00:09:11 +0200 |
| commit | 109b21f7b7ecd08f26449e384cf3d3e957f98f22 (patch) | |
| tree | 146560774ac0f5dff16c486fbe63085564048d80 | |
| parent | ed7b0447cb4d760746125f9b26f5283b02ff9056 (diff) | |
| parent | 14be0886778aec5ed597db19b1778503b90c51ab (diff) | |
| download | rust-109b21f7b7ecd08f26449e384cf3d3e957f98f22.tar.gz rust-109b21f7b7ecd08f26449e384cf3d3e957f98f22.zip | |
Rollup merge of #63208 - tmandry:issue-62658, r=cramertj
Round generator sizes to a multiple of their alignment Fixes #62658. r? @cramertj cc @eddyb
| -rw-r--r-- | src/librustc/ty/layout.rs | 2 | ||||
| -rw-r--r-- | src/test/ui/async-await/issue-62658.rs | 29 |
2 files changed, 31 insertions, 0 deletions
diff --git a/src/librustc/ty/layout.rs b/src/librustc/ty/layout.rs index 3b4b814c92a..e0e70f41abe 100644 --- a/src/librustc/ty/layout.rs +++ b/src/librustc/ty/layout.rs @@ -1540,6 +1540,8 @@ impl<'tcx> LayoutCx<'tcx, TyCtxt<'tcx>> { 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 diff --git a/src/test/ui/async-await/issue-62658.rs b/src/test/ui/async-await/issue-62658.rs new file mode 100644 index 00000000000..90fbb47bffd --- /dev/null +++ b/src/test/ui/async-await/issue-62658.rs @@ -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(); +} |
