pub enum DiagnosticKind {
Show 68 variants
UnclosedTree,
UnclosedSequence,
UnclosedAlternation,
UnclosedRegex,
ExpectedExpression,
ExpectedTypeName,
ExpectedCaptureName,
ExpectedFieldName,
ExpectedSubtype,
ExpectedPredicateValue,
EmptyTree,
EmptyAnonymousNode,
EmptySequence,
EmptyAlternation,
BareIdentifier,
InvalidSeparator,
AnchorInAlternation,
InvalidFieldEquals,
InvalidSupertypeSyntax,
InvalidTypeAnnotationSyntax,
ErrorTakesNoArguments,
RefCannotHaveChildren,
ErrorMissingOutsideParens,
UnsupportedPredicate,
UnexpectedToken,
CaptureWithoutTarget,
LowercaseBranchLabel,
CaptureNameHasDots,
CaptureNameHasHyphens,
CaptureNameUppercase,
DefNameLowercase,
DefNameHasSeparators,
BranchLabelHasSeparators,
FieldNameHasDots,
FieldNameHasHyphens,
FieldNameUppercase,
TypeNameInvalidChars,
TreeSitterSequenceSyntax,
NegationSyntaxDeprecated,
DuplicateDefinition,
UndefinedReference,
MixedAltBranches,
RecursionNoEscape,
DirectRecursion,
FieldSequenceValue,
AnchorWithoutContext,
IncompatibleTypes,
MultiCaptureQuantifierNoName,
UnusedBranchLabels,
StrictDimensionalityViolation,
MultiElementScalarCapture,
UncapturedOutputWithCaptures,
AmbiguousUncapturedOutputs,
DuplicateCaptureInScope,
IncompatibleCaptureTypes,
IncompatibleStructShapes,
PredicateOnNonLeaf,
EmptyRegex,
RegexBackreference,
RegexLookaround,
RegexNamedCapture,
RegexSyntaxError,
UnknownNodeType,
UnknownField,
FieldNotOnNodeType,
InvalidFieldChildType,
InvalidChildType,
UnnamedDef,
}Expand description
Diagnostic kinds ordered by priority (highest priority first).
When two diagnostics have overlapping spans, the higher-priority one suppresses the lower-priority one. This prevents cascading error noise.
Priority rationale:
- Unclosed delimiters cause massive cascading errors downstream
- Expected token errors are root causes the user should fix first
- Invalid syntax usage is a specific mistake at a location
- Naming validation errors are convention violations
- Semantic errors assume valid syntax
- Structural observations are often consequences of earlier errors
Variants§
UnclosedTree
UnclosedSequence
UnclosedAlternation
UnclosedRegex
ExpectedExpression
ExpectedTypeName
ExpectedCaptureName
ExpectedFieldName
ExpectedSubtype
ExpectedPredicateValue
EmptyTree
EmptyAnonymousNode
EmptySequence
EmptyAlternation
BareIdentifier
InvalidSeparator
AnchorInAlternation
InvalidFieldEquals
InvalidSupertypeSyntax
InvalidTypeAnnotationSyntax
ErrorTakesNoArguments
RefCannotHaveChildren
ErrorMissingOutsideParens
UnsupportedPredicate
UnexpectedToken
CaptureWithoutTarget
LowercaseBranchLabel
CaptureNameHasDots
CaptureNameHasHyphens
CaptureNameUppercase
DefNameLowercase
DefNameHasSeparators
BranchLabelHasSeparators
FieldNameHasDots
FieldNameHasHyphens
FieldNameUppercase
TypeNameInvalidChars
TreeSitterSequenceSyntax
NegationSyntaxDeprecated
DuplicateDefinition
UndefinedReference
MixedAltBranches
RecursionNoEscape
DirectRecursion
FieldSequenceValue
AnchorWithoutContext
IncompatibleTypes
MultiCaptureQuantifierNoName
UnusedBranchLabels
StrictDimensionalityViolation
MultiElementScalarCapture
UncapturedOutputWithCaptures
AmbiguousUncapturedOutputs
DuplicateCaptureInScope
IncompatibleCaptureTypes
IncompatibleStructShapes
PredicateOnNonLeaf
EmptyRegex
RegexBackreference
RegexLookaround
RegexNamedCapture
RegexSyntaxError
UnknownNodeType
UnknownField
FieldNotOnNodeType
InvalidFieldChildType
InvalidChildType
UnnamedDef
Implementations§
Source§impl DiagnosticKind
impl DiagnosticKind
Sourcepub fn default_severity(&self) -> Severity
pub fn default_severity(&self) -> Severity
Default severity for this kind. Can be overridden by policy.
Sourcepub fn suppresses(&self, other: &DiagnosticKind) -> bool
pub fn suppresses(&self, other: &DiagnosticKind) -> bool
Whether this kind suppresses other when spans overlap.
Uses enum discriminant ordering: lower position = higher priority. A higher-priority diagnostic suppresses lower-priority ones in the same span.
Sourcepub fn is_structural_error(&self) -> bool
pub fn is_structural_error(&self) -> bool
Structural errors are Unclosed* - they cause cascading errors but should be suppressed by root-cause errors at the same position.
Sourcepub fn is_root_cause_error(&self) -> bool
pub fn is_root_cause_error(&self) -> bool
Root cause errors - user omitted something required. These suppress structural errors at the same position.
Sourcepub fn is_consequence_error(&self) -> bool
pub fn is_consequence_error(&self) -> bool
Consequence errors - often caused by earlier parse errors. These get suppressed when any root-cause or structural error exists.
Sourcepub fn default_hint(&self) -> Option<&'static str>
pub fn default_hint(&self) -> Option<&'static str>
Default hint for this kind, automatically included in diagnostics. Call sites can add additional hints for context-specific information.
Sourcepub fn fallback_message(&self) -> &'static str
pub fn fallback_message(&self) -> &'static str
Base message for this diagnostic kind, used when no custom message is provided.
Sourcepub fn custom_message(&self) -> String
pub fn custom_message(&self) -> String
Template for custom messages. Contains {} placeholder for caller-provided detail.
Trait Implementations§
Source§impl Clone for DiagnosticKind
impl Clone for DiagnosticKind
Source§fn clone(&self) -> DiagnosticKind
fn clone(&self) -> DiagnosticKind
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for DiagnosticKind
impl Debug for DiagnosticKind
Source§impl Hash for DiagnosticKind
impl Hash for DiagnosticKind
Source§impl Ord for DiagnosticKind
impl Ord for DiagnosticKind
Source§fn cmp(&self, other: &DiagnosticKind) -> Ordering
fn cmp(&self, other: &DiagnosticKind) -> Ordering
1.21.0 · Source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
Source§impl PartialEq for DiagnosticKind
impl PartialEq for DiagnosticKind
Source§impl PartialOrd for DiagnosticKind
impl PartialOrd for DiagnosticKind
impl Copy for DiagnosticKind
impl Eq for DiagnosticKind
impl StructuralPartialEq for DiagnosticKind
Auto Trait Implementations§
impl Freeze for DiagnosticKind
impl RefUnwindSafe for DiagnosticKind
impl Send for DiagnosticKind
impl Sync for DiagnosticKind
impl Unpin for DiagnosticKind
impl UnwindSafe for DiagnosticKind
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Comparable<K> for Q
impl<Q, K> Comparable<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.