Skip to content

migrate most remaining crates to Rust 2024 Edition#22686

Merged
tdyas merged 4 commits intomainfrom
rust/2024/various-2
Sep 22, 2025
Merged

migrate most remaining crates to Rust 2024 Edition#22686
tdyas merged 4 commits intomainfrom
rust/2024/various-2

Conversation

@tdyas
Copy link
Copy Markdown
Contributor

@tdyas tdyas commented Sep 21, 2025

Migrate most of the remaining crates to Rust 2024 Edition. Basically, task_executor is excluded from this PR due to task_executor::Executor::spawn_blocking needing some further thought.

error[E0716]: temporary value dropped while borrowed
   --> ui/src/instance/prodash.rs:170:21
    |
170 |         w.write_fmt(format_workunit_duration_ms!(elapsed_ms))
    |           --------- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    |           |         |
    |           |         creates a temporary value which is freed while still in use
    |           |         temporary value is freed at the end of this statement
    |           borrow later used by call
    |
    = note: consider using a `let` binding to create a longer lived value
    = note: this error originates in the macro `format_workunit_duration_ms` (in Nightly builds, run with -Z macro-backtrace for more info)
@tdyas tdyas requested review from benjyw and sureshjoshi September 21, 2025 19:03
@tdyas tdyas added category:internal CI, fixes for not-yet-released features, etc. release-notes:not-required [CI] PR doesn't require mention in release notes labels Sep 21, 2025
#[macro_export]
macro_rules! format_workunit_duration_ms {
($workunit_duration_ms:expr) => {{ format_args!("{:.2}s", ($workunit_duration_ms as f64) / 1000.0) }};
pub fn format_workunit_duration_ms(duration: Duration) -> String {
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I converted this a regular function because the changes to lifetimes for temporary values in Rust 2024 Edition triggered this error:

    error[E0716]: temporary value dropped while borrowed
       --> ui/src/instance/prodash.rs:170:21
        |
    170 |         w.write_fmt(format_workunit_duration_ms!(elapsed_ms))
        |           --------- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
        |           |         |
        |           |         creates a temporary value which is freed while still in use
        |           |         temporary value is freed at the end of this statement
        |           borrow later used by call
        |
        = note: consider using a `let` binding to create a longer lived value
        = note: this error originates in the macro `format_workunit_duration_ms` (in Nightly builds, run with -Z macro-backtrace for more info)

@tdyas
Copy link
Copy Markdown
Contributor Author

tdyas commented Sep 21, 2025

The task_executor::Executor::spawn_blocking method in the task_executor crate needs some thought due to changes in Rust 2024 Edition capture rules for impl Trait in return position. Errors like this occurred:

  --> ui/src/instance/prodash.rs:102:9
    |
102 | //         self.executor
103 | ||             .clone()
    | ||____________________- temporary value created here
104 | |              .spawn_blocking(
105 | |                  move || self.handle.shutdown_and_wait(),
...   |
108 | |              .boxed()
    | |_____________________^ returns a value referencing data owned by the current function
    |
note: this call may capture more lifetimes than intended, because Rust 2024 has adjusted the `impl Trait` lifetime capture rules

So task_executor remains to be migrated to 2024 Edition.

@tdyas
Copy link
Copy Markdown
Contributor Author

tdyas commented Sep 21, 2025

https://blog.rust-lang.org/2024/09/05/impl-trait-capture-rules/ describes the lifetime capture changes for return-position impl Trait in 2024 Edition.

@tdyas
Copy link
Copy Markdown
Contributor Author

tdyas commented Sep 21, 2025

task_executor crate is migrated in #22688.

@tdyas tdyas merged commit a657fe0 into main Sep 22, 2025
24 checks passed
@tdyas tdyas deleted the rust/2024/various-2 branch September 22, 2025 01:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

category:internal CI, fixes for not-yet-released features, etc. release-notes:not-required [CI] PR doesn't require mention in release notes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants