Skip to content

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

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

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