Skip to main content

DiagnosticCode

Enum DiagnosticCode 

Source
pub enum DiagnosticCode {
Show 26 variants UnsupportedDirective, InvalidFieldCount, InvalidMonth, AmbiguousNameAbbreviation, InvalidDayRule, InvalidTimeSuffix, UnsupportedYearType, OutputPathTraversal, TooManyTransitions, UnsupportedLeapSeconds, ReferenceZicMismatch, InvalidValue, UnknownLineType, ContinuationWithoutZone, DuplicateZone, NulByteInInput, OverlongInputLine, AbbreviationPolicyViolation, AbbreviationNotPosix, TooManyTransitionsForLegacyClient, UnterminatedInputLine, UnterminatedQuote, SimultaneousTransition, ZoneNameNonPortableByte, ZoneNameOverlengthComponent, ValueOverTwentyFourHours,
}
Expand description

Stable diagnostic codes.

Numbering follows the project’s documented scheme; gaps are reserved for future use so existing codes never shift meaning.

Variants§

§

UnsupportedDirective

A directive/keyword we do not implement in this version.

§

InvalidFieldCount

A line had the wrong number of fields for its record type.

§

InvalidMonth

A month name was unrecognised or ambiguously abbreviated.

§

AmbiguousNameAbbreviation

A name abbreviation matched more than one keyword.

§

InvalidDayRule

An ON day specification was malformed.

§

InvalidTimeSuffix

An AT/SAVE time had an invalid suffix.

§

UnsupportedYearType

A FROM/TO year keyword we do not implement.

§

OutputPathTraversal

A zone/link name (or its output path) would escape the output root.

§

TooManyTransitions

A zone produced more transitions than the configured limit.

§

UnsupportedLeapSeconds

Leap-second input was supplied but is not implemented.

§

ReferenceZicMismatch

Our output disagreed with reference zic.

§

InvalidValue

A field value was syntactically invalid (offset, name, etc.).

§

UnknownLineType

A line in command position began with a token that is not a recognised record keyword (Rule/Zone/Link). Lexical layer; reference zic reports “input line of unknown type”. Distinct from UnsupportedDirective, which is a recognised construct zic-rs deliberately does not compile (a safety/scope divergence, T13.1).

§

ContinuationWithoutZone

An indented (continuation-shaped) line appeared where no zone is open to continue. Structural layer. zic-rs classifies this more precisely than reference zic (which folds it into “input line of unknown type”) — a documented, intentional refinement, not a wording mismatch.

§

DuplicateZone

A second Zone was defined with a name already in use. Structural layer; carries the conflicting name and the original definition’s line (mirrors reference zic’s “duplicate zone name N”).

§

NulByteInInput

The input contained a NUL byte (lexical/admissibility). Reference zic: “NUL input byte”.

§

OverlongInputLine

A source line exceeded the byte-length cap (lexical/admissibility). The cap (MAX_LINE_LEN) was reconciled against reference zic in T14.1 and matches its _POSIX2_LINE_MAX = 2048 (the older “511” manpage figure is stale — verified against the pinned 2026b source).

§

AbbreviationPolicyViolation

A time-zone abbreviation’s length is outside the portable range (tzfile(5): 3–6 characters) — fewer than 3 or more than 6 — a non-fatal warning (the file still compiles). Mirrors reference zic’s always-on “time zone abbreviation has too many characters (X)” / “…has fewer than 3 characters (X)” (thresholds pinned empirically against tzcode 2026b). The first non-fatal warning class (T13.3); the < 3 side was added in T13.4.

§

AbbreviationNotPosix

A time-zone abbreviation contains a character outside the POSIX-portable set (only ASCII alphanumerics and +/-), a non-fatal warning. Mirrors reference zic’s “time zone abbreviation differs from POSIX standard (X)” (T13.4). A distinct rule from the length policy (AbbreviationPolicyViolation) — both can fire for one abbreviation. (Case is not a violation: lowercase letters are alphanumeric and accepted.)

§

TooManyTransitionsForLegacyClient

The emitted transition count exceeds a client-compatibility threshold (an emitted-stream warning, -v/verbose-only in reference zic). Pinned from zic.c: 1200 < timecnt → “pre-2014 clients may mishandle more than 1200 transition times”, TZ_MAX_TIMES < timecnt → “reference clients mishandle …”. Reserved class (T13.5): the code + reference rule are recorded; emission is wired in T13.6 (gated by the verbosity model), since it depends on the finished timecnt and must be quiet-by-default to match reference.

