compiler: Move rustc_target::spec::abi::Abi to rustc_abi::ExternAbi by workingjubilee · Pull Request #132385 · rust-lang/rust (original) (raw)

Lift enum Abi from its rather odd place in the middle of rustc_target, and make it available again from rustc_abi. You know, the crate where you would expect the enum that describes all the ABIs to be? The platform-neutral ones, at least. This will help further refactoring of how we handle ABIs in the near future1.

Rename Abi to ExternAbi because quite a lot of the compiler overloads the concept of "ABI" enough that the existing name is imprecise and it is often renamed anyway. Often this was to avoid conflicts with the other type formerly known as Abi (now named BackendRepr2), but sometimes it is just for clarity, and this name seems more self-explanatory. It does get reexported, though, using its old name, to reduce the odds of merge-conflicting over the entire tree.

All of ExternAbi's friends come along for the ride, which costs adding some optional dependencies to the rustc_abi crate. However, all of this also allows simply moving three crates entirely off rustc_target:

This odd selection is mostly to demonstrate a secondary motivation: The majority of the front-end of the compiler should be as target-agnostic as possible, and it is easier to assure this if they simply don't depend on the crate that describes targets. Note that I didn't migrate crates that don't benefit from it in this way yet, and I didn't survey every last crate.

Footnotes

  1. This is being undertaken as part of https://github.com/rust-lang/rust/issues/119183
  2. https://github.com/rust-lang/rust/pull/132246