Dear rustc developers (or potential rustc developers),
Now that rustc is able to depend on crates from crates.io, I think we should look at trying to break out bits of rustc where it makes sense. In fact, this transition is already underway. For example, we have a number of crates that rustc depends on which are managed by the rustc team:
-
ena (unification)
-
chalk-engine (trait solving, eventually)
-
polonius (borrow checking, eventually)
However, we have a number of other crates that are currently “baked in”, mostly in rustc_data_structures. Many of these have a crates.io counterpart already:
-
FxHashMap (there is fxhash on crates.io)
- the rustc graph stuff and graph-algorithms (there is
petgraph on crates.io, but it differs in some particulars; probably it’s mostly better, but…)
I see a number of advantages of moving things out from the main repo into separate crates:
- Faster iteration and unit testing.
- These crates can build up their own communities and maintainers. This has been a big success in servo.
- Hacking on a subcrate is a good way to get involved without having to learn about all of rustc, or deal with rustc build times.
- It encourages us to build up unit tests and mocks and the like for testing corner cases. This is good.
On the other hand, there are some costs:
- It’s harder to land an “atomic change” that affects many things.
I think — on balance — it’s worth it. Here are some specific questions to think about?
- What code is a good candidate for “moving out”?
- In addition to the existing stuff, I think basically all the code in
rustc_data_structures fits the bill.
- How do we balance having control versus using other things?
- For example, should we port to use
petgraph in place of rustc’s graph? What about using fxhash?
- My preference, I think, is that for these sorts of core data structures, rustc should have the ability to tweak as we need to, but it’s not a clear call.
- In cases where the repo is owned by rust-lang project, should it be part of rust-lang or rust-lang-nursery?
- I lean towards rust-lang: this is shipping code used in rustc etc! It’s not exactly immature or experimental in the usual sense.
- That said, a lot of the APIs are not particularly ergonomic etc. Maybe we ought to signal that somehow.