Source positions and related helper functions.
Important concepts in this module include:
- the span, represented by
SpanDataand related types;
- source code as represented by a
- interned strings, represented by
Symbols, with some common symbols available statically in the
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
This API is completely unstable and subject to change.
pub use hygiene::DesugaringKind;
pub use hygiene::ExpnKind;
pub use hygiene::MacroKind;
pub use hygiene::ExpnData;
pub use hygiene::ExpnHash;
pub use hygiene::ExpnId;
pub use hygiene::LocalExpnId;
pub use hygiene::SyntaxContext;
pub use symbol::sym;
pub use symbol::Symbol;
- Edit distances.
- Machinery for hygienic macros.
- Types for tracking pieces of source code within a crate.
- An “interner” is a data structure that associates values with usize tags and allows bidirectional lookup; i.e., given a value, one can easily find the type, and vice versa.
- impl_pos 🔒
- A byte offset.
- A character offset.
- Useful type to use with
Result<>indicate that an error has already been reported to the user, so no need to continue checking.
- Range inside of a
Spanused for diagnostics when we only have access to relative positions.
- A source code location used for error reporting.
- Identifies an offset of a multi-byte character in a
- Identifies an offset of a character that was normalized away from
- A byte offset relative to file beginning.
- Per-session global variables: this struct is stored in thread-local storage in such a way that it is accessible without any kind of handle to all threads within the compilation session, but is not accessible outside the session.
- A single source in the
- The source file lines in difference list form. This matches the form used within metadata, which saves space by exploiting the fact that the lines list is sorted and individual lines are usually not that long.
- The hash of the on-disk source file used for debug info.
- A compressed span.
- Represents a span.
- This is a SourceFile identifier that is used to correlate source files between subsequent compilation sessions (which is something we need to do during incremental compilation).
- The state of the lazy external source loading mechanism of a
- Differentiates between real files and common virtual files.
- Identifies an offset of a non-narrow character in a
- The dummy span has zero position, length, and context, and no parent.
- Requirements for a
StableHashingContextto be used in this crate.
- This trait is used to allow decoder specific encodings of certain types. It is similar to rustc_type_ir’s TyDecoder.
- This trait is used to allow encoder specific encodings of certain types. It is similar to rustc_type_ir’s TyEncoder.
- Normalizes the source code and records the normalizations.
- Removes UTF-8 BOM, if any.
source_mapinto the session globals for the duration of the closure’s execution.