Module syntax::codemapUnstable [-] [+] [src]

The CodeMap tracks all the source code used within a single crate, mapping from integer byte positions to the original source code location. Each bit of source parsed during crate parsing (typically files, in-memory strings, or various bits of macro expansion) cover a continuous range of bytes in the CodeMap and are represented by FileMaps. Byte positions are stored in spans and used pervasively in the compiler. They are absolute positions within the CodeMap, which upon request can be converted to line and column information, source code snippets, etc.

Reexports

pub use self::MacroFormat::*;

Structs

BytePos

A byte offset. Keep this small (currently 32-bits), as AST contains a lot of them.

CharPos

A character offset. Because of multibyte utf8 characters, a byte offset is not equivalent to a character offset. The CodeMap will convert BytePos values to CharPos values as necessary.

CodeMap
DistinctSources
ExpnId
ExpnInfo

Extra information for tracking macro expansion of spans

FileLines
FileMap

A single source in the CodeMap

FileMapAndBytePos
FileMapAndLine
Loc

A source code location used for error reporting

LocWithOpt

A source code location used as the result of lookup_char_pos_adj

MalformedCodemapPositions
MultiByteChar

Identifies an offset of a multi-byte character in a FileMap

NameAndSpan
Span

Spans represent a region of code, used for error reporting. Positions in spans are absolute positions from the beginning of the codemap, not positions relative to FileMaps. Methods on the CodeMap can be used to relate spans back to the original source.

Spanned

Enums

MacroFormat

The syntax with which a macro was invoked.

SpanSnippetError

Constants

COMMAND_LINE_EXPN
COMMAND_LINE_SP
DUMMY_SP
NO_EXPANSION

Traits

Pos

Functions

dummy_spanned
mk_sp
original_sp

Return the span itself if it doesn't come from a macro expansion, otherwise return the call site span up to the enclosing_sp by following the expn_info chain.

respan
spanned

Type Definitions

FileName