diff options
| author | Guillaume Gomez <guillaume1.gomez@gmail.com> | 2024-04-10 16:15:24 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-04-10 16:15:24 +0200 |
| commit | 1002c6534ed39470f3feb1cc7877a80bfa6d532a (patch) | |
| tree | 10bda3906afd779397afc291a828aaef72710d6d /compiler | |
| parent | 3f7ae6803b8953bf1e1e8596edb4bc1513334e37 (diff) | |
| parent | 69b690f0f69c7d7bc783df6295bdc6b14d65f07b (diff) | |
| download | rust-1002c6534ed39470f3feb1cc7877a80bfa6d532a.tar.gz rust-1002c6534ed39470f3feb1cc7877a80bfa6d532a.zip | |
Rollup merge of #123701 - compiler-errors:only-assert-after-checking, r=WaffleLapkin
Only assert for child/parent projection compatibility AFTER checking that theyre coming from the same place This assertion doesn't make sense until we check that these captures are actually equivalent. Fixes #123697 <sub>Some days I wonder how I even write code that works...</sub>
Diffstat (limited to 'compiler')
| -rw-r--r-- | compiler/rustc_mir_transform/src/coroutine/by_move_body.rs | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/compiler/rustc_mir_transform/src/coroutine/by_move_body.rs b/compiler/rustc_mir_transform/src/coroutine/by_move_body.rs index ccb229616e8..b26f968bf5e 100644 --- a/compiler/rustc_mir_transform/src/coroutine/by_move_body.rs +++ b/compiler/rustc_mir_transform/src/coroutine/by_move_body.rs @@ -154,6 +154,14 @@ impl<'tcx> MirPass<'tcx> for ByMoveBody { }) { let (child_field_idx, child_capture) = child_captures.next().unwrap(); + // This analysis only makes sense if the parent capture is a + // prefix of the child capture. + assert!( + child_capture.place.projections.len() >= parent_capture.place.projections.len(), + "parent capture ({parent_capture:#?}) expected to be prefix of \ + child capture ({child_capture:#?})" + ); + // Store this set of additional projections (fields and derefs). // We need to re-apply them later. let child_precise_captures = @@ -244,7 +252,6 @@ fn child_prefix_matches_parent_projections( bug!("expected capture to be an upvar"); }; - assert!(child_capture.place.projections.len() >= parent_capture.place.projections.len()); parent_base.var_path.hir_id == child_base.var_path.hir_id && std::iter::zip(&child_capture.place.projections, &parent_capture.place.projections) .all(|(child, parent)| child.kind == parent.kind) |
