Skip to content

Reduce panic surface: unwrap/expect debt flagged by hypatia (baselined 2026-07-27) #145

Closed

Description

@hyperpolymath

Hypatia's code_safety module flags these; each is baselined with a 3-month expiry rather than fixed, because each is either infallible-by-construction or deliberate internal-invariant style. Revisit before 2026-10-27:

  • crates/my-fmt/src/lib.rs — 26× write!(self.output, …).unwrap() where output is String: fmt::Write to String is infallible. Consider a small w! macro or let _ = to make that explicit.
  • crates/my-llvm/src/lib.rs — 3× unwrap() on get_nth_param/node_weight with indices obtained from the same structure being indexed. Convert to expect("MIR invariant: …") when the crate is next compiled against system LLVM.
  • crates/my-lang/src/parser.rs — flagged "expect() in hot path (157×)" but the sites are the parser's own self.expect(TokenKind)? Result-returning method, not Option/Result::expect panics. Scanner false positive worth an upstream hypatia rule fix (name-collision on expect).
  • crates/my-mir/src/lib.rs — 5× expect("internal error: …") invariant style on petgraph lookups.
  • crates/my-lang/lib/common/string.rs — 1× expect with a totality proof in the message (from_digit on num % radix).
  • crates/my-lang/examples/measure_depth.rs — 2× expect in a probe example binary; panics acceptable.

Fixed at source in the same triage (NOT baselined): my-hir arg unwrap (match rewrite), my-lint 2× empty-name panics (is_some_and), my-llvm SAFETY-comment adjacency, the .hypatia-ignore self-referential secret-shape critical, and 5 stale-directory doc refs.

🤖 Generated with Claude Code

Activity

  1. hyperpolymath commented on Aug 12, 2026

    @hyperpolymath
    OwnerAuthor

    PUNTED to code maintenance backlog. Issue describes legitimate unwrap/expect debt in my-lang codebase that requires manual code review and refactoring. Each flagged instance is documented in the issue body with rationale. Current status: some instances are infallible-by-construction (e.g., fmt::Write to String), others are internal invariants (e.g., MIR node indexing). Revisit and fix at source when prioritized. Baseline expires 2026-10-27 per original triage.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions