Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

macros: allow temporary lifetime extension in select #6722

Merged
merged 2 commits into from
Jul 26, 2024

Conversation

Darksonn
Copy link
Contributor

In the 1.39.0 release, we merged #6710 which allows the use of IntoFuture values with tokio::select!. Unfortunately, this resulted in a breaking change where the macro would no longer accept expressions that make use of temporary lifetime extension. This PR fixes the breaking change.

Fixes: #6721

@Darksonn Darksonn added A-tokio Area: The main tokio crate M-macros Module: macros in the main Tokio crate labels Jul 25, 2024
@Darksonn Darksonn requested a review from mox692 July 25, 2024 09:16
Comment on lines +713 to +719
// regression test for https://github.com/tokio-rs/tokio/issues/6721
#[tokio::test]
async fn temporary_lifetime_extension() {
tokio::select! {
() = &mut std::future::ready(()) => {},
}
}
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I have verified that this test does not compile without the fix.

// Safety: Nothing must be moved out of `futures`. This is to
// satisfy the requirement of `Pin::new_unchecked` called below.
//
// We can't use the `pin!` macro for this because `futures` is a
// tuple and the standard library provides no way to pin-project to
// the fields of a tuple.
let mut futures = ( $( $crate::macros::support::IntoFuture::into_future($fut) , )+ );
let mut futures = ($( $crate::macros::support::IntoFuture::into_future(
$crate::count_field!( futures_init.$($skip)* )
Copy link
Contributor

Choose a reason for hiding this comment

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

Should we delete some indentations here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Shrug.

@Darksonn Darksonn merged commit 438def7 into master Jul 26, 2024
80 checks passed
@Darksonn Darksonn deleted the alice/select-temp-lifetime-extension branch July 26, 2024 16:36
kodiakhq bot pushed a commit to pdylanross/fatigue that referenced this pull request Jul 29, 2024
Bumps tokio from 1.39.1 to 1.39.2.

Release notes
Sourced from tokio's releases.

Tokio v1.39.2
1.39.2 (July 27th, 2024)
This release fixes a regression where the select! macro stopped accepting expressions that make use of temporary lifetime extension. (#6722)
#6722: tokio-rs/tokio#6722



Commits

f602eae chore: prepare Tokio v1.39.2 (#6730)
438def7 macros: allow temporary lifetime extension in select (#6722)
ee8d4d1 chore: fix ci failures (#6725)
3297052 ci: test Quinn in CI (#6719)
See full diff in compare view




Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting @dependabot rebase.


Dependabot commands and options

You can trigger Dependabot actions by commenting on this PR:

@dependabot rebase will rebase this PR
@dependabot recreate will recreate this PR, overwriting any edits that have been made to it
@dependabot merge will merge this PR after your CI passes on it
@dependabot squash and merge will squash and merge this PR after your CI passes on it
@dependabot cancel merge will cancel a previously requested merge and block automerging
@dependabot reopen will reopen this PR if it is closed
@dependabot close will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually
@dependabot show <dependency name> ignore conditions will show all of the ignore conditions of the specified dependency
@dependabot ignore this major version will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself)
@dependabot ignore this minor version will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself)
@dependabot ignore this dependency will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-tokio Area: The main tokio crate M-macros Module: macros in the main Tokio crate
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Help/Bug] tokio::select fails to compile with temporary value dropped while borrowed from version 1.39.1
4 participants