Crate rustc_span[−][src]

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 Symbols, 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 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;

Modules

Machinery for hygienic macros.

Levenshtein distances.

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.

Functionality for ordering and comparison.

Utilities for formatting and printing Strings.

Macros

Constructs an event at the debug level.

Derive macro generating an impl of the trait Hash.

Structs

This is essentially an AtomicPtr but is guaranteed to always be valid

A byte offset.

A character offset.

Range inside of a Span used for diagnostics when we only have access to relative positions.

A source code location used for error reporting.

The MD5 hasher

Identifies an offset of a multi-byte character in a SourceFile.

A collection of Spans.

Identifies an offset of a character that was normalized away from SourceFile.

Structure representing the state of a SHA-1 computation

The SHA-256 hash algorithm with the SHA-256 initial hash value.

A single source in the SourceMap.

The hash of the on-disk source file used for debug info.

A compressed span.

Represents a span.

A span together with some additional data.

When hashing something that ends up affecting properties like symbol names, we want these symbol names to be calculated independently of other factors like what architecture you’re compiling from.

A single-threaded reference-counting pointer. ‘Rc’ stands for ‘Reference Counted’.

A slice of a path (akin to str).

An owned, mutable path (akin to String).

A (half-open) range bounded inclusively below and exclusively above (start..end).

Enums

The state of the lazy external source loading mechanism of a SourceFile.

Differentiates between real files and common virtual files.

Identifies an offset of a non-narrow character in a SourceFile.

A clone-on-write smart pointer.

An Ordering is the result of a comparison between two values.

Constants

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

Statics

Traits

Trait for types that can be deserialized

The Digest trait specifies an interface common for digest functions.

Trait for types that can be serialized

Something that implements HashStable<CTX> can be hashed in a way that is stable across multiple compilation sessions.

Requirements for a StableHashingContext to be used in this crate.

The addition operator +.

Parse a value from a string

A hashable type.

The subtraction operator -.

Functions

Replaces \r\n with \n in-place in src.

Normalizes the source code and records the normalizations.

Removes UTF-8 BOM, if any.

Calls the provided closure, using the provided SourceMap to format any spans that are debug-printed during the closure’s execution.

Type Definitions

Derive Macros