diff options
Diffstat (limited to 'compiler')
| -rw-r--r-- | compiler/rustc_mir_transform/src/coroutine/by_move_body.rs | 11 |
1 files changed, 8 insertions, 3 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 d94441b1413..320d8fd3977 100644 --- a/compiler/rustc_mir_transform/src/coroutine/by_move_body.rs +++ b/compiler/rustc_mir_transform/src/coroutine/by_move_body.rs @@ -289,10 +289,15 @@ impl<'tcx> MutVisitor<'tcx> for MakeByMoveBody<'tcx> { // generating, we also are taking that field by value. Peel off a deref, // since a layer of reffing has now become redundant. let final_deref = if needs_deref { - let [mir::ProjectionElem::Deref] = projection else { - bug!("There should only be a single deref for an upvar local initialization"); + let Some((mir::ProjectionElem::Deref, projection)) = projection.split_first() + else { + bug!( + "There should be at least a single deref for an upvar local initialization, found {projection:#?}" + ); }; - &[] + // There may be more derefs, since we may also implicitly reborrow + // a captured mut pointer. + projection } else { projection }; |
