Skip to content

Copy paste bug in crates/jiff/src/error/tz/zic.rs #639

Description

@qarmin

Bug found by AI, validated by me

Full report with more possible problems - jiff_20260804.html

CPY_2 LOW

Description: In crates/jiff/src/error/tz/zic.rs, the Display arm for Error::FailedParseFieldAt writes "failed to parse NAME field", which is an exact copy of the message used for the unrelated Error::FailedParseFieldName variant. FailedParseFieldAt is constructed in crates/jiff/src/tz/zic.rs:388 specifically when parsing a rule's AT field (at_field.parse::<RuleAtP>().context(E::FailedParseFieldAt)?), so its error text should mention the AT field, not NAME. Every other FailedParseField* variant in this enum correctly names its own field (FROM, IN, LETTERS, ON, RULES, SAVE, STDOFF, TO, UNTIL), confirming FailedParseFieldAt was copy-pasted from FailedParseFieldName without updating the field name in the message.

Locations:

crates/jiff/src/error/tz/zic.rs:222-224
  222 |                 FailedParseFieldAt => {
  223 |                     f.write_str("failed to parse `NAME` field")
  224 |                 }
crates/jiff/src/error/tz/zic.rs:243-245
  243 |                 FailedParseFieldName => {
  244 |                     f.write_str("failed to parse `NAME` field")
  245 |                 }

Fix: Change the FailedParseFieldAt arm to reference the AT field instead of NAME:

FailedParseFieldAt => {
    f.write_str("failed to parse `AT` field")
}

FailedParseFieldAt => {
f.write_str("failed to parse `NAME` field")
}

FailedParseFieldName => {
f.write_str("failed to parse `NAME` field")
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions