Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
c24e1c3
add s390x z17 target features
folkertdev May 19, 2025
fab206b
make `OsString::new` and `PathBuf::new` unstably const
cyrgani May 24, 2025
0cba7fb
Remove `i128` and `u128` from `improper_ctypes_definitions`
tgross35 Feb 20, 2025
0f1579b
build dist for x86_64-pc-solaris and sparcv9-sun-solaris
psumbera Mar 4, 2025
23d5231
Use non-2015 edition paths in tests that do not test for their resolu…
Veykril Jun 2, 2025
252ad18
Improve the documentation of `Display` and `FromStr`, and their inter…
joshtriplett Feb 7, 2025
f412d05
Add some more description of interactions between `Display` and `From…
joshtriplett Feb 7, 2025
7ba5d26
`FromStr`: Rework explanation of `FromStr`/`Display` round-tripping
joshtriplett Jun 3, 2025
742014e
`Display`: Rework explanation of `FromStr`/`Display` round-tripping
joshtriplett Jun 3, 2025
a0c19ee
index: add method for checking range on DenseBitSet
nia-e May 31, 2025
556c096
bootstrap: don't symlink source dir into stage0 sysroot
lambdageek Jun 4, 2025
3e7d5aa
Rollup merge of #136687 - joshtriplett:improve-display-and-fromstr-do…
matthiaskrgr Jun 4, 2025
c5efc6a
Rollup merge of #137306 - tgross35:remove-i128-u128-improper-ctypes, …
matthiaskrgr Jun 4, 2025
8ae7ca0
Rollup merge of #138699 - psumbera:solaris-ci-build3, r=marcoieni
matthiaskrgr Jun 4, 2025
59bdb5c
Rollup merge of #141250 - folkertdev:s390x-z17-target-features, r=wor…
matthiaskrgr Jun 4, 2025
88620b4
Rollup merge of #141467 - cyrgani:const-empty-stringlikes, r=Amanieu
matthiaskrgr Jun 4, 2025
e63e53a
Rollup merge of #141871 - nia-e:fix-bitset, r=eholk
matthiaskrgr Jun 4, 2025
add4bde
Rollup merge of #141888 - ferrocene:lw/decouple-tests-from-2015, r=co…
matthiaskrgr Jun 4, 2025
d31faac
Rollup merge of #142000 - lambdageek:no-symlink-stage0, r=onur-ozkan
matthiaskrgr Jun 4, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
index: add method for checking range on DenseBitSet
  • Loading branch information
nia-e committed Jun 3, 2025
commit a0c19ee577542cbc9dbdead54c91e661aa6396de
26 changes: 26 additions & 0 deletions compiler/rustc_index/src/bit_set.rs
Original file line number Diff line number Diff line change
Expand Up @@ -234,6 +234,32 @@ impl<T: Idx> DenseBitSet<T> {
self.clear_excess_bits();
}

/// Checks whether any bit in the given range is a 1.
#[inline]
pub fn contains_any(&self, elems: impl RangeBounds<T>) -> bool {
let Some((start, end)) = inclusive_start_end(elems, self.domain_size) else {
return false;
};
let (start_word_index, start_mask) = word_index_and_mask(start);
let (end_word_index, end_mask) = word_index_and_mask(end);

if start_word_index == end_word_index {
self.words[start_word_index] & (end_mask | (end_mask - start_mask)) != 0
} else {
if self.words[start_word_index] & !(start_mask - 1) != 0 {
return true;
}

let remaining = start_word_index + 1..end_word_index;
if remaining.start <= remaining.end {
self.words[remaining].iter().any(|&w| w != 0)
|| self.words[end_word_index] & (end_mask | (end_mask - 1)) != 0
} else {
false
}
}
}

/// Returns `true` if the set has changed.
#[inline]
pub fn remove(&mut self, elem: T) -> bool {
Expand Down
19 changes: 19 additions & 0 deletions compiler/rustc_index/src/bit_set/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -692,6 +692,25 @@ fn dense_last_set_before() {
}
}

#[test]
fn dense_contains_any() {
let mut set: DenseBitSet<usize> = DenseBitSet::new_empty(300);
assert!(!set.contains_any(0..300));
set.insert_range(10..20);
set.insert_range(60..70);
set.insert_range(150..=250);

assert!(set.contains_any(0..30));
assert!(set.contains_any(5..100));
assert!(set.contains_any(250..255));

assert!(!set.contains_any(20..59));
assert!(!set.contains_any(256..290));

set.insert(22);
assert!(set.contains_any(20..59));
}

#[bench]
fn bench_insert(b: &mut Bencher) {
let mut bs = DenseBitSet::new_filled(99999usize);
Expand Down
5 changes: 1 addition & 4 deletions src/tools/miri/src/alloc/isolated_alloc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -145,10 +145,7 @@ impl IsolatedAlloc {
if pinfo.domain_size() < offset_pinfo + size_pinfo {
break;
}
// FIXME: is there a more efficient way to check whether the entire range is unset
// in the bitset?
let range_avail = !(offset_pinfo..offset_pinfo + size_pinfo).any(|i| pinfo.contains(i));
if range_avail {
if !pinfo.contains_any(offset_pinfo..offset_pinfo + size_pinfo) {
pinfo.insert_range(offset_pinfo..offset_pinfo + size_pinfo);
// SAFETY: We checked the available bytes after `idx` in the call
// to `domain_size` above and asserted there are at least `idx +
Expand Down
Loading