pub struct Spanned<T> {
pub node: T,
pub line: SourceLine,
pub ty: OnceLock<Type>,
}Expand description
AST node with source location plus an optional inferred type.
Line-agnostic equality: two Spanned values are equal iff their inner
nodes are equal, regardless of line or attached type. The type slot is a
OnceLock<Type> populated by the type checker; backends that have not
been migrated to consume it stay agnostic and continue inferring locally.
OnceLock (rather than OnceCell) keeps Spanned Sync, which matters
because parts of the AST live behind Arc and cross thread boundaries
(e.g. parallel verify execution, REPL background tasks).
Fields§
§node: T§line: SourceLine§ty: OnceLock<Type>Implementations§
Source§impl<T> Spanned<T>
impl<T> Spanned<T>
pub fn new(node: T, line: SourceLine) -> Self
Sourcepub fn bare(node: T) -> Self
pub fn bare(node: T) -> Self
Create a Spanned with line=0 (synthetic/generated AST, no source location).
Trait Implementations§
Auto Trait Implementations§
impl<T> !Freeze for Spanned<T>
impl<T> RefUnwindSafe for Spanned<T>where
T: RefUnwindSafe,
impl<T> Send for Spanned<T>where
T: Send,
impl<T> Sync for Spanned<T>where
T: Sync,
impl<T> Unpin for Spanned<T>where
T: Unpin,
impl<T> UnsafeUnpin for Spanned<T>where
T: UnsafeUnpin,
impl<T> UnwindSafe for Spanned<T>where
T: UnwindSafe,
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more