rustc_builtin_macros::util

Function expr_to_spanned_string

Source
pub(crate) fn expr_to_spanned_string<'a>(
    cx: &'a mut ExtCtxt<'_>,
    expr: P<Expr>,
    err_msg: &'static str,
) -> ExpandResult<Result<(Symbol, StrStyle, Span), Result<(Diag<'a>, bool), ErrorGuaranteed>>, ()>
Expand description

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.