Module rustc_expand::base

source ·

Macros§

Structs§

  • Fill-in macro expansion result, to allow compilation to continue after hitting errors.
  • One of these is made during expansion and incrementally updated as we go; when a macro expansion occurs, the resulting nodes have the backtrace() -> expn_data of their expansion context stored into their span.
  • Error type that denotes indeterminacy.
  • MacResult implementation for the common case where you’ve already built each form of AST that you might return.
  • A struct representing a macro definition in “lowered” form ready for expansion.

Enums§

Traits§

Functions§

  • Non-fatally assert that tts is empty. Note that this function returns even when tts is non-empty, macros that need to stop compilation should call cx.diagnostic().abort_if_errors() (this should be done as rarely as possible).
  • Extracts a string literal from the macro expanded version of expr, returning a diagnostic error of err_msg if expr is not a string literal. The returned bool indicates whether an applicable suggestion has already been added to the diagnostic to avoid emitting multiple suggestions. Err(Err(ErrorGuaranteed)) indicates that an ast error was encountered.
  • Extracts a string literal from the macro expanded version of expr, emitting err_msg if expr is not a string literal. This does not stop compilation on error, merely emits a non-fatal error and returns Err.
  • Extracts comma-separated expressions from tts. On error, emit it, and return Err.
  • Interpreting tts as a comma-separated sequence of expressions, expect exactly one string literal, or emit an error and return Err.
  • Parse an expression. On error, emit it, advancing to Eof, and return Err.
  • This nonterminal looks like some specific enums from proc-macro-hack and procedural-masquerade crates. We need to maintain some special pretty-printing behavior for them due to incorrect asserts in old versions of those crates and their wide use in the ecosystem. See issue #73345 for more details. FIXME(#73933): Remove this eventually.
  • Resolves a path mentioned inside Rust code, returning an absolute path.

Type Aliases§