2022-02-17 07:55:58 -06:00
|
|
|
#![feature(type_alias_impl_trait)]
|
|
|
|
|
|
|
|
// edition:2021
|
2022-07-28 10:22:02 -05:00
|
|
|
// compile-flags:-Z treat-err-as-bug=1
|
2023-05-01 03:05:05 -05:00
|
|
|
// error-pattern: aborting due to `-Z treat-err-as-bug=1`
|
2022-07-28 10:22:02 -05:00
|
|
|
// failure-status:101
|
2023-05-01 03:05:05 -05:00
|
|
|
// normalize-stderr-test ".*note: .*\n\n" -> ""
|
|
|
|
// normalize-stderr-test "thread 'rustc' panicked.*\n" -> ""
|
|
|
|
// rustc-env:RUST_BACKTRACE=0
|
2022-02-17 07:55:58 -06: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 04:58:59 -06:00
|
|
|
) -> impl FnOnce(&mut dyn Transaction) -> TransactionFuture<'_, O>
|
2022-02-17 07:55:58 -06:00
|
|
|
where
|
2022-03-11 04:58:59 -06:00
|
|
|
F: FnOnce(&mut dyn Transaction) -> TransactionFuture<'_, O> + 'f
|
2022-02-17 07:55:58 -06:00
|
|
|
{
|
|
|
|
f
|
|
|
|
}
|
|
|
|
|
|
|
|
impl Context {
|
|
|
|
async fn do_transaction<O>(
|
2022-03-11 04:58:59 -06:00
|
|
|
&self, f: impl FnOnce(&mut dyn Transaction) -> TransactionFuture<'_, O>
|
2022-02-17 07:55:58 -06:00
|
|
|
) -> TransactionResult<O>
|
|
|
|
{
|
|
|
|
let mut conn = Connection {};
|
|
|
|
let mut transaction = TestTransaction { conn: &mut conn };
|
|
|
|
f(&mut transaction).await
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
fn main() {}
|