Skip to content

Mark public error enums #[non_exhaustive] before first publish #2454

Closed

Description

@josecelano

Parent EPIC: #1669 (Overhaul: Packages), Pre-publish API checklist.

Goal

Every public error enum with real variants in a workspace crate that will be published on crates.io is marked #[non_exhaustive], so that adding a variant later is not a breaking change. The audit also records derive and placeholder decisions.

Background

ADR 20261005145329 (return Result only for concretely fallible public APIs, from #2435) requires existing public error enums to be #[non_exhaustive] before their first publish. Enums with real variants gain variants as features grow, and without the attribute each new variant breaks downstream exhaustive matches. EPIC #1669 records this as its Pre-publish API checklist, and every workspace package is expected on crates.io within weeks.

Inventory at develop on 2026-10-06, to be confirmed:

  • No item in packages/, console/, or src/ uses #[non_exhaustive].
  • 61 public enums named *Error* (excluding tests and benches), across the root crate (11), tracker-core (10), http-protocol (7), console/tracker-client (6), udp-server (4), udp-core (3), and twelve more packages. Some may not be public API; other error types may lack Error in their name.
  • torrust-tracker-configuration's Error has a never-constructed Infallible variant ("The error for errors that can never happen."), which the handle-errors-in-code rule "Never use Infallible or an empty error enum as a placeholder" asks to evaluate.

Scope

In scope:

  • Inventory public error enums per crate (public reachability and std::error::Error implementations, not names alone).
  • Add #[non_exhaustive] to each one with real variants, and fix the downstream exhaustive matches that the change breaks in other workspace crates.
  • Record per-enum derive decisions (keep only derives every future variant can keep).
  • Evaluate placeholder variants such as configuration::Error::Infallible; removing a never-constructed placeholder variant is in scope, with maintainer approval.
  • Mark the checklist done in EPIC Overhaul: Packages #1669.

Out of scope: #[non_exhaustive] on structs, non-error enums, or variants; changing error semantics or variants (except an approved placeholder removal); publishing and editing Cargo.toml versions.

Plan

  1. Inventory document, reviewed by the maintainer.
  2. Decide whether and how to guard the property (doctest, lint, or checklist only).
  3. Apply the attribute crate by crate, one commit per crate, in dependency order (a crate before its dependents). Per-crate completion is recorded in the step 1 inventory.
  4. Resolve placeholder and derive findings with maintainer approval.
  5. Close the checklist in EPIC Overhaul: Packages #1669.

Note: crates already on crates.io (the root torrust-tracker, torrust-tracker-configuration, torrust-tracker-primitives, torrust-tracker-test-helpers) take a breaking change. This issue edits no versions: the inventory records the required semver-major next publish, and EPIC #1669's Pre-publish API checklist item 4 makes the publish apply it (the tracker application release for the root crate, the per-package publish for the others).

Specification: docs/issues/open/2454-1669-mark-public-error-enums-non-exhaustive/ISSUE.md (spec-only PR #2456).

Activity

  1. self-assigned this
    on Oct 6, 2026
  2. added 12 commits that reference this issue on Oct 7, 2026
  3. 53 remaining items

  4. added 13 commits that reference this issue on Oct 20, 2026
  5. added a commit that references this issue on Oct 21, 2026
  6. added a commit that references this issue on Nov 16, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions