Skip to content

add regression test for rust-lang#101650 #141094

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

Merged
merged 1 commit into from
May 19, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 24 additions & 0 deletions tests/ui/async-await/format-await-send.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
// regression test for <https://github.com/rust-lang/rust/issues/101650>
// assert that Future which has format!() with an async function is Send

#![allow(unused)]

//@ check-pass
//@ edition: 2018

use core::future::Future;
use core::pin::Pin;

fn build_string() -> Pin<Box<dyn Future<Output = String> + Send>> {
Box::pin(async move {
let mut string_builder = String::new();
string_builder += &format!("Hello {}", helper().await);
string_builder
Comment on lines +14 to +16
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
let mut string_builder = String::new();
string_builder += &format!("Hello {}", helper().await);
string_builder
format!("Hello {}", helper().await)

this should also already test test, does it not?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

According to that comment, format!(..) and string += &format!(..); are separate cases. The format!(..) case has already been tested in this file.

Also, it might be better to move the test into tests/ui/fmt and give it a new name.

})
}

async fn helper() -> String {
"World".to_string()
}

fn main() {}
Loading