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_hash
crate, adapted to work as a module. - Server-side handles and storage for per-handle data.
- Serialization for client-server communication.
Cell
variant for (scoped) existential lifetimes.- Abstraction for creating
fn
pointers from any callable that effectively has the equivalent of implementingDefault
, even if the compiler neither providesDefault
nor allows reifying closures (i.e. creatingfn
pointers) 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_server
inserver.rs
), then passes it to the client through the function pointer in therun
field ofclient::Client
. The client constructs a localBridge
from 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 str
andString
. - TokenTreeExperimental
Traits
- Helper to wrap associated types to allow trait impl dispatch. That is, normally a pair of impls for
T::Foo
andT::Bar
can 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
(seeMark
for details).