diff options
| author | Matthias Krüger <matthias.krueger@famsik.de> | 2024-02-15 09:20:23 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-02-15 09:20:23 +0100 |
| commit | 829b59a47d502dcb441f47a4e182e9f39c76a7b6 (patch) | |
| tree | 053ff2243eb850f665ceede8565af34f63238e37 /compiler/rustc_const_eval/src | |
| parent | 48991081092a7d3d4fb48e8994d0f0ac2321f8ec (diff) | |
| parent | e6a21f549ebf1437a59e9a0bb3c8e41172d1dcf7 (diff) | |
| download | rust-829b59a47d502dcb441f47a4e182e9f39c76a7b6.tar.gz rust-829b59a47d502dcb441f47a4e182e9f39c76a7b6.zip | |
Rollup merge of #121122 - compiler-errors:identical-layouts, r=oli-obk
Enforce coroutine-closure layouts are identical Enforce that for an async closure, the by-ref and by-move coroutine layouts are identical. This is just a sanity check to make sure that optimizations aren't doing anything fishy. r? oli-obk
Diffstat (limited to 'compiler/rustc_const_eval/src')
| -rw-r--r-- | compiler/rustc_const_eval/src/transform/validate.rs | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/compiler/rustc_const_eval/src/transform/validate.rs b/compiler/rustc_const_eval/src/transform/validate.rs index b5c70538c52..1ff72516324 100644 --- a/compiler/rustc_const_eval/src/transform/validate.rs +++ b/compiler/rustc_const_eval/src/transform/validate.rs @@ -98,6 +98,26 @@ impl<'tcx> MirPass<'tcx> for Validator { } } } + + // Enforce that coroutine-closure layouts are identical. + if let Some(layout) = body.coroutine_layout() + && let Some(by_move_body) = body.coroutine_by_move_body() + && let Some(by_move_layout) = by_move_body.coroutine_layout() + { + if layout != by_move_layout { + // If this turns out not to be true, please let compiler-errors know. + // It is possible to support, but requires some changes to the layout + // computation code. + cfg_checker.fail( + Location::START, + format!( + "Coroutine layout differs from by-move coroutine layout:\n\ + layout: {layout:#?}\n\ + by_move_layout: {by_move_layout:#?}", + ), + ); + } + } } } |
