fix: simple fix a rust compile warning#2143
Conversation
Signed-off-by: yihong0618 <zouzou0208@gmail.com>
📝 WalkthroughSummary by CodeRabbit
Note: This release contains internal test improvements with no user-facing changes. WalkthroughThe PR removes unnecessary mutability from the ChangesTest mutability cleanup in CAGRA search filter test
Estimated code review effort🎯 1 (Trivial) | ⏱️ ~2 minutes 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
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 winMake
neighbors_hostmutable for theto_host(&mut ...)call
neighbors_hostis declared as immutable (let neighbors_host = ...) but is later passed as&mut neighbors_hosttoneighbors.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
📒 Files selected for processing (1)
rust/cuvs/src/cagra/index.rs
this patch simple fix a rust compile warning when run
./build.sh rust