Skip to content

Conversation

Lorak-mmk
Copy link
Collaborator

@Lorak-mmk Lorak-mmk commented Aug 13, 2025

This PR:

  • Performs fixes for Clippy changes introduced in 1.89
  • Bumps MSRV to 1.85 (and fixes lints triggered by that)
  • Performs code changes necessary to make our codebase compatible with both edition 2021 and 2024
  • Moves all crates to edition 2024
  • Moves to resolver v3
  • Removes Cargo.lock.msrv and related devdocs, since it is redundant with resolver v3
  • Makes some minor changes in ccm code, utilizing async closures.

TODO:
See the commit Preparing for 2024 edition: automatic changes
There is a pattern that is not handled by automatic migration tool: https://doc.rust-lang.org/edition-guide/rust-2024/rpit-lifetime-capture.html#migrating-away-from-the-outlives-trick
We have code like this in many places:

    pub(crate) fn iter_working_connections_per_node(
        &self,
    ) -> Result<
        impl Iterator<Item = (Uuid, impl Iterator<Item =
Arc<Connection>> + use<>)> + '_,
        ConnectionPoolError,
    >

Is that an example of this trick? Should we change this code from + '_ to + use<'_>?

Fixes: #1421

Pre-review checklist

  • I have split my patch into logically separate commits.
  • All commit messages clearly explain what they change and why.
  • I added relevant tests for new features and bug fixes.
  • All commits compile, pass static checks and pass test.
  • PR description sums up the changes and reasons why they should be introduced.
  • I have provided docstrings for the public items that I want to introduce.
  • I have adjusted the documentation in ./docs/source/.
  • I added appropriate Fixes: annotations to PR description.

