Module util

Source

Structs§

ExprToSpannedString 🔒

Functions§

check_builtin_macro_attribute 🔒
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).
expr_to_spanned_string 🔒
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.
get_single_expr_from_tts 🔒
Interpreting tts as a comma-separated sequence of expressions, expect exactly one expression, or emit an error and return Err.
get_single_str_from_tts 🔒
Interpreting tts as a comma-separated sequence of expressions, expect exactly one string literal, or emit an error and return Err.
get_single_str_spanned_from_tts 🔒
parse_expr 🔒
Parse an expression. On error, emit it, advancing to Eof, and return Err.
warn_on_duplicate_attribute 🔒
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§

ExprToSpannedStringResult 🔒
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.