Skip to content

Commit 567c51d

Browse files
authored
Rollup merge of #143406 - scottmcm:did-we-need-that-unsafe, r=compiler-errors
Remove some unnecessary `unsafe` in VecCache I'm pretty sure, but until perf confirms, r? ghost
2 parents e2e72cd + 15286f2 commit 567c51d

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

compiler/rustc_data_structures/src/vec_cache.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,8 +76,8 @@ impl SlotIndex {
7676
index_in_bucket: idx as usize,
7777
};
7878
}
79-
// SAFETY: We already ruled out idx 0, so `checked_ilog2` can't return `None`.
80-
let bucket = unsafe { idx.checked_ilog2().unwrap_unchecked() as usize };
79+
// We already ruled out idx 0, so this `ilog2` never panics (and the check optimizes away)
80+
let bucket = idx.ilog2() as usize;
8181
let entries = 1 << bucket;
8282
SlotIndex {
8383
bucket_idx: bucket - FIRST_BUCKET_SHIFT + 1,

0 commit comments

Comments
 (0)