]> git.lizzy.rs Git - rust.git/blob - src/test/ui/generic-associated-types/issue-91883.rs
Auto merge of #99612 - yanchen4791:issue-95079-fix, r=compiler-errors
[rust.git] / src / test / ui / generic-associated-types / issue-91883.rs
1 #![feature(generic_associated_types)]
2
3 use std::fmt::Debug;
4 use std::marker::PhantomData;
5
6 #[derive(Debug)]
7 pub struct TransactionImpl<'db> {
8     _marker: PhantomData<&'db ()>,
9 }
10
11 #[derive(Debug)]
12 pub struct CursorImpl<'txn> {
13     _marker: PhantomData<&'txn ()>,
14 }
15
16 pub trait Cursor<'txn> {}
17
18 pub trait Transaction<'db>: Send + Sync + Debug + Sized {
19     type Cursor<'tx>: Cursor<'tx>
20     where
21         'db: 'tx,
22         Self: 'tx;
23
24     fn cursor<'tx>(&'tx self) -> Result<Self::Cursor<'tx>, ()>
25     where
26         'db: 'tx;
27 }
28
29 impl<'tx> Cursor<'tx> for CursorImpl<'tx> {}
30
31 impl<'db> Transaction<'db> for TransactionImpl<'db> {
32     type Cursor<'tx> = CursorImpl<'tx>; //~ ERROR lifetime bound not satisfied
33
34     fn cursor<'tx>(&'tx self) -> Result<Self::Cursor<'tx>, ()>
35     where
36         'db: 'tx,
37     {
38         loop {}
39     }
40 }
41
42 fn main() {}