pub struct ErrorRef {
pub id: Id,
pub entry: Entry,
}Expand description
A globally unique reference of the syntax error in the syntax tree.
Each syntax tree’s syntax error could be uniquely addressed within a pair of the Id and Entry, where the identifier uniquely addresses a specific compilation unit instance (syntax tree), and the entry part addresses a syntax error within this tree.
Essentially, ErrorRef is a composite index.
Both components of this index form a unique pair (within the current process), because each compilation unit has a unique identifier, and the syntax errors within the syntax tree always receive unique Entry indices within the syntax tree.
If the syntax error instance has been removed from the syntax tree over time, new syntax error within this syntax tree will never occupy the same ErrorRef object, but the ErrorRef referred to the removed SyntaxError would become invalid.
The nil ErrorRefs are special references that are considered to be always invalid (they intentionally don’t refer to any syntax error within any syntax tree).
Two distinct instances of the nil ErrorRef are always equal.
Fields§
§id: IdAn identifier of the syntax tree.
entry: EntryA versioned index of the syntax error instance within the syntax tree.
Implementations§
Source§impl ErrorRef
impl ErrorRef
Sourcepub const fn nil() -> Self
pub const fn nil() -> Self
Returns an ErrorRef that intentionally does not refer to any syntax error within any syntax tree.
If you need just a static reference to the nil ErrorRef, use the predefined NIL_ERROR_REF static.
Sourcepub const fn is_nil(&self) -> bool
pub const fn is_nil(&self) -> bool
Returns true, if the underlying reference intentionally does not refer to any syntax error within any syntax tree.
Sourcepub fn deref<'tree, N: Node>(
&self,
tree: &'tree impl SyntaxTree<Node = N>,
) -> Option<&'tree SyntaxError>
pub fn deref<'tree, N: Node>( &self, tree: &'tree impl SyntaxTree<Node = N>, ) -> Option<&'tree SyntaxError>
Immutably borrows a syntax tree’s syntax error referred to by this ErrorRef.
Returns None if this ErrorRef is not valid for specified tree.
Sourcepub fn is_valid_ref(&self, tree: &impl SyntaxTree) -> bool
pub fn is_valid_ref(&self, tree: &impl SyntaxTree) -> bool
Returns true if the syntax error referred to by this ErrorRef exists in
the specified tree.