Function clippy_utils::source::snippet_with_context
source · pub fn snippet_with_context<'a>(
cx: &impl LintContext,
span: Span,
outer: SyntaxContext,
default: &'a str,
applicability: &mut Applicability
) -> (Cow<'a, str>, bool)
Expand description
Same as snippet_with_applicability
, but first walks the span up to the given context. This
will result in the macro call, rather than the expansion, if the span is from a child context.
If the span is not from a child context, it will be used directly instead.
e.g. Given the expression &vec![]
, getting a snippet from the span for vec![]
as a HIR node
would result in box []
. If given the context of the address of expression, this function will
correctly get a snippet of vec![]
.
This will also return whether or not the snippet is a macro call.