Skip to content

Let the compiler hold the invariant a rejected access is not public - #429

Open
petrovo-as wants to merge 1 commit into
PHPantom-dev:mainfrom
petrovo-as:fix/member-visibility-rejection-type
Open

Let the compiler hold the invariant a rejected access is not public#429
petrovo-as wants to merge 1 commit into
PHPantom-dev:mainfrom
petrovo-as:fix/member-visibility-rejection-type

Conversation

@petrovo-as

@petrovo-as petrovo-as commented Sep 8, 2026

Copy link
Copy Markdown
Contributor

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

Rejection in member_visibility.rs carries a Visibility, which has three values. It can only ever hold two of them: judge_branch settles a public member and returns before any rejection is built. The third value is reachable in the type but not in the program, so three match arms exist for a state that cannot arise — including one in build_message that would produce a wrong message had it ever run.

The change

Rejection now carries a two-valued Restriction (Private or Protected). 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 the member_visibility suite 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:

  • I have updated CHANGELOG.md (internal refactor, nothing observable)
  • I have updated the documentation (README.md, docs/, examples/)
  • I have updated the config schema (config-schema.json)
  • I have added/updated tests to cover my changes (behaviour is unchanged; the existing suite passing unmodified is the check)
  • I fully understand the code that I am submitting (what it does,
    how it works, how it's organized), including any code drafted by an LLM.
  • For any prose generated by an LLM, I have proof-read and copy-edited with
    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

@codecov-commenter

Copy link
Copy Markdown

⚠️ Please install the 'codecov app svg image' to ensure uploads and comments are reliably processed by Codecov.

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
petrovo-as force-pushed the fix/member-visibility-rejection-type branch from 91067d1 to b3f7176 Compare September 8, 2026 14:40
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.

2 participants