Rollup merge of #119376 - msrd0:regression-test-106630, r=petrochenkov

Add regression test for #106630

This PR adds a regression test for #106630. I was unsure where exactly to place the test or how to test it locally so please let me know if I should change something.
This commit is contained in:
Matthias Krüger 2023-12-28 18:48:01 +01:00 committed by GitHub
commit 77c23b3e94
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -0,0 +1,33 @@
// edition:2018
// run-pass
use std::future::Future;
trait AsyncCallback<'a> {
type Out;
}
impl<'a, Fut, T, F> AsyncCallback<'a> for F
where
F: FnOnce(&'a mut ()) -> Fut,
Fut: Future<Output = T> + Send + 'a,
{
type Out = T;
}
trait CallbackMarker {}
impl<F, T> CallbackMarker for F
where
T: 'static,
for<'a> F: AsyncCallback<'a, Out = T> + Send,
{
}
fn do_sth<F: CallbackMarker>(_: F) {}
async fn callback(_: &mut ()) -> impl Send {}
fn main() {
do_sth(callback);
}