Crate rustc_span

Source
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.
CachingSourceMapView
CharPos
A character offset.
DistinctSources
FileLines
FileNameDisplay
InnerSpan
Range inside of a Span used for diagnostics when we only have access to relative positions.
LineInfo
Loc
A source code location used for error reporting.
MalformedSourceMapPositions
MultiByteChar
Identifies an offset of a multi-byte character in a SourceFile.
NormalizedPos
Identifies an offset of a character that was normalized away from SourceFile.
OffsetOverflowError
SourceFile
A single source in the SourceMap.
SourceFileAndBytePos
SourceFileAndLine
SourceFileHash
The hash of the on-disk source file used for debug info.
Span
A compressed span.
SpanData
Represents a span.

Enums§

ExternalSource
ExternalSourceKind
The state of the lazy external source loading mechanism of a SourceFile.
FileName
Differentiates between real files and common virtual files.
FileNameDisplayPreference
NonNarrowChar
Identifies an offset of a non-narrow character in a SourceFile.
RealFileName
SourceFileHashAlgorithm
SpanLinesError
SpanSnippetError

Constants§

DUMMY_SP
Dummy span, both position and length are zero, syntax context is zero as well.

Traits§

Pos

Type Aliases§

FileLinesResult