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

  • api_tags 🔒 Experimental
  • arena 🔒 Experimental
    A minimal arena allocator inspired by rustc_arena::DroplessArena.
  • buffer 🔒 Experimental
    Buffer management for same-process client<->server communication.
  • clientExperimental
    Client-side types.
  • closure 🔒 Experimental
    Closure type (equivalent to &mut dyn FnMut(A) -> R) that’s repr(C).
  • fxhash 🔒 Experimental
    This is a copy of the rustc_hash crate, adapted to work as a module.
  • handle 🔒 Experimental
    Server-side handles and storage for per-handle data.
  • rpc 🔒 Experimental
    Serialization for client-server communication.
  • scoped_cell 🔒 Experimental
    Cell variant for (scoped) existential lifetimes.
  • selfless_reify 🔒 Experimental
    Abstraction for creating fn pointers from any callable that effectively has the equivalent of implementing Default, even if the compiler neither provides Default nor allows reifying closures (i.e. creating fn pointers) other than those with absolutely no captures.
  • serverExperimental
    Server-side traits.
  • symbol 🔒 Experimental
    Client-side interner used for symbols.

Macros

Structs

  • BridgeConfigExperimental
    Configuration for establishing an active connection between a server and a client. The server creates the bridge config (run_server in server.rs), then passes it to the client through the function pointer in the run field of client::Client. The client constructs a local Bridge from the config in TLS during its execution (Bridge::{enter, with} in client.rs).
  • DelimSpanExperimental
  • DiagnosticExperimental
  • ExpnGlobalsExperimental
    Globals provided alongside the initial inputs for a macro expansion. Provides values such as spans which are used frequently to avoid RPC.
  • GroupExperimental
  • IdentExperimental
  • LiteralExperimental
  • Marked 🔒 Experimental
  • PunctExperimental

Enums

  • LitKindExperimental
  • PanicMessageExperimental
    Simplified version of panic payloads, ignoring types other than &'static str and String.
  • TokenTreeExperimental

Traits

  • Mark 🔒 Experimental
    Helper to wrap associated types to allow trait impl dispatch. That is, normally a pair of impls for T::Foo and T::Bar can overlap, but if the impls are, instead, on types like Marked<T::Foo, Foo> and Marked<T::Bar, Bar>, they can’t.
  • Unmark 🔒 Experimental
    Unwrap types wrapped by Mark::mark (see Mark for details).