Repository navigation
fix(rust): assert_eq!(matches!(..), true) is only as strong as its pattern (#16290) - #16295
Merged
Merged
Conversation
…ttern (#16290) An equality macro that compares a whole matches! with a boolean literal at positive polarity (assert_eq!(matches!(..), true) in either order, assert_ne!(matches!(..), false)) asserts the pattern, but the pattern reading only saw assert!/assert_matches!, so the equality chain read it exact_value / strong even for _ or Some(_). asserted_pattern now takes the pattern operand when RIPR-SPEC-0231 rule 1's polarity reader says Positive; every other comparison stays rule 1's. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_016EQRVmWcuwdH1oVxCdbzvV
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_016EQRVmWcuwdH1oVxCdbzvV
…attern as smoke (#16290) Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_016EQRVmWcuwdH1oVxCdbzvV
EffortlessSteven
marked this pull request as ready for review
November 25, 2026 23:22
…s; honesty case (#16290) Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_016EQRVmWcuwdH1oVxCdbzvV
EffortlessSteven
left a comment
Member
Author
There was a problem hiding this comment.
SOURCE_REVIEW_READY - head 455d073
Source and oracle review of the exact head above.
Inspected:
pattern_admission.rs,asserted_pattern: whenpattern_comparison_polarityreads the line as positive, the wholematches!operand gives its pattern pair, andpattern_assertion_classificationgrades it as it grades theassert!condition. A negative comparison, a non-literal operand and a compound operand get no pattern reading.assert_ne!stays capped by rule 1 whatever the literal.patterns.rs,transparent_operand: it removes edge comments, grouping parentheses and a block holding only the operand, repeating until none is left.pattern_operand_negationsuses it, so polarity and the pattern reader see the same operand. A block with a statement before its tail is refused byunwrap_block(nowpub(super)inbool_operands.rs). The only callers are the polarity reader andasserted_pattern.- Unit rows: weak, smoke and broad rows for both operand orders, parenthesised literals, commented groups and blocks. No-reading rows for a pinned pattern,
false,assert_ne!(.., true), a variable, a commented block compared withfalseand a block with a statement. tests/matches_bool_equality_strength.rsthroughcheck_workspace: pinned values stayexposedin both orders and inside a commented block. Wildcard, side-only and several-value patterns, the wrapped spellings, theassert_ne!(.., false)pin and the== falsecomparison all readweakly_exposed. The pre-fix binary reads the compared and wrapped forms asexposed.- Fixture
wildcard_owner_discard: the unrelatedassert_eq!(matches!(Some(100), Some(_)), true)now readssmoke_only/ smoke. The class staysweakly_exposed, the golden is reblessed with a RIPR-SPEC-0231 reason, and its RIPR-SPEC-0108 honesty case was updated to match. - New honesty case
rust_repo_exposure_matches_compared_with_true_not_promotedreadsweakly_grippedwith a weak related-test oracle. - RIPR-SPEC-0231 rule 3 sentence, cache 1.201 / 0.203, reblessed unchanged-attempt snapshots (envelope only), recaptured honesty reports (hash fields only), golden CHANGELOG, changelog.d and traceability entries.
- Local: clippy for the ripr package with all targets, rustfmt, goldens, fixtures, the honesty gate, the policy checks, cli_smoke and both matches end-to-end targets are clean. Lib unit tests cannot build in this container, so hosted qualification covers them.
- Gemini's thread (no behaviour change, answered) and Devin's three threads (wrapped operands repaired, honesty case added, spec wording corrected) were answered and resolved.
Generated by Claude Code
2 tasks done
github-merge-queue
Bot
removed this pull request from the merge queue due to a conflict with the base branch
Nov 26, 2026
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_016EQRVmWcuwdH1oVxCdbzvV
Contributor
|
|
EffortlessSteven
left a comment
Member
Author
There was a problem hiding this comment.
SOURCE_REVIEW_READY - head 02662f4
Source and oracle review of the exact head above.
Inspected:
pattern_admission.rs,asserted_pattern: whenpattern_comparison_polarityreads the line as positive, the wholematches!operand gives its pattern pair, andpattern_assertion_classificationgrades it as it grades theassert!condition. A negative comparison, a non-literal operand and a compound operand get no pattern reading.assert_ne!stays capped by rule 1 whatever the literal.patterns.rs,transparent_operand: it removes edge comments, grouping parentheses and a block holding only the operand, repeating until none is left.pattern_operand_negationsuses it, so polarity and the pattern reader see the same operand. A block with a statement before its tail is refused byunwrap_block(nowpub(super)inbool_operands.rs). The only callers are the polarity reader andasserted_pattern.- Unit rows: weak, smoke and broad rows for both operand orders, parenthesised literals, commented groups and blocks. No-reading rows for a pinned pattern,
false,assert_ne!(.., true), a variable, a commented block compared withfalseand a block with a statement. tests/matches_bool_equality_strength.rsthroughcheck_workspace: pinned values stayexposedin both orders and inside a commented block. Wildcard, side-only and several-value patterns, the wrapped spellings, theassert_ne!(.., false)pin and the== falsecomparison all readweakly_exposed. The pre-fix binary reads the compared and wrapped forms asexposed.- Fixture
wildcard_owner_discard: the unrelatedassert_eq!(matches!(Some(100), Some(_)), true)now readssmoke_only/ smoke. The class staysweakly_exposed, the golden is reblessed with a RIPR-SPEC-0231 reason, and its RIPR-SPEC-0108 honesty case was updated to match. - New honesty case
rust_repo_exposure_matches_compared_with_true_not_promotedreadsweakly_grippedwith a weak related-test oracle. - Merge of main at 7878842 (#16280 took cache 1.201): conflicted generated files were taken from main, then the generation moved to 1.202 / 0.204. The unchanged-attempt snapshots were reblessed, all honesty reports were recaptured including the four #16280 reports, and the golden CHANGELOG entry now names 1.202. RIPR-SPEC-0231 rule 3 sentence, reblessed unchanged-attempt snapshots (envelope only), recaptured honesty reports (hash fields only), golden CHANGELOG, changelog.d and traceability entries.
- Local: clippy for the ripr package with all targets, rustfmt, goldens, fixtures, the honesty gate, the policy checks, cli_smoke and both matches end-to-end targets are clean. Lib unit tests cannot build in this container, so hosted qualification covers them.
- CodeRabbit reviewed this head with no actionable comments.
- Gemini's thread (no behaviour change, answered) and Devin's three threads (wrapped operands repaired, honesty case added, spec wording corrected) were answered and resolved.
Generated by Claude Code
2 tasks done
5 tasks done
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.
Summary
assert!(matches!(value, PATTERN))already reads as strong as its pattern (RIPR-SPEC-0231 rule 3). The same check written asassert_eq!(matches!(value, PATTERN), true)(orassert_eq!(true, matches!(..))) skipped that reading and always readexact_value/ strong. Soassert_eq!(matches!(x, _), true),assert_eq!(matches!(Some(x), Some(_)), true)andassert_eq!(matches!(discount(100), 90 | 100), true)made a change readexposedeven though they accept both versions (false credit). A positive-polarity comparison of amatches!operand now reads its pattern, so it gets the same class as theassert!form. A pattern that pins one value stays exact.Swarm / Source Boundary
ripr-swarmSource-of-truth Links
Proposal: n/a
Spec: RIPR-SPEC-0231 (rule 3 amended)
ADR: n/a
Plan item: n/a
Governing issue or accepted claim: #16290
Acceptance delta (one sentence):
assert_eq!(matches!(value, PATTERN), true)reads only as strong asPATTERN, the same asassert!(matches!(value, PATTERN)).Candidate Relationships
Candidate branch (GitHub PR head is authoritative after publication): claude/project-thread-six0md
Stack parent or prerequisite PR (if any): none (#16288 merged)
Proposed replacement of PR (if any; not yet accepted): none
Acceptance retained from a replaced candidate (if any): none
Accepted winner and losing candidate disposition (when decided): n/a
Scope
extract/oracles/pattern_admission.rs,asserted_pattern: whenpattern_comparison_polarityreads the line as a positive comparison (assert_eq!(.., true),assert_ne!(.., false), either operand order) and one operand is a whole, un-negatedmatches!(..), the pattern reading of that call decides. A negative comparison (== false,assert_ne!(.., true)), a non-boolean operand (Ok(5)) or a variable (flag) gets no pattern reading, as before.patterns.rs,transparent_operand: comments around the operand, grouping parentheses and a block holding only the operand are transparent, soassert_eq!((matches!(..)) /* note */, true)andassert_eq!({ matches!(..) }, true)read the same as the bare form. A block with a statement before its tail is not transparent.pattern_operand_negationsuses it, so polarity sees the same operand.Ok(5),false,assert_ne!(.., true)andflag.crates/ripr/tests/matches_bool_equality_strength.rsthroughcheck_workspace. Controls: a single pinned value staysexposedin both operand orders; wildcard, side-only and several-value patterns readweakly_exposed.wildcard_owner_discard: its unrelated assertionassert_eq!(matches!(Some(100), Some(_)), true)now readssmoke_only/ smoke instead ofexact_value/ strong. The finding staysweakly_exposed; the next step and repair hint now name the weak assertion. Golden blessing reason (infixtures/wildcard_owner_discard/expected/CHANGELOG.md): RIPR-SPEC-0231: assert_eq!(matches!(Some(100), Some(_)), true) is a side-only pattern, so the related-test oracle reads smoke_only instead of exact_value; the finding stays weakly_exposed (rust: assert_eq!(matches!(x, PATTERN), true) is an exact oracle whatever the pattern, even_#16290). The matching RIPR-SPEC-0108 honesty caserust_wildcard_owner_discardnow pinssmoke_only/ smoke with missweak_assertion.assert_ne!(matches!(..), false)stays weak under rule 1, becauseassert_ne!stays an inequality macro.rust_repo_exposure_matches_compared_with_true_not_promoted(weakly_gripped, weak related-test oracle), with its subject, report andreport_digest_requiredentry.changelog.dentry, traceability entry.Scope Classification
Production delta:
matches!compared withtruereads its pattern instead of always reading exact.Evidence/support delta:
Single acceptance criterion:
assert_eq!(matches!(discount(100), 90 | 100), true)readsweakly_exposed;assert_eq!(matches!(discount(100), 90), true)staysexposed.Non-goals:
ready && matches!(..)), which keep their existing rules.assert!(matches!(..)).Support-tier Impact
Claim/proof notes:
exposedtowardsweakly_exposed.Policy Impact
Ledger or exception notes:
Proof
cargo test -j2 -p ripr --test matches_bool_equality_strength --test matches_or_pattern_strength --test cli_smoke cargo clippy -j2 -p ripr --all-targets -- -D warnings cargo fmt --check cargo xtask goldens check cargo xtask fixtures cargo xtask check-evidence-promotion-honesty cargo xtask check-policy-allResult, failures, or skipped proof:
pattern_admission.rsrestored, the new test fails because the compared wildcard and or-pattern forms readexposed.Claim Boundary
matches!compared withtruefollows its pattern. Must not claim any runtime mutation outcome.Rollback
wildcard_owner_discardgolden together.Spec-Test-Code Traceability
Static Language Check
killed,survived,untested,proven, andadequate.CI Economics
n/a
Closes #16290
https://claude.ai/code/session_016EQRVmWcuwdH1oVxCdbzvV
Generated by Claude Code