We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
2 parents 41f2b6b + 2cd24b5 commit 11d963fCopy full SHA for 11d963f
compiler/rustc_index/src/bit_set.rs
@@ -187,14 +187,18 @@ impl<T: Idx> DenseBitSet<T> {
187
/// Insert `elem`. Returns whether the set has changed.
188
#[inline]
189
pub fn insert(&mut self, elem: T) -> bool {
190
- assert!(
+ debug_assert!(
191
elem.index() < self.domain_size,
192
"inserting element at index {} but domain size is {}",
193
elem.index(),
194
self.domain_size,
195
);
196
let (word_index, mask) = word_index_and_mask(elem);
197
- let word_ref = &mut self.words[word_index];
+ // SAFETY:
198
+ // The number of words we have is the domain size divided by word size (rounded up). We have
199
+ // asserted above that the element is contained within the domain size. Therefore,
200
+ // word_index is in bounds.
201
+ let word_ref = unsafe { self.words.get_unchecked_mut(word_index) };
202
let word = *word_ref;
203
let new_word = word | mask;
204
*word_ref = new_word;
AltStyle によって変換されたページ (->オリジナル) / アドレス: モード: デフォルト 音声ブラウザ ルビ付き 配色反転 文字拡大 モバイル
0 commit comments