Skip to content

Commit a72083f

Browse files
committed
Avoid some more usize-to-u64 casts in prefix_slice_suffix
1 parent a9ce750 commit a72083f

1 file changed

Lines changed: 3 additions & 5 deletions

File tree

compiler/rustc_mir_build/src/builder/matches/match_pair.rs

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -58,9 +58,8 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
5858
None => (prefix_len + suffix_len, false),
5959
};
6060

61-
for (idx, subpattern) in prefix.iter().enumerate() {
62-
let elem =
63-
ProjectionElem::ConstantIndex { offset: idx as u64, min_length, from_end: false };
61+
for (offset, subpattern) in (0u64..).zip(prefix) {
62+
let elem = ProjectionElem::ConstantIndex { offset, min_length, from_end: false };
6463
let place = place.clone_project(elem);
6564
MatchPairTree::for_pattern(place, subpattern, self, match_pairs, extra_data)
6665
}
@@ -74,8 +73,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
7473
MatchPairTree::for_pattern(subslice, subslice_pat, self, match_pairs, extra_data);
7574
}
7675

77-
for (idx, subpattern) in suffix.iter().rev().enumerate() {
78-
let end_offset = (idx + 1) as u64;
76+
for (end_offset, subpattern) in (1u64..).zip(suffix.iter().rev()) {
7977
let elem = ProjectionElem::ConstantIndex {
8078
offset: if is_array { min_length - end_offset } else { end_offset },
8179
min_length,

0 commit comments

Comments
 (0)