[src]

Module syntax::codemap

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.

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
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

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
MacroFormat

The syntax with which a macro was invoked.

pub static DUMMY_SP: Span = Span { lo: BytePos(0), hi: BytePos(0), expn_info: None }  
Pos
dummy_spanned
mk_sp
respan
spanned
FileName