Skip to content

📝 CodeRabbit Chat: Implement requested code changes#237

Open
coderabbitai[bot] wants to merge 7 commits into
8-2-2-call-site-collection-in-rstest-testsfrom
coderabbitai/chat/89cbd74
Open

📝 CodeRabbit Chat: Implement requested code changes#237
coderabbitai[bot] wants to merge 7 commits into
8-2-2-call-site-collection-in-rstest-testsfrom
coderabbitai/chat/89cbd74

Conversation

@coderabbitai

@coderabbitai coderabbitai Bot commented Jun 5, 2026

Copy link
Copy Markdown

Code changes was requested by @leynos.

The following files were modified:

  • crates/rstest_helper_should_be_fixture/src/collector_behaviour.rs
  • crates/rstest_helper_should_be_fixture/src/collector_tests.rs
  • crates/rstest_helper_should_be_fixture/src/driver.rs

Summary by Sourcery

Refine rstest helper call collection behaviour and testing for duplicate and distinct call sites.

Bug Fixes:

  • Adjust call-site collector behaviour to correctly handle repeated helper calls with identical or distinct source spans when aggregating records.

Enhancements:

  • Extract rstest function collection logic into a dedicated method on the lint pass to simplify reuse and maintainability.
  • Introduce a shared helper for inserting multiple helper calls in the collector behaviour world setup.

Tests:

  • Replace separate tests with a parameterized rstest case to cover duplicate and non-duplicate helper call scenarios in the call-site collector.

leynos and others added 7 commits May 28, 2026 02:36
Add a draft execution plan for roadmap item 8.2.2, covering call-site
collection inside `#[rstest]` tests, fixture-local classification, and
constant-aware argument fingerprinting. The plan stays diagnostic-silent
and defers threshold evaluation, diagnostic emission, and UI pass/fail
fixtures to roadmap items 8.2.3 and 8.2.4. It records the in-crate
adapter placement decision, dedup policy for `#[case]` companions, and
the validation, review, and rollout sequence required before the
roadmap tick lands.
Add a passive call-site collector for local helper invocations inside
strict `#[rstest]` tests. Lower positional arguments into the shared
argument fingerprint model, deduplicate recovered source spans, and log
collected evidence at crate-post time without emitting diagnostics.

Keep the implementation scoped to the lint crate and record the first
milestone validation and CodeRabbit review outcome in the ExecPlan.
Add behavioural, property, and trybuild pass coverage for the
rstest helper call-site collector. Record the CodeRabbit fixes and
validation results in the 8.2.2 execplan.
Add an explicit regression proving macro-only HIR spans do not
recover to user-editable source. Record the validation and
CodeRabbit review outcome in the 8.2.2 execplan.
Update user, developer, design, roadmap, and execplan docs for
the diagnostic-silent rstest helper call-site collection phase.
Record the validation and review outcomes for 8.2.2.
Mark the 8.2.2 execplan PR step complete after pushing the branch
and updating draft PR #235.
@coderabbitai coderabbitai Bot requested a review from leynos June 5, 2026 18:07
@coderabbitai

coderabbitai Bot commented Jun 5, 2026

Copy link
Copy Markdown
Author

Important

Review skipped

This PR was authored by the user configured for CodeRabbit reviews. CodeRabbit does not review PRs authored by this user. It's recommended to use a dedicated user account to post CodeRabbit review feedback.

⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: 32edf24f-ab4c-4f7a-b5c7-0b8e96e9f833

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review

Comment @coderabbitai help to get the list of available commands and usage tips.

@sourcery-ai

sourcery-ai Bot commented Jun 5, 2026

Copy link
Copy Markdown

Reviewer's Guide

Refactors the rstest helper call collection behavior to reuse logic, parameterize tests around second-call behavior, and split rstest function collection from the LateLintPass implementation while keeping behavior identical and adding some configurability in tests and BDD steps.

