Module clippy_utils::source
source · Expand description
Utils for extracting, inspecting or transforming source code
Structs
Traits
- A type which can be converted to the range portion of a
Span
.
Functions
- Expand a span to include a preceding comma
- Like
snippet_block
, but add braces if the expr is not anExprKind::Block
. - Returns a new Span that extends the original Span to the first non-whitespace char of the first line.
- Gets the source file, and range in the file, of the given span. Returns
None
if the span extends through multiple files, or is malformed. - Returns the indentation of the line of a span
- Extends the span to the beginning of the spans line, incl. whitespaces.
- Returns the position just before rarrow
- Reindent a multiline string with possibility of ignoring the first line.
- Converts a span to a code snippet if available, otherwise returns the default.
- Converts a span (from a block) to a code snippet if available, otherwise use default.
- Same as
snippet_block
, but adapts the applicability level by the rules ofsnippet_with_applicability
. - Gets a snippet of the indentation of the line of a span
- Converts a span to a code snippet. Returns
None
if not available. - Same as
snippet
, but it adapts the applicability level by following rules: - 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. - Trims the whitespace from the start and the end of the span.
- Walks the span up to the target context, thereby returning the macro call site if the span is inside a macro expansion, or the original span if it is not. Note this will return
None
in the case of the span being in a macro expansion, but the target context is from expanding a macro argument. - Removes block comments from the given
Vec
of lines.