Files
rust/compiler/rustc_public
Jacob Pratt edb63697e3 Rollup merge of #160676 - makai410:rpub/cleanup, r=celinval
rustc_public: split `def`s out of `ty`

This is more of an "I feel like this should be like this" kind of change. I suppose that we might need to make the `ty` a bit more fine-grained as the coverage expands. That said, I don't have a strong opinion on whether it's necessary, so feel free to close this PR if you find it not convincing enough.

The diff looks so scary, though... I just split `ty.rs` into `def.rs` and `tys.rs` and changed `crate_def!` and `crate_def_with_ty!`.
2026-08-12 20:17:31 -04:00
..

This crate is currently developed in-tree together with the compiler.

Our goal is to start publishing rustc_public into crates.io. Until then, users will use this as any other rustc crate, by installing the rustup component rustc-dev, and declaring rustc-public as an external crate.

See the rustc_public "Getting Started" guide for more information.

Design

The rustc_public crate will follow a similar approach to proc-macro2. Its implementation is split between two main crates:

  • rustc_public: Public crate, to be published on crates.io, which will contain the "stable" data structure as well as calls to rustc_public_bridge APIs. The translation between public and internal constructs is also done in this crate.
  • rustc_public_bridge: This crate implements the public APIs to the compiler. It is responsible for gathering all the information requested, and providing the data in its unstable internal form.

I.e., tools will depend on rustc_public crate, which will invoke the compiler using APIs defined in rustc_public_bridge.

I.e.:

    ┌────────────────────────────┐           ┌───────────────────────────┐
    │      External Tool         │           │         Rust Compiler     │
    │            ┌────────────┐  │           │ ┌────────┐                │
    │            │            │  │           │ │        │                │
    │            │rustc_public│  │           │ │rustc   │                │
    │            │            │  ├──────────►| │public  │                │
    │            │            │  │◄──────────┤ │bridge  │                │
    │            │            │  │           │ │        │                │
    │            │            │  │           │ │        │                │
    │            └────────────┘  │           │ └────────┘                │
    └────────────────────────────┘           └───────────────────────────┘

More details can be found here: https://hackmd.io/XhnYHKKuR6-LChhobvlT-g?view