about summary refs log tree commit diff
path: root/compiler/rustc_data_structures
diff options
context:
space:
mode:
authorMatthias Krüger <476013+matthiaskrgr@users.noreply.github.com>2025-07-05 00:12:10 +0200
committerGitHub <noreply@github.com>2025-07-05 00:12:10 +0200
commit567c51d5841ef30a16aecadc6bd190b2e9f92e5c (patch)
tree8b8831a73159686104456639a4821b753c96a1bc /compiler/rustc_data_structures
parente2e72cd02649333951c60f0b924927a9b6566dae (diff)
parent15286f220e54e39dc533e43a492679e957bf332b (diff)
downloadrust-567c51d5841ef30a16aecadc6bd190b2e9f92e5c.tar.gz
rust-567c51d5841ef30a16aecadc6bd190b2e9f92e5c.zip
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
Diffstat (limited to 'compiler/rustc_data_structures')
-rw-r--r--compiler/rustc_data_structures/src/vec_cache.rs4
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 0ffa6b3205f..599970663db 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,