Module proc_macro::bridge
source · 🔬This is a nightly-only experimental API. (
proc_macro_internals #27812)Expand description
Internal interface for communicating between a proc_macro client
(a proc macro crate) and a proc_macro server (a compiler front-end).
Serialization (with C ABI buffers) and unique integer handles are employed
to allow safely interfacing between two copies of proc_macro built
(from the same source) by different compilers with potentially mismatching
Rust ABIs (e.g., stage0/bin/rustc vs stage1/bin/rustc during bootstrap).
Modules
- A minimal arena allocator inspired by
rustc_arena::DroplessArena. - Buffer management for same-process client<->server communication.
- clientExperimentalClient-side types.
- Closure type (equivalent to
&mut dyn FnMut(A) -> R) that’srepr(C). - This is a copy of the
rustc_hashcrate, adapted to work as a module. - Server-side handles and storage for per-handle data.
- Serialization for client-server communication.
Cellvariant for (scoped) existential lifetimes.- Abstraction for creating
fnpointers from any callable that effectively has the equivalent of implementingDefault, even if the compiler neither providesDefaultnor allows reifying closures (i.e. creatingfnpointers) other than those with absolutely no captures. - serverExperimentalServer-side traits.
- Client-side interner used for symbols.
Macros
- Higher-order macro describing the server RPC API, allowing automatic generation of type-safe Rust APIs, both client-side and server-side.
Structs
- BridgeConfigExperimentalConfiguration for establishing an active connection between a server and a client. The server creates the bridge config (
run_serverinserver.rs), then passes it to the client through the function pointer in therunfield ofclient::Client. The client constructs a localBridgefrom the config in TLS during its execution (Bridge::{enter, with}inclient.rs). - DelimSpanExperimental
- DiagnosticExperimental
- ExpnGlobalsExperimentalGlobals provided alongside the initial inputs for a macro expansion. Provides values such as spans which are used frequently to avoid RPC.
- GroupExperimental
- IdentExperimental
- LiteralExperimental
- PunctExperimental
Enums
- LitKindExperimental
- PanicMessageExperimentalSimplified version of panic payloads, ignoring types other than
&'static strandString. - TokenTreeExperimental
Traits
- Helper to wrap associated types to allow trait impl dispatch. That is, normally a pair of impls for
T::FooandT::Barcan overlap, but if the impls are, instead, on types likeMarked<T::Foo, Foo>andMarked<T::Bar, Bar>, they can’t. - Unwrap types wrapped by
Mark::mark(seeMarkfor details).