Minor cleanup. This feature is not used by scylla-cql.
mismatched_lifetime_syntaxes is introduced in Rust 1.89. It warns when
an elided lifetime (like &self) is bound to a hidden lifetime (like
RawValue that is really RawValue<'_>).
In Rust 1.89, those structs started to trigger dead_code warning with
information that they are never constructed.
In row_tests / value_tests I don't want to allow/expect dead_code,
because part of the reason for existence of those structs is to verify
generated impls for those structs.
The solution I chose is to write a never-called function that calles the
relevant deserialize impl. This seems to work.
Curiously, TestRowByName in hygiene tests doesn't trigger the warning. I
am unable to tell why. I tried to replace derives with their generated
impls, but I didn't notice any difference that could have caused this.
Such lifetimes are often written intentionally, to make code easier to
read. Lint will start to trigger when we bump MSRV to 1.85, so lets
allow it.
There is a lint for that that starts to trigger after MSRV is bumped to
1.85.
There is a lint for that that starts to trigger when MSRV is bumped to
1.85.
This time I bumped all the crates. Why? Because I want us to move to
edition 2024.
"gen" became a reserved keyword in edition 2024. We want to move to that
edition, so I renamed all of those to "generator". Fortunately, none of
them appear in the public API.
Those became errors in 2024.
How this commit was created:
I executed `cargo fix --edition`. After that I looked through the
changes, and reverted the ones I thought were unnecessary.
What changes I reverted?
- Rust 2024 added new expression types matched by `expr` fragment
specifier. For backwards compatibility `expr_2021` exists as well. cargo
moves the code to use it, but for our macros `expr` is still fine - they
are only internal after all.
- In Rust 2024, lifetime of temporary expression in `if let Pattern =
Expression` changed. Now it is dropped before entering `else` branch.
Cargo switches the code to use `match` instead of `if let` for
compatibility. I reviewed affected places in our code and concluded that
we can keep using `if let` everywhere.

That means that the only commited changes are related to RPIT lifetime
capture rules. Cargo introduced `use` bounds in several places. Most of
them are not important since they are not pub so we can change them
later. Two places were pub, and cargo correctly preserved current
semantics (which are also reasonable imo).
The pub places:
- `ColumnSpecs::iter`: `use<'slice, 'spec>` was introduced. We don't
need or want to bind to lifetime of a self reference, only to lifetimes
of held slice, so it makes sense.
- `Sharder::iter_source_ports_for_shard`. `use<>` was introduced by
Cargo. This is correct - the returned iterator does not depend on self.
self is only needed to get the bounds of the port range.

There is one thing that automatic migration doesn't handle the "outlives
trick":
https://doc.rust-lang.org/edition-guide/rust-2024/rpit-lifetime-capture.html#migrating-away-from-the-outlives-trick
I don't understand it completely unfortunately. We should understand it,
and if needed migrate from it, before migrating to 2024 edition.
We have a method like this for example:
```
    pub(crate) fn iter_working_connections_per_node(
        &self,
    ) -> Result<
        impl Iterator<Item = (Uuid, impl Iterator<Item =
Arc<Connection>> + use<>)> + '_,
        ConnectionPoolError,
    >
```
Is it an example of this trick? Should we change this `+ '_` to
`use<'_>`?
Running `cargo fix --edition` in previous commit produced a lot of
output. Vast majority of it is about drop order of temporaries changing
in 2024.
I briefly looked through some of those warnings, but I did not see
anything interesting. I doubt we rely on this drop order anywhere.

The other type of warning is about the RPIT lifetime capture rules.
There is a case that the tool does not handle automatically and only
warns about:
https://doc.rust-lang.org/edition-guide/rust-2024/rpit-lifetime-capture.html#migrating-cases-involving-apit
I went through those warnings, and performed the changes manually.
Scope changes of temporaries in Rust 2024 would cause compilation error
here, because the printer would be dropped too quickly.
See more at
https://doc.rust-lang.org/edition-guide/rust-2024/temporary-tail-expr-scope.html
Returning a just-bound let variable triggers a lint in Rust 2024.
I kept rustfmt edition at 2021 for now, because I want to introduce
formatting changes in a separate commit.
Most of the changes are just reordered imports and function/macro calls
with long arguments getting split into multiple lines.
This resolver is MSRV-aware which should remove the need for our
Cargo.lock.msrv file.
It should not be needed anymore.
This simplifies the code, removing the need for locking.
It is imo more straightforward, easier to understand.
@github-actions github-actions bot added the semver-checks-breaking cargo-semver-checks reports that this PR introduces breaking API changes label Aug 13, 2025
Copy link

cargo semver-checks detected some API incompatibilities in this PR.
Checked commit: fd84918

See the following report for details:

cargo semver-checks output
./scripts/semver-checks.sh --baseline-rev 3da897d6e81e785c9be145da47f31248c33a4f30
+ cargo semver-checks -p scylla -p scylla-cql --baseline-rev 3da897d6e81e785c9be145da47f31248c33a4f30
     Cloning 3da897d6e81e785c9be145da47f31248c33a4f30
    Building scylla v1.3.1 (current)
       Built [  33.204s] (current)
     Parsing scylla v1.3.1 (current)
      Parsed [   0.108s] (current)
    Building scylla v1.3.1 (baseline)
error: running cargo-doc on crate 'scylla' failed with output:
-----
   Compiling libc v0.2.175
   Compiling proc-macro2 v1.0.97
   Compiling unicode-ident v1.0.18
   Compiling shlex v1.3.0
   Compiling autocfg v1.5.0
    Checking cfg-if v1.0.1
   Compiling dunce v1.0.5
   Compiling fs_extra v1.3.0
   Compiling num-traits v0.2.19
   Compiling getrandom v0.3.3
   Compiling quote v1.0.40
    Checking pin-project-lite v0.2.16
   Compiling syn v2.0.104
    Checking once_cell v1.21.3
   Compiling jobserver v0.1.33
    Checking zeroize v1.8.1
   Compiling pkg-config v0.3.32
   Compiling vcpkg v0.2.15
   Compiling cc v1.2.32
   Compiling aws-lc-rs v1.13.3
   Compiling zerocopy v0.8.26
   Compiling cmake v0.1.54
   Compiling ident_case v1.0.1
   Compiling fnv v1.0.7
   Compiling strsim v0.11.1
    Checking num-integer v0.1.46
    Checking mio v1.0.4
    Checking socket2 v0.6.0
   Compiling libm v0.2.15
   Compiling aws-lc-sys v0.30.0
   Compiling openssl-sys v0.9.109
    Checking futures-core v0.3.31
    Checking bytes v1.10.1
    Checking futures-sink v0.3.31
    Checking futures-channel v0.3.31
    Checking rand_core v0.9.3
    Checking rustls-pki-types v1.12.0
   Compiling bigdecimal v0.4.8
   Compiling num-bigint v0.3.3
   Compiling lock_api v0.4.13
   Compiling synstructure v0.13.2
   Compiling darling_core v0.20.11
    Checking futures-task v0.3.31
    Checking futures-io v0.3.31
    Checking memchr v2.7.5
    Checking untrusted v0.9.0
   Compiling thiserror v1.0.69
    Checking foreign-types-shared v0.1.1
   Compiling parking_lot_core v0.9.11
   Compiling openssl v0.10.73
   Compiling snap v1.1.1
   Compiling tokio-macros v2.5.0
   Compiling zerofrom-derive v0.1.6
    Checking tokio v1.47.1
   Compiling darling_macro v0.20.11
   Compiling futures-macro v0.3.31
    Checking slab v0.4.11
   Compiling crossbeam-utils v0.8.21
   Compiling thiserror v2.0.14
   Compiling rustls v0.23.31
    Checking pin-utils v0.1.0
    Checking powerfmt v0.2.0
    Checking futures-util v0.3.31
    Checking deranged v0.4.0
   Compiling darling v0.20.11
    Checking zerofrom v0.1.6
   Compiling thiserror-impl v1.0.69
   Compiling openssl-macros v0.1.1
   Compiling yoke-derive v0.8.0
   Compiling thiserror-impl v2.0.14
    Checking foreign-types v0.3.2
    Checking ppv-lite86 v0.2.21
    Checking num-bigint v0.4.6
   Compiling tokio-openssl v0.6.5
    Checking twox-hash v2.1.1
    Checking log v0.4.27
    Checking bitflags v2.9.1
    Checking iana-time-zone v0.1.63
    Checking num-conv v0.1.0
    Checking time-core v0.1.4
    Checking either v1.15.0
    Checking subtle v2.6.1
    Checking smallvec v1.15.1
    Checking scopeguard v1.2.0
    Checking stable_deref_trait v1.2.0
    Checking yoke v0.8.0
    Checking itertools v0.14.0
    Checking time v0.3.41
    Checking chrono v0.4.41
    Checking lz4_flex v0.11.5
    Checking rand_chacha v0.9.0
    Checking futures-executor v0.3.31
   Compiling scylla-macros v1.3.1 (/home/runner/work/scylla-rust-driver/scylla-rust-driver/target/semver-checks/git-3da897d6e81e785c9be145da47f31248c33a4f30/c3ed706bfaabbfdac8a0ac777c681ed8709c2256/scylla-macros)
   Compiling tracing-attributes v0.1.30
    Checking uuid v1.18.0
    Checking secrecy v0.8.0
    Checking tracing-core v0.1.34
    Checking hashbrown v0.14.5
    Checking foldhash v0.1.5
    Checking byteorder v1.5.0
    Checking allocator-api2 v0.2.21
    Checking equivalent v1.0.2
    Checking scylla-cql v1.3.1 (/home/runner/work/scylla-rust-driver/scylla-rust-driver/target/semver-checks/git-3da897d6e81e785c9be145da47f31248c33a4f30/c3ed706bfaabbfdac8a0ac777c681ed8709c2256/scylla-cql)
    Checking dashmap v6.1.0
    Checking hashbrown v0.15.5
    Checking tracing v0.1.41
    Checking futures v0.3.31
    Checking histogram v0.11.3
    Checking rand v0.9.2
   Compiling async-trait v0.1.88
    Checking rand_pcg v0.9.0
    Checking socket2 v0.5.10
    Checking arc-swap v1.7.1
    Checking rustls-webpki v0.103.4
    Checking tokio-rustls v0.26.2
 Documenting scylla v1.3.1 (/home/runner/work/scylla-rust-driver/scylla-rust-driver/target/semver-checks/git-3da897d6e81e785c9be145da47f31248c33a4f30/c3ed706bfaabbfdac8a0ac777c681ed8709c2256/scylla)
�[38;5;9merror: couldn't read `/home/runner/work/scylla-rust-driver/scylla-rust-driver/target/semver-checks/git-3da897d6e81e785c9be145da47f31248c33a4f30/c3ed706bfaabbfdac8a0ac777c681ed8709c2256/scylla/src/deserialize/README.md`: No such file or directory (os error 2)
   �[38;5;12m--> /home/runner/work/scylla-rust-driver/scylla-rust-driver/target/semver-checks/git-3da897d6e81e785c9be145da47f31248c33a4f30/c3ed706bfaabbfdac8a0ac777c681ed8709c2256/scylla/src/lib.rs:203:14
    �[38;5;12m|
�[38;5;12m203 �[38;5;12m|     #![doc = include_str!("deserialize/README.md")]
    �[38;5;12m|              �[38;5;9m^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

error: could not document `scylla`

-----

error: failed to build rustdoc for crate scylla v1.3.1
note: this is usually due to a compilation error in the crate,
      and is unlikely to be a bug in cargo-semver-checks
note: the following command can be used to reproduce the compilation error:
      cargo new --lib example &&
          cd example &&
          echo '[workspace]' >> Cargo.toml &&
          cargo add --path /home/runner/work/scylla-rust-driver/scylla-rust-driver/target/semver-checks/git-3da897d6e81e785c9be145da47f31248c33a4f30/c3ed706bfaabbfdac8a0ac777c681ed8709c2256/scylla --features bigdecimal-04,chrono-04,default,full-serialization,metrics,num-bigint-03,num-bigint-04,openssl-010,rustls-023,secrecy-08,time-03 &&
          cargo check

    Building scylla-cql v1.3.1 (current)
       Built [   9.897s] (current)
     Parsing scylla-cql v1.3.1 (current)
      Parsed [   0.036s] (current)
    Building scylla-cql v1.3.1 (baseline)
       Built [   9.895s] (baseline)
     Parsing scylla-cql v1.3.1 (baseline)
      Parsed [   0.037s] (baseline)
    Checking scylla-cql v1.3.1 -> v1.3.1 (no change; assume patch)
     Checked [   0.360s] 165 checks: 165 pass, 13 skip
     Summary no semver update required
    Finished [  20.971s] scylla-cql
error: aborting due to failure to build rustdoc for crate scylla v1.3.1

Stack backtrace:
   0: anyhow::error::<impl anyhow::Error>::msg
   1: anyhow::__private::format_err
   2: cargo_semver_checks::data_generation::generate::generate_rustdoc
   3: cargo_semver_checks::data_generation::request::CrateDataRequest::resolve
   4: cargo_semver_checks::rustdoc_gen::StatefulRustdocGenerator<cargo_semver_checks::rustdoc_gen::ReadyState>::load_rustdoc
   5: cargo_semver_checks::Check::check_release
   6: cargo_semver_checks::exit_on_error
   7: cargo_semver_checks::main
   8: std::sys::backtrace::__rust_begin_short_backtrace
   9: main
make: *** [Makefile:73: semver-rev] Error 1

@Lorak-mmk Lorak-mmk self-assigned this Aug 13, 2025
@wprzytula wprzytula requested review from wprzytula and Copilot August 20, 2025 09:02
Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR migrates the entire codebase to Rust 2024 edition while implementing necessary fixes for Clippy changes and bumping the MSRV to 1.85. The primary purpose is to modernize the codebase to take advantage of the latest Rust edition features and improvements.

  • Updates all crates to edition 2024 and changes resolver to v3
  • Fixes import ordering issues introduced by new Clippy lints in Rust 1.89
  • Updates async closure usage in CCM code to utilize new async fn syntax
  • Removes redundant Cargo.lock.msrv file since resolver v3 handles MSRV requirements

Reviewed Changes

Copilot reviewed 123 out of 124 changed files in this pull request and generated no comments.

File Description
Cargo.toml files Updated edition to "2024" and resolver to "3" across all crates
Import statements Reordered imports to satisfy new Clippy lint requirements
CCM library code Modernized async closure syntax and error handling patterns
Various source files Applied automatic formatting changes for edition 2024 compatibility
Comments suppressed due to low confidence (4)

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
semver-checks-breaking cargo-semver-checks reports that this PR introduces breaking API changes
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Migrate to Rust 2024
1 participant