Skip to content

Commit 15286f2

Browse files
committed
Remove some unnecessary unsafe in VecCache
1 parent d41e12f commit 15286f2

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)