Sequence diagram for refactored rstest function collection

sequenceDiagram
    participant LintDriver
    participant RstestHelperShouldBeFixture as Helper
    participant LateContext as Cx
    participant CallSiteVisitor as Visitor

    LintDriver->>Helper: check_fn(cx, kind, decl, body, span, def_id)
    Helper->>Helper: collect_rstest_fn(cx, body, def_id)
    Helper->>Cx: local_def_id_to_hir_id(def_id)
    Helper->>Cx: typeck(def_id)
    Helper->>Visitor: new(cx, collector, def_id, fixture_locals)
    Helper->>Visitor: visit_expr(body.value)
Loading

File-Level Changes

Change Details Files
Unify and parameterize tests around handling repeated helper calls for the same callee and varying source spans.
  • Replace two separate tests about deduplication and distinct spans with a single rstest-parameterized test covering both cases.
  • Add parameters for second call span, insertion result, and expected record count, and assert them instead of duplicating test logic.
crates/rstest_helper_should_be_fixture/src/collector_tests.rs
Extract rstest function collection into a helper method and delegate from LateLintPass hooks.
  • Move body of check_fn into a new collect_rstest_fn method on RstestHelperShouldBeFixture, keeping the logic unchanged.
  • Call collect_rstest_fn from LateLintPass::check_fn to separate collection logic from lint pass wiring.
crates/rstest_helper_should_be_fixture/src/driver.rs
Deduplicate BDD setup for inserting two helper calls by introducing a reusable helper function.
  • Introduce push_two_helper_calls helper to insert two helper calls with configurable second span.
  • Rewrite existing BDD 'given' steps to reuse push_two_helper_calls for same and distinct span scenarios.
crates/rstest_helper_should_be_fixture/src/collector_behaviour.rs

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@sourcery-ai sourcery-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey - I've found 1 issue, and left some high level feedback:

  • In check_crate_post, the inner for record in records loop was removed but the body still appears to use record, so either reintroduce the iteration or adjust the debug logic to avoid referencing an undefined variable and to ensure all records are still processed.
Prompt for AI Agents
Please address the comments from this code review:

## Overall Comments
- In `check_crate_post`, the inner `for record in records` loop was removed but the body still appears to use `record`, so either reintroduce the iteration or adjust the debug logic to avoid referencing an undefined variable and to ensure all records are still processed.

## Individual Comments

### Comment 1
<location path="crates/rstest_helper_should_be_fixture/src/driver.rs" line_range="203" />
<code_context>
         for (callee, records) in self.collector.iter() {
-            for record in records {
+
                 debug!(
                     target: LINT_NAME,
                     "collected rstest helper call: callee={}, callee_def_id={:?}, \
</code_context>
<issue_to_address>
**issue (bug_risk):** The loop over `records` appears to have been removed, breaking iteration and likely compilation.

`check_crate_post` used to bind `record` via `for record in records { ... }`, but that loop is now gone while `record` is still used in the body. This will fail to compile (undefined `record`) and also prevents iterating over all `records`. Reintroduce a loop over `records` or otherwise adjust the logic to process each record correctly.
</issue_to_address>

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

for (callee, records) in self.collector.iter() {
for record in records {

debug!(

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

issue (bug_risk): The loop over records appears to have been removed, breaking iteration and likely compilation.

check_crate_post used to bind record via for record in records { ... }, but that loop is now gone while record is still used in the body. This will fail to compile (undefined record) and also prevents iterating over all records. Reintroduce a loop over records or otherwise adjust the logic to process each record correctly.

@leynos leynos force-pushed the 8-2-2-call-site-collection-in-rstest-tests branch from e4830a2 to a6ad47c Compare June 19, 2026 18:32
@lodyai lodyai Bot force-pushed the 8-2-2-call-site-collection-in-rstest-tests branch from b81b889 to a37bc88 Compare July 5, 2026 00:38
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.

1 participant