diff options
| author | Oli Scherer <git-spam-no-reply9815368754983@oli-obk.de> | 2024-04-02 14:13:05 +0000 |
|---|---|---|
| committer | Oli Scherer <git-spam-no-reply9815368754983@oli-obk.de> | 2024-04-02 14:13:05 +0000 |
| commit | 6f3cc0903c7d540acc10ea13fa2cf6aaec8f64cd (patch) | |
| tree | 005120e4d6deb279d7c8dfe8ebaee0bb3f06fe2d /compiler/rustc_mir_transform/src | |
| parent | b4993c47f2f1348356d87c92ea54fd20fcd71cb7 (diff) | |
| download | rust-6f3cc0903c7d540acc10ea13fa2cf6aaec8f64cd.tar.gz rust-6f3cc0903c7d540acc10ea13fa2cf6aaec8f64cd.zip | |
Avoid an `is_empty()` followed by an index op in favor of a single fallible op
Diffstat (limited to 'compiler/rustc_mir_transform/src')
| -rw-r--r-- | compiler/rustc_mir_transform/src/coroutine/by_move_body.rs | 6 |
1 files changed, 3 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 9201ad40152..99dbb342268 100644 --- a/compiler/rustc_mir_transform/src/coroutine/by_move_body.rs +++ b/compiler/rustc_mir_transform/src/coroutine/by_move_body.rs @@ -89,11 +89,11 @@ impl<'tcx> MutVisitor<'tcx> for MakeByMoveBody<'tcx> { location: mir::Location, ) { if place.local == ty::CAPTURE_STRUCT_LOCAL - && !place.projection.is_empty() - && let mir::ProjectionElem::Field(idx, ty) = place.projection[0] + && let Some((&mir::ProjectionElem::Field(idx, ty), projection)) = + place.projection.split_first() && self.by_ref_fields.contains(&idx) { - let (begin, end) = place.projection[1..].split_first().unwrap(); + let (begin, end) = projection.split_first().unwrap(); // FIXME(async_closures): I'm actually a bit surprised to see that we always // initially deref the by-ref upvars. If this is not actually true, then we // will at least get an ICE that explains why this isn't true :^) |
