Expand description
Source positions and related helper functions.
Important concepts in this module include:
- the span, represented by
SpanData
and related types; - source code as represented by a
SourceMap
; and - interned strings, represented by [
Symbol
]s, with some common symbols available statically in the [sym
] module.
Unlike most compilers, the span contains not only the position in the source code, but also various other metadata,
such as the edition and macro hygiene. This metadata is stored in [SyntaxContext
] and [ExpnData
].
§Note
This API is completely unstable and subject to change.
Re-exports§
pub use source_map::SourceMap;
Modules§
- fatal_
error - source_
map - Types for tracking pieces of source code within a crate.
Structs§
- BytePos
- A byte offset.
- Caching
Source MapView - CharPos
- A character offset.
- Distinct
Sources - File
Lines - File
Name Display - Inner
Span - Range inside of a
Span
used for diagnostics when we only have access to relative positions. - Line
Info - Loc
- A source code location used for error reporting.
- Malformed
Source MapPositions - Multi
Byte Char - Identifies an offset of a multi-byte character in a
SourceFile
. - Normalized
Pos - Identifies an offset of a character that was normalized away from
SourceFile
. - Offset
Overflow Error - Source
File - A single source in the
SourceMap
. - Source
File AndByte Pos - Source
File AndLine - Source
File Hash - The hash of the on-disk source file used for debug info.
- Span
- A compressed span.
- Span
Data - Represents a span.
Enums§
- External
Source - External
Source Kind - The state of the lazy external source loading mechanism of a
SourceFile
. - File
Name - Differentiates between real files and common virtual files.
- File
Name Display Preference - NonNarrow
Char - Identifies an offset of a non-narrow character in a
SourceFile
. - Real
File Name - Source
File Hash Algorithm - Span
Lines Error - Span
Snippet Error
Constants§
- DUMMY_
SP - Dummy span, both position and length are zero, syntax context is zero as well.