Skip to content

chore - Bump MSRV/toolchain to stable 1.93 and fix strict clippy#530

Open
mingley wants to merge 7 commits into
tikv:masterfrom
mingley:mingley/bump-rust-version-1-93
Open

chore - Bump MSRV/toolchain to stable 1.93 and fix strict clippy#530
mingley wants to merge 7 commits into
tikv:masterfrom
mingley:mingley/bump-rust-version-1-93

Conversation

@mingley

@mingley mingley commented Feb 6, 2026

Copy link
Copy Markdown

Summary

This PR upgrades the repository toolchain/MSRV to Rust 1.93.0 and applies strict-clippy compatibility fixes while preserving runtime behavior and public API compatibility.

Quality objective:

  • keep the codebase clean under -D warnings,
  • avoid unintended semantic changes,
  • maintain Error::GrpcAPI usability for downstream code.

Rationale

Problem statement

Moving to Rust 1.93 and strict clippy surfaced new lints in generated/protocol and request/transaction paths. A prior approach introduced awkward conditional typing for Error::GrpcAPI; this PR keeps the API representation stable and solves lint pressure in a clearer way.

Design changes

  • Toolchain/MSRV:
    • Cargo.toml: rust-version = "1.93.0"
    • rust-toolchain.toml: channel 1.93.0
  • Error::GrpcAPI compatibility:
    • keep payload as tonic::Status (single representation),
    • keep From<tonic::Status> for Error conversion path,
    • remove cfg(clippy) payload-type split.
  • Lint strategy for large error payload:
    • targeted #![allow(clippy::result_large_err)] in src/lib.rs and examples/raw.rs.
  • Clippy cleanup (behavior-preserving simplifications):
    • remove redundant conversions,
    • replace repeat(...).take(...) with repeat_n(...),
    • narrow generated-code dead-code handling in src/proto.rs.

Risk analysis

  • Primary risk: accidental API/behavior drift during lint cleanup.
  • Mitigation:
    • explicit tests for error conversion and variant behavior,
    • full format/clippy/test gates.

File Scope

  • Cargo.toml
  • rust-toolchain.toml
  • src/common/errors.rs
  • src/lib.rs
  • examples/raw.rs
  • src/proto.rs
  • src/pd/retry.rs
  • src/store/request.rs
  • src/transaction/requests.rs
  • src/transaction/transaction.rs
  • tests/integration_tests.rs

Testing Done

Executed locally:

  1. cargo fmt -> pass
  2. cargo clippy --all-targets --all-features -- -D warnings -> pass
  3. cargo test -> pass

Added/maintained regression coverage in src/common/errors.rs:

  • from_tonic_status_produces_grpc_api_error
  • grpc_api_variant_accepts_tonic_status_payload
  • from_proto_region_error_wraps_region_error
  • from_proto_key_error_wraps_key_error

Compatibility

  • Public Error::GrpcAPI construction/pattern behavior remains compatible (tonic::Status payload).
  • No intentional runtime behavior change beyond lint/toolchain conformance.

Summary by CodeRabbit

  • Chores

    • Updated the Rust toolchain to 1.93.0 and set the project’s minimum supported Rust version.
  • Improvements

    • Improved gRPC error handling consistency by adjusting how gRPC status errors are converted.
    • Reduced unnecessary per-item conversions in request and transaction read paths.
    • Updated lint allowances/documentation to better match Rust 1.93 clippy behavior.
  • Tests

    • Added unit coverage for the updated gRPC status-to-error conversion behavior.

@ti-chi-bot

ti-chi-bot Bot commented Feb 6, 2026

Copy link
Copy Markdown

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by:
Once this PR has been reviewed and has the lgtm label, please assign you06 for approval. For more information see the Code Review Process.
Please ensure that each of them provides their approval before proceeding.

The full list of commands accepted by this bot can be found here.

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@ti-chi-bot ti-chi-bot Bot added the dco-signoff: yes Indicates the PR's author has signed the dco. label Feb 6, 2026
@coderabbitai

coderabbitai Bot commented Feb 6, 2026

Copy link
Copy Markdown

Review Change Stack

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review
📝 Walkthrough

Walkthrough

Upgrade Rust toolchain to 1.93.0 via Cargo.toml and rust-toolchain.toml with clippy allowances for compatibility. Refactor Error::GrpcAPI to hold plain tonic::Status with explicit From<tonic::Status> impl and tests. Update request dispatch error handling and simplify iterators by replacing repeat().take() with repeat_n(). Remove redundant per-element Into::into conversions across transaction and store code.

Changes

Toolchain upgrade and compatibility

Layer / File(s) Summary
Manifest toolchain declarations
Cargo.toml, rust-toolchain.toml
Rust version constraint added to Cargo.toml and toolchain channel updated to 1.93.0 in rust-toolchain.toml.
Clippy allowances for 1.93.0 compatibility
src/lib.rs, examples/raw.rs, src/proto.rs
Added result_large_err allowance in crate root and example file; added dead_code allowance for protobuf-generated code to suppress Rust 1.93 clippy warnings.

Error type restructuring

Layer / File(s) Summary
GrpcAPI variant and From impl
src/common/errors.rs
Removed #[from] attribute from GrpcAPI variant and added explicit impl From<tonic::Status> for Error that constructs Error::GrpcAPI(status) with tests validating the conversion and payload preservation.
Error handling in request dispatch
src/store/request.rs
Updated store request dispatch to map gRPC errors via Error::from instead of the removed Error::GrpcAPI derive-from behavior.

Iterator and type conversion simplifications

