diff options
| author | Scott McMurray <scottmcm@users.noreply.github.com> | 2025-07-03 17:42:43 -0700 |
|---|---|---|
| committer | Scott McMurray <scottmcm@users.noreply.github.com> | 2025-07-03 17:42:43 -0700 |
| commit | 15286f220e54e39dc533e43a492679e957bf332b (patch) | |
| tree | e2154f7ec5efc915adec144b8113d6b4fe560af2 | |
| parent | d41e12f1f4e4884c356f319b881921aa37040de5 (diff) | |
| download | rust-15286f220e54e39dc533e43a492679e957bf332b.tar.gz rust-15286f220e54e39dc533e43a492679e957bf332b.zip | |
Remove some unnecessary `unsafe` in VecCache
| -rw-r--r-- | compiler/rustc_data_structures/src/vec_cache.rs | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/compiler/rustc_data_structures/src/vec_cache.rs b/compiler/rustc_data_structures/src/vec_cache.rs index 3b448c056b7..df83d15b5f9 100644 --- a/compiler/rustc_data_structures/src/vec_cache.rs +++ b/compiler/rustc_data_structures/src/vec_cache.rs @@ -76,8 +76,8 @@ impl SlotIndex { index_in_bucket: idx as usize, }; } - // SAFETY: We already ruled out idx 0, so `checked_ilog2` can't return `None`. - let bucket = unsafe { idx.checked_ilog2().unwrap_unchecked() as usize }; + // We already ruled out idx 0, so this `ilog2` never panics (and the check optimizes away) + let bucket = idx.ilog2() as usize; let entries = 1 << bucket; SlotIndex { bucket_idx: bucket - FIRST_BUCKET_SHIFT + 1, |
