Skip to content

chore(lint): enable clippy::panic_in_result_fn - #96

Merged
tupe12334 merged 2 commits into
mainfrom
clippy/enable-panic_in_result_fn
Jul 27, 2026
Merged

chore(lint): enable clippy::panic_in_result_fn#96
tupe12334 merged 2 commits into
mainfrom
clippy/enable-panic_in_result_fn

Conversation

@tupe12334

Copy link
Copy Markdown
Member

Summary

Enable the clippy::panic_in_result_fn restriction lint, which flags panic!, todo!, unimplemented!, and unreachable! calls inside functions that return Result or Option.

Why

When a function's return type already models fallibility, an internal panic bypasses structured error propagation — the process crashes instead of returning Err(_)/None for the caller to handle. This lint enforces the invariant that Result/Option-returning functions stay within the type system's error-handling contract.

What changed

Added to [lints.clippy] in Cargo.toml:

# Prevent panic!/todo!/unimplemented!/unreachable! inside Result/Option-returning
# functions. When a function already signals fallibility via its return type,
# an internal panic bypasses structured error propagation and crashes the
# process instead of returning Err(_)/None for the caller to handle.
panic_in_result_fn = "deny"

The codebase has zero violations today — this commit locks in that clean state and prevents future regressions.

Verification

cargo clippy --all-targets passes with no warnings or errors. Pre-push hook (clippy + build + 100% coverage) also passed.

Closes #95


This pull request was opened by the Clippy lint improvements → issue + PR (Rust repos) → Slack routine of moadim. CC @tupe12334

Deny panic!/todo!/unimplemented!/unreachable! inside functions that return
Result or Option. When a function's return type already models failure,
an internal panic bypasses structured error propagation and crashes the
process instead of returning Err(_)/None for callers to handle.

The codebase has zero violations today; this commit locks in that clean
state and prevents future regressions.

Closes #95
@tupe12334

Copy link
Copy Markdown
Member Author

Resolved merge conflict against main via manual-merge-both-kept (this PR's panic_in_result_fn lint had already landed via a sibling PR, so the merge keeps main's version alongside the expect_used lint from another sibling — no functional change).

Posted by the moadim routine "Resolve conflicts on code-quality PRs (non-guiddeco)".

@tupe12334
tupe12334 merged commit 0130d70 into main Jul 27, 2026
1 check passed
@tupe12334
tupe12334 deleted the clippy/enable-panic_in_result_fn branch July 27, 2026 09:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Enable clippy::panic_in_result_fn lint

1 participant