§

UnterminatedInputLine

The final input line has content but no terminating newline (lexical/admissibility). Mirrors reference zic’s inputline: at EOF with linelen > 0 it reports “unterminated line” and exits. A POSIX text file ends every line with \n; zic-rs was previously lenient here (accepted the trailing partial line) — T14.2 makes it fail closed, matching reference. The class name is the rule violated, not the wording (“unterminated line”).

§

UnterminatedQuote

A double-quoted field is opened but never closed before end-of-line (lexical/admissibility). Mirrors reference zic’s getfields, which hits the line’s terminating \0 inside a quote and reports “Odd number of quotation marks”, then exits. zic-rs already failed closed here but under the generic InvalidValue (ZIC012); T14.2 gives it a dedicated class.

§

SimultaneousTransition

Two rules expand to a transition at the same instant (semantic). Mirrors reference zic’s “two rules for same instant”, which it treats as a fatal error (errors=true → exit 1). zic-rs fails closed with this code rather than emitting a non-monotonic (invalid) TZif — a same-instant rule conflict is not silently resolved. Surfaced by the T14.4 pathology ledger, which found that the prior debug_assert! would panic in debug / emit an invalid stream in release.

§

ZoneNameNonPortableByte

A zone/link name (which becomes an output path) contains a byte outside the portable benign set (-, _, ASCII letters, and / as the separator) — e.g. a digit, +, ., or a high/control byte. A non-fatal warning mirroring reference zic’s -v-gated “file name ‘%s’ contains byte ‘…’” (namecheck). The hard structural path rules (absolute · .. · // · empty · trailing /) are fatal OutputPathTraversal; this is the softer portability axis (T14.5). zic-rs has no quiet mode → collects always; surfaced only under --verbose.

§

ZoneNameOverlengthComponent

A single component of a zone/link name exceeds the portable length (reference zic’s component_len_max = 14). A non-fatal warning mirroring zic’s -v-gated “file name ‘%s’ contains overlength component” (componentcheck); the file still compiles (T14.5).

§

ValueOverTwentyFourHours

A parsed time value (a STDOFF / SAVE / AT / UNTIL field) has a magnitude strictly greater than 24:00:00. A non-fatal warning mirroring reference zic’s noise/-v-gated gethms check (zic.c: hh > HOURSPERDAY || (hh == HOURSPERDAY && (mm||ss)) → “values over 24 hours not handled by pre-2007 versions of zic”). Exactly 24:00:00 does not warn; the file still compiles. zic-rs has no quiet mode → collects always; surfaced only under --verbose (T15.5-remainder; closes the T14.4 ledger residual).

Implementations§

Source§

impl DiagnosticCode

Source

pub fn as_str(self) -> &'static str

The stable string form, e.g. ZIC001_UNSUPPORTED_DIRECTIVE.

Source

pub fn layer(self) -> DiagnosticLayer

The DiagnosticLayer this code belongs to (T13.5 — the comparison method’s first axis). The match is exhaustive, so adding a code without classifying it is a compile error — the taxonomy stays in lock-step with docs/zic-warning-parity.md.

Source

pub fn span_precision(self) -> DiagnosticSpanPrecision

The DiagnosticSpanPrecision this code currently populates (T13.5 audit, made machine-checked in T13.6). Exhaustive — a new code must declare its precision or the build fails. Records the current level, not a perfection claim (exact token columns are a future refinement for several Line classes).

Source

pub fn default_severity(self) -> Severity

The canonical severity of this code (T13.6 — completes the per-code contract metadata so every code carries (layer, span_precision, default_severity); exhaustive → adding a code forces a classification). The three non-fatal abbreviation/transition warnings are Warning; every other code is a fail-closed Error. Canonical, not absolute: the warn-and-skip policy may downgrade an emitted error-diagnostic to Warning at the instance level (see plan::run), and verbosity is the one genuinely per-instance axis (a Diagnostic cannot be constructed without a severity and a verbosity, so those are type-enforced on every instance — see Diagnostic).

Trait Implementations§

Source§

impl Clone for DiagnosticCode

Source§

fn clone(&self) -> DiagnosticCode

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Copy for DiagnosticCode

Source§

impl Debug for DiagnosticCode

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Display for DiagnosticCode

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Eq for DiagnosticCode

Source§

impl PartialEq for DiagnosticCode

Source§

fn eq(&self, other: &DiagnosticCode) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl StructuralPartialEq for DiagnosticCode

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.