Skip to content

fix: simple fix a rust compile warning#2143

Open
yihong0618 wants to merge 1 commit into
rapidsai:mainfrom
yihong0618:hy/fix_rust_warning
Open

fix: simple fix a rust compile warning#2143
yihong0618 wants to merge 1 commit into
rapidsai:mainfrom
yihong0618:hy/fix_rust_warning

Conversation

@yihong0618
Copy link
Copy Markdown
Contributor

this patch simple fix a rust compile warning when run ./build.sh rust

Signed-off-by: yihong0618 <zouzou0208@gmail.com>
@copy-pr-bot
Copy link
Copy Markdown

copy-pr-bot Bot commented May 29, 2026

This pull request requires additional validation before any workflows can run on NVIDIA's runners.

Pull request vetters can view their responsibilities here.

Contributors can view more details about this message here.

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 29, 2026

Review Change Stack

📝 Walkthrough

Summary by CodeRabbit

  • Tests
    • Minor test code refinement in the search functionality test suite.

Note: This release contains internal test improvements with no user-facing changes.

Walkthrough

The PR removes unnecessary mutability from the neighbors_host variable in the test_cagra_search_with_filter test function. The variable is not mutated after initialization, so the mut keyword is redundant.

Changes

Test mutability cleanup in CAGRA search filter test

Layer / File(s) Summary
Remove unnecessary mutability from test variable
rust/cuvs/src/cagra/index.rs
The neighbors_host ndarray binding in test_cagra_search_with_filter is changed from mutable to immutable, eliminating an unused mut annotation.

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~2 minutes

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly identifies the main change as fixing a Rust compile warning, which aligns with the changeset that removes an unused mut binding.
Description check ✅ Passed The description explicitly states the intent to fix a Rust compile warning when running ./build.sh rust, which is directly related to the changeset.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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

Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
rust/cuvs/src/cagra/index.rs (1)

303-314: ⚠️ Potential issue | 🔴 Critical | ⚡ Quick win

Make neighbors_host mutable for the to_host(&mut ...) call

neighbors_host is declared as immutable (let neighbors_host = ...) but is later passed as &mut neighbors_host to neighbors.to_host(...), which will fail to compile.

Suggested fix
-        let neighbors_host = ndarray::Array::<u32, _>::zeros((n_queries, k));
+        let mut neighbors_host = ndarray::Array::<u32, _>::zeros((n_queries, k));
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@rust/cuvs/src/cagra/index.rs` around lines 303 - 314, neighbors_host is
declared immutable but later passed as &mut to neighbors.to_host(&res, &mut
neighbors_host); make neighbors_host mutable by changing its binding to be
mutable (e.g., let mut neighbors_host = ...) so the &mut borrow is valid; update
the declaration of neighbors_host (and similarly distances_host if needed) where
ManagedTensor::from(&neighbors_host) is created and used with neighbors.to_host
and distances.to_host to ensure correct mutability.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Outside diff comments:
In `@rust/cuvs/src/cagra/index.rs`:
- Around line 303-314: neighbors_host is declared immutable but later passed as
&mut to neighbors.to_host(&res, &mut neighbors_host); make neighbors_host
mutable by changing its binding to be mutable (e.g., let mut neighbors_host =
...) so the &mut borrow is valid; update the declaration of neighbors_host (and
similarly distances_host if needed) where ManagedTensor::from(&neighbors_host)
is created and used with neighbors.to_host and distances.to_host to ensure
correct mutability.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Enterprise

Run ID: 67b8035a-282b-49ec-a353-1368f1862a0b

📥 Commits

Reviewing files that changed from the base of the PR and between caf24ce and 3352e38.

📒 Files selected for processing (1)
  • rust/cuvs/src/cagra/index.rs

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: No status

Development

Successfully merging this pull request may close these issues.

1 participant