pub struct Spanned {
pub span: Span,
pub form: SpannedForm,
}Expand description
An S-expression node with source position.
Fields§
§span: Span§form: SpannedFormImplementations§
Source§impl Spanned
impl Spanned
pub fn new(span: Span, form: SpannedForm) -> Spanned
Sourcepub fn synthetic_nil() -> Spanned
pub fn synthetic_nil() -> Spanned
Synthetic nil — useful as a placeholder in macro expansion when no real span is available.
Sourcepub fn from_sexp_synthetic(s: &Sexp) -> Spanned
pub fn from_sexp_synthetic(s: &Sexp) -> Spanned
Lift a plain Sexp to a Spanned with every node marked synthetic.
Useful when a macro template generates literal structure that has no
user-source origin.
Sourcepub fn from_sexp_at(s: &Sexp, span: Span) -> Spanned
pub fn from_sexp_at(s: &Sexp, span: Span) -> Spanned
Lift a plain Sexp to a Spanned with every node assigned the given
span. Used by the expander to stamp macro-generated subtrees with
the call-site span so errors point somewhere useful.
pub fn is_list(&self) -> bool
pub fn as_list(&self) -> Option<&[Spanned]>
pub fn as_symbol(&self) -> Option<&str>
pub fn as_keyword(&self) -> Option<&str>
pub fn as_string(&self) -> Option<&str>
pub fn as_int(&self) -> Option<i64>
Trait Implementations§
Source§impl MacroArgCarrier for Spanned
impl MacroArgCarrier for Spanned
Source§type Site = Span
type Site = Span
The macro CALL SITE. A value the call never supplied — an unfilled
&optional slot’s default form, or the synthesized &rest list —
has no source position of its own, so it wears the span of the call
that caused it to exist. That is the position an error about such a
value should point at.