pub trait Spanned {
// Required method
fn span(&self) -> Span;
}Expand description
Every AST node must implement this trait.
The trait returns the node’s source Span — the byte-offset range in the
original source file that this node corresponds to. This is a hard
requirement for provenance tracking (R12) and diagnostic quality (every
diagnostic has a non-empty Span pointing to the offending source range,
plan §7.6).
§Contract
span()MUST return the tightest bounding span that covers all tokens belonging to this node.- For nodes that span multiple non-contiguous ranges (e.g., a package spec
with a separate body),
span()returns the primary span (the spec keyword range). Related spans are carried viaSpanLabelin theEvidenceorDiagnostictypes.
Required Methods§
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".