Skip to content

Clippy 1.87 autofix - #6516

Merged
agourlay merged 2 commits into
devfrom
clippy-1.87-auto-fix
May 12, 2025
Merged

agourlay merged 2 commits into
devfrom
clippy-1.87-auto-fix

Conversation

@agourlay

Copy link
Copy Markdown
Member

Rust 1.87 is coming out soon.

A lot of Clippy lints are being triggered.

I propose to manage those in several PRs for better clarity.

This first PR is the result of clippy --fix to get get started.

@coderabbitai

coderabbitai Bot commented May 12, 2025 •

Copy link
Copy Markdown
Contributor
📝 Walkthrough

Walkthrough

The changes across the codebase focus primarily on simplifying code by removing unnecessary intermediate variables and adopting more concise idioms for error construction. Throughout various modules, explicit constructions of io::Error using io::Error::new(io::ErrorKind::Other, ...) have been replaced with the shorter io::Error::other(...) form. Several closures and return statements have been refactored to directly return the result of expressions instead of assigning them to local variables first. Some conditional logic has been made more explicit or idiomatic, such as using saturating_sub for index calculations and replacing chained conditionals with if-else statements. No exported or public API signatures were changed. The modifications are internal and do not affect error handling logic or control flow.

Tip

⚡️ Faster reviews with caching
  • CodeRabbit now supports caching for code and dependencies, helping speed up reviews. This means quicker feedback, reduced wait times, and a smoother review experience overall. Cached data is encrypted and stored securely. This feature will be automatically enabled for all accounts on May 16th. To opt out, configure Review - Disable Cache at either the organization or repository level. If you prefer to disable all data retention across your organization, simply turn off the Data Retention setting under your Organization Settings.

Enjoy the performance boost—your workflow just got faster.


📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 01e61ae and 76e442b.

📒 Files selected for processing (17)
  • lib/collection/src/collection_manager/optimizers/config_mismatch_optimizer.rs (2 hunks)
  • lib/common/common/src/tar_ext.rs (3 hunks)
  • lib/common/common/src/validation.rs (1 hunks)
  • lib/quantization/src/encoded_storage.rs (1 hunks)
  • lib/segment/src/common/operation_time_statistics.rs (1 hunks)
  • lib/segment/src/compat.rs (1 hunks)
  • lib/segment/src/index/field_index/full_text_index/immutable_inverted_index.rs (1 hunks)
  • lib/segment/src/index/field_index/full_text_index/mutable_inverted_index.rs (1 hunks)
  • lib/segment/src/index/field_index/histogram.rs (2 hunks)
  • lib/segment/src/index/field_index/map_index/immutable_map_index.rs (1 hunks)
  • lib/segment/src/payload_storage/mmap_payload_storage.rs (1 hunks)
  • lib/segment/src/vector_storage/chunked_vectors.rs (1 hunks)
  • lib/segment/src/vector_storage/quantized/quantized_mmap_storage.rs (1 hunks)
  • src/actix/mod.rs (1 hunks)
  • src/common/helpers.rs (1 hunks)
  • src/common/http_client.rs (1 hunks)
  • src/settings.rs (1 hunks)
🧰 Additional context used
🧬 Code Graph Analysis (1)
lib/segment/src/index/field_index/map_index/immutable_map_index.rs (1)
lib/segment/src/index/field_index/mmap_point_to_values.rs (7)
  • v (208-208)
  • mmapped_size (23-23)
  • mmapped_size (37-39)
  • mmapped_size (61-63)
  • mmapped_size (85-87)
  • mmapped_size (109-111)
  • mmapped_size (138-140)
⏰ Context from checks skipped due to timeout of 90000ms (11)
  • GitHub Check: test-consensus-compose
  • GitHub Check: test-snapshot-operations-s3-minio
  • GitHub Check: test-shard-snapshot-api-s3-minio
  • GitHub Check: test-low-resources
  • GitHub Check: Basic TLS/HTTPS tests
  • GitHub Check: test-consistency
  • GitHub Check: integration-tests-consensus
  • GitHub Check: rust-tests (macos-latest)
  • GitHub Check: rust-tests (windows-latest)
  • GitHub Check: rust-tests (ubuntu-latest)
  • GitHub Check: lint
🔇 Additional comments (20)
lib/common/common/src/validation.rs (1)

168-168: Prefer idiomatic .contains(&0) over manual .iter().any()
The change to multivec_length.contains(&0) is correct, more concise, and aligns with Clippy’s suggestion without altering behavior.

src/common/http_client.rs (1)

172-175: Good improvement: Using the more concise io::Error::other method.

This change simplifies the error construction by using io::Error::other(err) instead of the more verbose io::Error::new(io::ErrorKind::Other, err). This is a cleaner approach that achieves the same result with less code.

src/settings.rs (1)

288-290: Nice simplification using io::Error::other.

