2022-02-17 13:55:58 +00:00
|
|
|
#![feature(type_alias_impl_trait)]
|
|
|
|
|
2024-02-16 20:02:50 +00:00
|
|
|
//@ edition:2021
|
|
|
|
//@ compile-flags:-Z treat-err-as-bug=2
|
|
|
|
//@ error-pattern: due to `-Z treat-err-as-bug=2
|
|
|
|
//@ failure-status:101
|
|
|
|
//@ normalize-stderr-test ".*note: .*\n\n" -> ""
|
|
|
|
//@ normalize-stderr-test "thread 'rustc' panicked.*:\n.*\n" -> ""
|
|
|
|
//@ rustc-env:RUST_BACKTRACE=0
|
2022-02-17 13:55:58 +00:00
|
|
|
|
|
|
|
use std::future::Future;
|
|
|
|
|
|
|
|
struct Connection {
|
|
|
|
}
|
|
|
|
|
|
|
|
trait Transaction {
|
|
|
|
}
|
|
|
|
|
|
|
|
struct TestTransaction<'conn> {
|
|
|
|
conn: &'conn Connection
|
|
|
|
}
|
|
|
|
|
|
|
|
impl<'conn> Transaction for TestTransaction<'conn> {
|
|
|
|
}
|
|
|
|
|
|
|
|
struct Context {
|
|
|
|
}
|
|
|
|
|
|
|
|
type TransactionResult<O> = Result<O, ()>;
|
|
|
|
|
|
|
|
type TransactionFuture<'__, O> = impl '__ + Future<Output = TransactionResult<O>>;
|
|
|
|
|
|
|
|
fn execute_transaction_fut<'f, F, O>(
|
|
|
|
f: F,
|
2022-03-11 10:58:59 +00:00
|
|
|
) -> impl FnOnce(&mut dyn Transaction) -> TransactionFuture<'_, O>
|
2022-02-17 13:55:58 +00:00
|
|
|
where
|
2022-03-11 10:58:59 +00:00
|
|
|
F: FnOnce(&mut dyn Transaction) -> TransactionFuture<'_, O> + 'f
|
2022-02-17 13:55:58 +00:00
|
|
|
{
|
|
|
|
f
|
|
|
|
}
|
|
|
|
|
|
|
|
impl Context {
|
|
|
|
async fn do_transaction<O>(
|
2022-03-11 10:58:59 +00:00
|
|
|
&self, f: impl FnOnce(&mut dyn Transaction) -> TransactionFuture<'_, O>
|
2022-02-17 13:55:58 +00:00
|
|
|
) -> TransactionResult<O>
|
|
|
|
{
|
|
|
|
let mut conn = Connection {};
|
|
|
|
let mut transaction = TestTransaction { conn: &mut conn };
|
|
|
|
f(&mut transaction).await
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
fn main() {}
|