marianoguerra/css/kind does not have a README file

    ErrorKind

    pub(all) enum ErrorKind {
    UnexpectedEof
    UnterminatedString
    UnterminatedComment
    UnterminatedUrl
    BadUrl
    UnexpectedCloser(String)
    UnclosedBlock(String)
    BadSelector
    DanglingCombinator
    BadAttributeSelector
    BadPseudoClass(String)
    BadAnB
    ExpectedColon
    EmptyValue
    ImportantNotLast
    BadBang
    BadDeclaration
    BadAtRuleShape(String)
    UnknownAtRule(String)
    BadAtRulePrelude(String)
    BadMediaQuery
    BadSupportsCondition
    MixedLogicalOps
    BadKeyframeSelector
    DeclarationAtTopLevel
    RuleInDeclarationContext
    Unexpected(String)
    } derive(Eq,
    Debug
    )

    What went wrong, as a closed set.

    This package has no dependencies at all, and that is deliberate: the AST stores a kind on every Bogus node, so if kinds lived beside the Diagnostic that renders them, building a tree would link the diagnostic library. Splitting the name of a problem from the reporting of one is what keeps ast and write free of error-report.

    The set is closed rather than a string because a consumer is expected to match on it -- an editor deciding which quick fix to offer, a harness deciding whether a corpus file is expected to fail. A string would make every such decision a spelling comparison.

    ErrorKind::code

    fn ErrorKind::code(self : ErrorKind) -> String

    A stable identifier for this kind.

    Stable is the whole point: it goes in error[...] headers, in JSON output and in a harness's expectations, so it must not change when the prose does. That is why it is written out rather than derived from the variant name -- renaming a variant is then a local edit, not a silent break of everything downstream that matched on the string.

    ErrorKind::is_warning

    fn ErrorKind::is_warning(self : ErrorKind) -> Bool

    Whether this kind is a hard error or something a tolerant parse may carry.

    The distinction is what makes strict mode meaningful: strict fails on the first Error, and an UnknownAtRule is deliberately not one -- CSS grows new at-rules faster than any parser learns them, so refusing an unknown one would make the library wrong every time the language moves.

    Source Files