diff options
| author | Michael Goulet <michael@errs.io> | 2024-02-15 01:07:20 +0000 |
|---|---|---|
| committer | Michael Goulet <michael@errs.io> | 2024-02-15 01:18:09 +0000 |
| commit | e6a21f549ebf1437a59e9a0bb3c8e41172d1dcf7 (patch) | |
| tree | 3ea19ad4feafe291156ef29df74a1c9c091cd53c /compiler/rustc_const_eval/src | |
| parent | ee9c7c940c07d8b67c9a6b2ec930db70dcd23a46 (diff) | |
| download | rust-e6a21f549ebf1437a59e9a0bb3c8e41172d1dcf7.tar.gz rust-e6a21f549ebf1437a59e9a0bb3c8e41172d1dcf7.zip | |
Enforce coroutine-closure layouts are identical
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:#?}", + ), + ); + } + } } } |
