rustc_builtin_macros

Module util

Source

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 expression, or emit an error 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_expr 🔒
    Parse an expression. On error, emit it, advancing to Eof, and return Err.
  • Emit a warning if the item is annotated with the given attribute. This is used to diagnose when an attribute may have been mistakenly duplicated.

Type Aliases§

  • Ok represents successfully retrieving the string literal at the correct position, e.g., println("abc").
  • Ok is returned when the conversion to a string literal is unsuccessful, but another type of expression is obtained instead.Err is returned when the conversion process fails.