The code has been improved by replacing the more verbose io::Error::new(io::ErrorKind::Other, ...) with the more concise io::Error::other(...) method, making the code cleaner while maintaining the same functionality.

lib/quantization/src/encoded_storage.rs (1)

47-50: Good use of io::Error::other for concise error creation.

Replacing io::Error::new(io::ErrorKind::Other, ...) with io::Error::other(...) simplifies the code while maintaining identical functionality. This makes error construction more readable and aligns with Rust's idioms.

lib/segment/src/vector_storage/quantized/quantized_mmap_storage.rs (1)

41-44: Nice refactoring to use the concise io::Error::other method.

Using io::Error::other(...) instead of io::Error::new(io::ErrorKind::Other, ...) improves code readability while maintaining the same error handling logic. This change is consistent with similar improvements throughout the codebase.

lib/segment/src/payload_storage/mmap_payload_storage.rs (1)

222-225: Great use of the more concise std::io::Error::other method.

The change replaces the verbose std::io::Error::new(std::io::ErrorKind::Other, ...) construction with the more idiomatic std::io::Error::other(...) while maintaining identical functionality.

lib/segment/src/vector_storage/chunked_vectors.rs (1)

208-211: Good simplification of error construction.

The code now uses the more concise std::io::Error::other(...) method instead of the longer std::io::Error::new(std::io::ErrorKind::Other, ...) pattern, making the code cleaner while preserving the same error behavior.

src/common/helpers.rs (1)

109-109: Improved error conversion using io::Error::other.

The function now uses the shorter, more idiomatic error construction method while maintaining the same functionality for converting tonic transport errors to IO errors.

lib/segment/src/common/operation_time_statistics.rs (1)

327-327: Good use of saturating_sub to simplify boundary checks.

Using i.saturating_sub(SLIDING_WINDOW_LEN) is a more idiomatic approach to handle potential index underflow, replacing what was likely a more verbose conditional check. This enhances code readability while maintaining the same behavior.

lib/common/common/src/tar_ext.rs (4)

66-66: Improved error creation pattern

The code now uses the more idiomatic io::Error::other constructor instead of the verbose io::Error::new(io::ErrorKind::Other, ...) pattern.


214-214: Improved error creation pattern

The code now uses the more idiomatic io::Error::other constructor instead of the verbose io::Error::new(io::ErrorKind::Other, ...) pattern.


313-313: Improved error creation pattern

The code now uses the more idiomatic io::Error::other constructor instead of the verbose io::Error::new(io::ErrorKind::Other, ...) pattern.


321-321: Improved error creation pattern

The code now uses the more idiomatic io::Error::other constructor instead of the verbose io::Error::new(io::ErrorKind::Other, ...) pattern.

lib/segment/src/index/field_index/map_index/immutable_map_index.rs (1)

438-442: Simplified return pattern

Removed unnecessary intermediate variable and directly returned the result of the closure call. This makes the code more concise without changing its functionality.

src/actix/mod.rs (1)

192-192: Improved error creation pattern

The code now uses the more idiomatic io::Error::other constructor instead of the verbose io::Error::new(io::ErrorKind::Other, ...) pattern. This is consistent with similar changes across the codebase.

lib/segment/src/index/field_index/histogram.rs (1)

311-347: Simplified return pattern

Removed unnecessary intermediate variable and directly returned the result of the chained iterator operations with unwrap_or. This makes the code more concise without changing its functionality.

lib/collection/src/collection_manager/optimizers/config_mismatch_optimizer.rs (1)

166-178: Improved code conciseness by removing unnecessary intermediate variable.

The code has been simplified by directly returning the result of the expression instead of storing it in a temporary variable first.

lib/segment/src/compat.rs (1)

52-56: Replaced chained conditional with more readable if-else statement.

The code now uses a more explicit if-else statement instead of a functional pattern with .then and .unwrap_or_else. This improves readability while maintaining the same logic.

lib/segment/src/index/field_index/full_text_index/immutable_inverted_index.rs (1)

56-57: Simplified map closure by removing unnecessary intermediate variable.

The code now directly returns the result of the get method without storing it in a temporary variable.

lib/segment/src/index/field_index/full_text_index/mutable_inverted_index.rs (1)

147-149: Simplified map closure by removing unnecessary intermediate variable.

The code now directly returns the result of self.postings.get(vocab_idx as usize) instead of storing it in a temporary variable first. This change is consistent with similar improvements in other inverted index implementations.

✨ Finishing Touches
  • 📝 Generate Docstrings

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@agourlay
agourlay merged commit 1e3017b into dev May 12, 2025
@agourlay
agourlay deleted the clippy-1.87-auto-fix branch May 12, 2025 13:51
@agourlay agourlay mentioned this pull request May 12, 2025
generall pushed a commit that referenced this pull request May 22, 2025
* Clippy 1.87 autofix

* fmt
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.

2 participants