Repository navigation
Apply one zero-argument expect_err rule on both adapters - #7980
Conversation
Post-merge review of #7952: without_expect_err treats an argument group that trims to empty as a mock's zero-argument expect_err(), but ends_with_expect_err matched only the literal `.expect_err()`. So `MockFoo::new().expect_err( );` read a medium mock_expectation on the line scanner and added a weak broad_error on the parser path. ends_with_expect_err now finds the outer call whose group closes the expression and requires a non-empty argument, read back from the unmasked text because masking blanks a message's quotes. Adds parity cases for a zero-argument expect_err() on a call receiver, spaced and unspaced, and for `expect_` in a comment. Registers the expect_err parity test under RIPR-SPEC-0227 in traceability. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01LF96T8WMLipviRmdgetFpK
|
Warning You have reached your daily quota limit. Please wait up to 24 hours and I will start processing your requests again! |
|
Warning You have reached your daily quota limit. Please wait up to 24 hours and I will start processing your requests again! |
|
Warning Review limit reachedThe included review limit has been reached and this organization has disabled usage-based review continuation. Wait for reviews to reset or ask a billing admin to change After included review limits. Next included review available in 3 minutes. View limit details
Comment |
There was a problem hiding this comment.
Decision
- Needs reviewer attention before upstream: findings remain.
Confirmed findings
- Siblings ends_with_unwrap_err, ends_with_expect, ends_with_panic, and without_expect_err are not touched by this diff; if the PR's stated invariant is 'both adapters agree on zero-argument expect_err', the parity claim is only true for ends_with_expect_err vs without_expect_err on the specific surface changed. Other adapters that may treat bare expect_err() similarly are out of scope for this hunk.
- Smallest-complete-fix scope is appropriate: adds three parity cases, one spec registration, one changelog extension. No expansion into #7979 (comment args, spaced/UFCS) or #7955 (multi-line/multi-statement) territory. Boundary placement correct.
Verification questions
- Confirm without sibling diff coverage: without_expect_err, ends_with_unwrap_err, ends_with_expect, ends_with_panic, balanced_group_end, mask_comments_and_strings are all defined outside this hunk; Devin's prior scan.rs:2646 finding (comment-only argument) re-opens under the new check and is not addressed in this PR.
Refuted
- The new test run(); // expect_called is sufficient evidence that the comment-masking fix from #7952 is preserved under this change; refuted because: It covers a line-trailing comment outside the call group, which is the case the prior #7952 fix already addressed. It does not cover a comment inside the argument group of a real call (the case Devin flagged).
- The new ends_with_expect_err duplicates without_expect_err's group-parsing logic and should call a shared helper; refuted because: patterns.rs's without_expect_err lives in a different module with a different scope (returns Option<&str> mask, not bool). Extracting a shared helper now would expand surface beyond the smallest fix; current approach reuses the already-shared mask_comments_and_strings + balanced_group_end primitives.
Parked follow-ups
- Devin's prior review-comment (RIGHT side scan.rs:2646) flagged block comments inside expect_err(): masked.apply mask_comments_and_strings turns
/* note */into spaces of equal length, so the argument group reads as a single space block — not an empty group, not a real message string. This is a real gap and not addressed by the PR's new test cases; residuals belong with related follow-ups.
Evidence gaps
- Model proof intent was rejected by deterministic validation.
Devin on #7980: `MockFoo::new().expect_err(/* setup */);` is mockall's zero-argument expectation, but both zero-argument checks trimmed the raw group text, so the comment counted as a message. The line scanner then dropped the mock name and the parser path read a weak broad_error. has_argument_tokens (patterns.rs) now decides for both: a group holds an argument when its masked text is non-blank or it holds a string or character literal. Adds the parity case. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01LF96T8WMLipviRmdgetFpK
There was a problem hiding this comment.
Decision
- Needs verification checks before upstream.
Verification questions
- Confirm parity cases added are all positive: zero-arg on receiver (with/without spaces) and comment-only argument. There is no negative corpus regression ensuring
Result::expect_err("msg")still reads broad_error/weak under the new shared has_argument_tokens rule. - Confirm rIPR-SPEC-0227 registration is added for the new test but no spec_0227_uncompared_expect_err_reads_like_unwrap_err body assertion is present in classify.rs - only the existing spec_0227_uncompared_unwrap_err_is_a_weak_broad_error_oracle mirrors the unwrap pattern. The traceability entry points to a test function that is not added in this diff.
- Confirm ends_with_unwrap_err, ends_with_expect, ends_with_panic still gate on literal
()rather than has_argument_tokens, so parity claim only holds for expect_err.
Refuted
- mask_comments_and_strings in scan.rs:2631 blanks string quotes, so a message-bearing
Result::expect_err("msg")would be misread as zero arguments.; refuted because: has_argument_tokens independently counts string_quotes via mask_with_string_delimiter_quotes and char literals via mask_with_char_literals, so a quoted message is recognized as an argument even when the masked trim is empty. The new testexpect_err_expect_word_message(pre-existing) continues to assert the broad_error/weak read. - Cross-method parity invariant ('all zero-arg expect_* / unwrap / panic adapters agree') is broken because siblings still use the trim-based rule.; refuted because: PR body and the github-actions review explicitly scope this change to expect_err only; the invariant claim is local to that one adapter pair, and #7979/#7955 already track related out-of-scope cases.
- has_argument_tokens returns true for expect_err("") (empty string literal), so the comment-arg fix silently broadens zero-arg to also exclude empty-string messages, which is the wrong direction; refuted because: Tested: an empty string is still a real Result::expect_err argument and should keep the message; counting it via string_quotes>0 is the correct behavior. The char-literal branch covers '' too. Comment-only groups still return false because masked.trim() is empty and both literal counters are zero. No regression.
Parked follow-ups
- Sibling methods ends_with_unwrap_err, ends_with_expect, ends_with_panic still rely on the older
is_empty/trim rule; the cross-method parity invariant is not established by this diff and would need a follow-up if required. - Siblings ends_with_unwrap_err / ends_with_expect / ends_with_panic still use the old ends_with(')') / literal '.expect_err()' shape and were not brought into parity.
Evidence gaps
- Model proof intent was rejected by deterministic validation.
|
Warning You have reached your daily quota limit. Please wait up to 24 hours and I will start processing your requests again! |
Exact-Head Review Record
|
Before: after #7952,
MockFoo::new().expect_err( );, a mockall expectation for a method namederrwith a space inside the parens, read as a mediummock_expectationon the line scanner. The parser path read the same line as a weakbroad_errorplus a mediummock_expectation. That happened because the two zero-argument checks disagreed:without_expect_errtreats an argument group that trims to empty as zero arguments, whileends_with_expect_errmatched only the literal.expect_err().After: both adapters read a zero-argument
expect_err()on a call receiver as a mock expectation only, with or without inner whitespace.Result::expect_err("msg")still readsbroad_error/ weak.ends_with_expect_errnow finds the outer.expect_err(whose group closes the expression and requires a non-empty argument. Masking blanks a message's quotes, so the argument is read back from the unmasked text.How. This PR follows up an independent post-merge review of #7952 (correctness and tests/spec angles; neither found anything blocking). It adds parity cases for
MockFoo::new().expect_err();,MockFoo::new().expect_err( );andrun(); // expect_called(the comment-masking change in #7952 had no discriminating case). It also registersspec_0227_uncompared_expect_err_reads_like_unwrap_errunder RIPR-SPEC-0227 in.ripr/traceability.toml, and extends the #7604 changelog fragment.Proof:
scan.rschange reverted, the spaced case fails on the parser path with[(BroadError, Weak), (MockExpectation, Medium)].cargo xtask precommitpasses.verdict-corpus check-allpasses; oracle accuracy is 41/41 with 0 overclaims.Residuals filed elsewhere:
.expect_err (and the UFCS formResult::expect_err(..): rust: spaced or fully qualifiedexpect_errstill reads as a medium mock_expectation #7979;🤖 Generated with Claude Code
https://claude.ai/code/session_01LF96T8WMLipviRmdgetFpK
Generated by Claude Code