Rollup merge of #136610 - Jarcho:range_idx, r=Noratrieb

Allow `IndexSlice` to be indexed by ranges.

This comes with some annoyances as the index type can no longer inferred from indexing expressions. The biggest offender for this is `IndexVec::from_fn_n(|idx| ..., n)` where the index type won't be inferred from the call site or any index expressions inside the closure.

My main use case for this is mapping a `Place` to `Range<Idx>` for value tracking where the range represents all the values the place contains.
This commit is contained in:
Jacob Pratt 2025-02-24 02:11:32 -05:00 committed by GitHub
commit 6aa015ae9d
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
12 changed files with 144 additions and 42 deletions

View file

@ -147,7 +147,7 @@ impl<I: Idx, K: Ord, V> FromIterator<(K, V)> for SortedIndexMultiMap<I, K, V> {
where
J: IntoIterator<Item = (K, V)>,
{
let items = IndexVec::from_iter(iter);
let items = IndexVec::<I, _>::from_iter(iter);
let mut idx_sorted_by_item_key: Vec<_> = items.indices().collect();
// `sort_by_key` is stable, so insertion order is preserved for duplicate items.