Module rustc_builtin_macros::util

source ยท

Functionsยง

  • check_zero_tts ๐Ÿ”’
    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.
  • expr_to_string ๐Ÿ”’
    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.
  • get_exprs_from_tts ๐Ÿ”’
    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_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").
  • UnexpectedExprKind ๐Ÿ”’
    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.