Let the compiler hold the invariant a rejected access is not public - #429
Open
petrovo-as wants to merge 1 commit into
Open
Let the compiler hold the invariant a rejected access is not public#429petrovo-as wants to merge 1 commit into
petrovo-as wants to merge 1 commit into
Conversation
|
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
`Rejection` carried a `Visibility`, which has three values, but only ever holds one of two: the check settles a public member and returns before a rejection is built. The third value was therefore reachable in the type and not in the program, leaving three `match` arms behind for a state that cannot arise — one of them spelling a message that would have been wrong had it ever run. Give the struct a `Restriction` of `Private` or `Protected` instead. The single conversion sits where the public early-return already was, so the one public path stays and the impossible arms go. No change in behaviour. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
petrovo-as
force-pushed
the
fix/member-visibility-rejection-type
branch
from
September 8, 2026 14:40
91067d1 to
b3f7176
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Note
I am not a Rust developer. This follow-up to #380 was written with AI assistance and reviewed line by line before opening.
The problem
Rejectioninmember_visibility.rscarries aVisibility, which has three values. It can only ever hold two of them:judge_branchsettles a public member and returns before any rejection is built. The third value is reachable in the type but not in the program, so threematcharms exist for a state that cannot arise — including one inbuild_messagethat would produce a wrong message had it ever run.The change
Rejectionnow carries a two-valuedRestriction(PrivateorProtected). The single conversion point is the public early-return that was already there, so the one public path is kept and the impossible arms are gone.No behaviour change. It also removes the arms Codecov flagged as uncovered on #380, though that is a side effect rather than the point.
Testing
cargo clippy --all-targets -- -D warnings,cargo fmt --check, and themember_visibilitysuite pass unchanged. No test was modified — an unchanged suite is the evidence that behaviour is the same.No changelog entry: internal refactor with nothing observable for users.
Checklist
If applicable:
CHANGELOG.md(internal refactor, nothing observable)README.md,docs/,examples/)config-schema.json)how it works, how it's organized), including any code drafted by an LLM.
an eye towards deleting anything that is irrelevant, clarifying anything
that is confusing, and adding details that are relevant. This includes,
for example, commit descriptions, PR descriptions, and code comments.
🤖 Generated with Claude Code