Layer / File(s) Summary
Iterator API updates
src/transaction/requests.rs, tests/integration_tests.rs
Replaced iter::repeat().take() with iter::repeat_n() in prewrite request construction and integration test batch_scan invocation.
Removal of redundant Into conversions
src/transaction/requests.rs, src/transaction/transaction.rs, src/pd/retry.rs
Removed per-element Into::into conversions from transaction request building, retry response mapping, and scan lock merging; direct collection or assignment used instead.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~12 minutes

Poem

🐰 The toolchain hops to 1.93's gate,
Error conversions now explicit, not late.
Repeat_n simplifies, Into we drop,
Clippy is happy—the warnings do stop! ✨

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately summarizes the main changes: upgrading the Rust toolchain to 1.93 and fixing clippy issues.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
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

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

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

@ti-chi-bot ti-chi-bot Bot added contribution This PR is from a community contributor. size/L Denotes a PR that changes 100-499 lines, ignoring generated files. labels Feb 6, 2026
@mingley

mingley commented Feb 6, 2026

Copy link
Copy Markdown
Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Feb 6, 2026

Copy link
Copy Markdown
✅ Actions performed

Review triggered.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@ti-chi-bot ti-chi-bot Bot added size/M Denotes a PR that changes 30-99 lines, ignoring generated files. and removed size/L Denotes a PR that changes 100-499 lines, ignoring generated files. labels Feb 6, 2026
@mingley

mingley commented Feb 6, 2026

Copy link
Copy Markdown
Author

Addressed local review findings #2 and #3 in cfad559:

  • Removed crate-wide/example clippy::result_large_err suppressions.
  • Replaced Error::GrpcAPI(tonic::Status) with boxed storage + explicit From<tonic::Status> so API signatures remain unchanged while reducing error size pressure.
  • Dropped generated-file rewrite logic from proto-build/src/main.rs.
  • Moved dead-code suppression to generated module boundary in src/proto.rs with explicit “why now vs before” context comment.

Also added a dedicated "Follow-on PR Callout: Dependency Modernization" section to the PR description with major version gaps and rationale.

@mingley mingley changed the title Bump MSRV/toolchain to stable 1.93 and fix strict clippy chore - Bump MSRV/toolchain to stable 1.93 and fix strict clippy Feb 6, 2026
@ti-chi-bot ti-chi-bot Bot added dco-signoff: no Indicates the PR's author has not signed dco. size/L Denotes a PR that changes 100-499 lines, ignoring generated files. and removed size/M Denotes a PR that changes 30-99 lines, ignoring generated files. dco-signoff: yes Indicates the PR's author has signed the dco. labels Feb 11, 2026

@coderabbitai coderabbitai 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.

Actionable comments posted: 2

🤖 Fix all issues with AI agents
In `@src/common/errors.rs`:
- Around line 202-211: The test grpc_api_variant_accepts_tonic_status_payload is
gated with #[cfg(not(clippy))], causing it to be skipped under cargo clippy;
remove the #[cfg(not(clippy))] attribute so the test always runs, and ensure it
still passes after applying the unconditional boxing change mentioned in the
surrounding comments (the test constructs Error::GrpcAPI from tonic::Status and
asserts status.code() and status.message()).
- Around line 11-14: The conditional type alias GrpcApiErrorPayload causes
divergent in-memory representations under clippy vs normal builds; make the
payload unconditionally boxed by changing the alias to "type GrpcApiErrorPayload
= Box<tonic::Status>;" so Error::GrpcAPI has a consistent, smaller enum variant
across all builds, then remove the #[cfg(not(clippy))] gating from tests that
construct Error::GrpcAPI (the test that conditionally constructs GrpcAPI can now
use Error::GrpcAPI(status) directly) and consider removing the now-redundant
#[allow(clippy::large_enum_variant)] if no longer needed.

Comment thread src/common/errors.rs Outdated
Comment thread src/common/errors.rs Outdated
@mingley mingley force-pushed the mingley/bump-rust-version-1-93 branch from 0a5504c to 98a9dcb Compare February 11, 2026 12:44
@ti-chi-bot ti-chi-bot Bot added dco-signoff: yes Indicates the PR's author has signed the dco. and removed dco-signoff: no Indicates the PR's author has not signed dco. labels Feb 11, 2026
@mingley mingley force-pushed the mingley/bump-rust-version-1-93 branch from 98a9dcb to affc0d5 Compare February 11, 2026 13:22
Signed-off-by: Michael Ingley <michael.ingley@gmail.com>
@mingley mingley force-pushed the mingley/bump-rust-version-1-93 branch from affc0d5 to d63fe2b Compare February 11, 2026 13:22
Comment thread src/common/errors.rs Outdated
…-version-1-93

Signed-off-by: Michael Ingley <michael.ingley@gmail.com>
@mingley mingley force-pushed the mingley/bump-rust-version-1-93 branch from 162c150 to 7afa393 Compare June 22, 2026 23:12
…m impl

The manual `impl From<tonic::Status>` duplicated what `#[from]` already
generates, so the variant change and impl were a no-op (identical behavior,
same clippy result). Reverts to `#[from]` per review and drops the trivial
conversion tests added alongside it.

Signed-off-by: Michael Ingley <michael.ingley@gmail.com>
…ail_point

The 1.93 bump trips clippy::result_large_err on the integration-test crates (large Error type), matching the existing allows in lib.rs and examples; and unused_mut on the fail_point! closure binding, which is mutated only when failpoints are compiled in. Closes the gap that left make check red since 2026-06-14.

Signed-off-by: Michael Ingley <michael.ingley@gmail.com>
@mingley mingley requested a review from pingyu June 23, 2026 00:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

contribution This PR is from a community contributor. dco-signoff: yes Indicates the PR's author has signed the dco. size/L Denotes a PR that changes 100-499 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants