Skip to content

Minimal indexmap support for rustc-rayon #14

New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Merged
merged 2 commits into from
Jan 18, 2025

Conversation

cuviper
Copy link
Member

@cuviper cuviper commented Jan 13, 2025

Currently, indexmap has an optional "internal only" dependency on rustc-rayon to implement parallel iterator support for use in the compiler. This PR flips that around to have rustc-rayon implements those parallel iterators, so indexmap doesn't need to bother with this relatively niche use-case. If this is accepted and published, I intend to remove that "internal" dependency.

These implementations are all straightforward with the Slice API:

  • impl<'a, K, V, S> IntoParallelIterator for &'a IndexMap<K, V, S>
  • impl<'a, K, V, S> IntoParallelIterator for &'a mut IndexMap<K, V, S>
  • impl<'a, T, S> IntoParallelIterator for &'a IndexSet<T, S>

However, indexmap/rustc-rayon also had by-value IntoParallelIterator implementations that are not feasible without direct access to their storage. Nothing in the compiler is currently using that though, so I think it's ok to drop it.

@cuviper
Copy link
Member Author

cuviper commented Jan 13, 2025

For reference, here's how the impls currently look on the indexmap side:
https://github.com/indexmap-rs/indexmap/blob/31c9862f71e00411271acb7c9bea3a21b3d08880/src/rustc.rs

... and they use the forwarding macros found here:
https://github.com/indexmap-rs/indexmap/blob/31c9862f71e00411271acb7c9bea3a21b3d08880/src/macros.rs#L126

So those are using rayon's Vec/slice implementations and then mapping the private Bucket to the final Item type.

@cuviper cuviper merged commit 5bdcebb into rust-lang:rustc Jan 18, 2025
3 checks passed
cuviper added a commit to cuviper/rust that referenced this pull request Jan 27, 2025
[`rustc-rayon v0.5.1`](rust-lang/rustc-rayon#14)
added `indexmap` implementations that will allow `indexmap` to drop its
own "internal-only" implementations.

(This is separate from `indexmap`'s implementation for normal `rayon`.)
cuviper added a commit to cuviper/indexmap that referenced this pull request Jan 27, 2025
While this looks like a breaking change, it was always documented in
`Cargo.toml` as internal-only for use in the compiler:

> Internal feature, only used when building as part of rustc,
> not part of the stable interface of this crate.

That's flipped around in [rustc-rayon#14] and [rust#136149].

[rustc-rayon#14]: rust-lang/rustc-rayon#14
[rust#136149]: rust-lang/rust#136149
matthiaskrgr added a commit to matthiaskrgr/rust that referenced this pull request Jan 28, 2025
…mpiler-errors

Flip the `rustc-rayon`/`indexmap` dependency order

[`rustc-rayon v0.5.1`](rust-lang/rustc-rayon#14) added `indexmap` implementations that will allow `indexmap` to drop its own "internal-only" implementations.

(This is separate from `indexmap`'s implementation for normal `rayon`.)
matthiaskrgr added a commit to matthiaskrgr/rust that referenced this pull request Jan 28, 2025
…mpiler-errors

Flip the `rustc-rayon`/`indexmap` dependency order

[`rustc-rayon v0.5.1`](rust-lang/rustc-rayon#14) added `indexmap` implementations that will allow `indexmap` to drop its own "internal-only" implementations.

(This is separate from `indexmap`'s implementation for normal `rayon`.)
rust-timer added a commit to rust-lang-ci/rust that referenced this pull request Jan 28, 2025
Rollup merge of rust-lang#136149 - cuviper:rustc-rayon-indexmap, r=compiler-errors

Flip the `rustc-rayon`/`indexmap` dependency order

[`rustc-rayon v0.5.1`](rust-lang/rustc-rayon#14) added `indexmap` implementations that will allow `indexmap` to drop its own "internal-only" implementations.

(This is separate from `indexmap`'s implementation for normal `rayon`.)
github-actions bot pushed a commit to rust-lang/miri that referenced this pull request Jan 29, 2025
…rors

Flip the `rustc-rayon`/`indexmap` dependency order

[`rustc-rayon v0.5.1`](rust-lang/rustc-rayon#14) added `indexmap` implementations that will allow `indexmap` to drop its own "internal-only" implementations.

(This is separate from `indexmap`'s implementation for normal `rayon`.)
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant