Skip to content

Commit 6f3cc09

Browse files
committed
Avoid an is_empty() followed by an index op in favor of a single fallible op
1 parent b4993c4 commit 6f3cc09

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

Diff for: compiler/rustc_mir_transform/src/coroutine/by_move_body.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -89,11 +89,11 @@ impl<'tcx> MutVisitor<'tcx> for MakeByMoveBody<'tcx> {
8989
location: mir::Location,
9090
) {
9191
if place.local == ty::CAPTURE_STRUCT_LOCAL
92-
&& !place.projection.is_empty()
93-
&& let mir::ProjectionElem::Field(idx, ty) = place.projection[0]
92+
&& let Some((&mir::ProjectionElem::Field(idx, ty), projection)) =
93+
place.projection.split_first()
9494
&& self.by_ref_fields.contains(&idx)
9595
{
96-
let (begin, end) = place.projection[1..].split_first().unwrap();
96+
let (begin, end) = projection.split_first().unwrap();
9797
// FIXME(async_closures): I'm actually a bit surprised to see that we always
9898
// initially deref the by-ref upvars. If this is not actually true, then we
9999
// will at least get an ICE that explains why this isn't true :^)

0 commit comments

Comments
 (0)