Skip to content

Commit 5efe7c7

Browse files
authoredJun 26, 2022
Rollup merge of rust-lang#98538 - TaKO8Ki:add-test-for-issue-91883, r=Mark-Simulacrum
Add a ui test for issue rust-lang#91883 closes rust-lang#91883
2 parents 50b6e7d + 30724eb commit 5efe7c7

File tree

2 files changed

+68
-0
lines changed

2 files changed

+68
-0
lines changed
 
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
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() {}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
error[E0478]: lifetime bound not satisfied
2+
--> $DIR/issue-91883.rs:32:24
3+
|
4+
LL | / type Cursor<'tx>: Cursor<'tx>
5+
LL | | where
6+
LL | | 'db: 'tx,
7+
LL | | Self: 'tx;
8+
| |__________________- definition of `Cursor` from trait
9+
...
10+
LL | type Cursor<'tx> = CursorImpl<'tx>;
11+
| ^^^^^^^^^^^^^^^- help: try copying these clauses from the trait: `where 'db: 'tx, Self: 'tx`
12+
|
13+
note: lifetime parameter instantiated with the lifetime `'db` as defined here
14+
--> $DIR/issue-91883.rs:31:6
15+
|
16+
LL | impl<'db> Transaction<'db> for TransactionImpl<'db> {
17+
| ^^^
18+
note: but lifetime parameter must outlive the lifetime `'tx` as defined here
19+
--> $DIR/issue-91883.rs:32:17
20+
|
21+
LL | type Cursor<'tx> = CursorImpl<'tx>;
22+
| ^^^
23+
24+
error: aborting due to previous error
25+
26+
For more information about this error, try `rustc --explain E0478`.

0 commit comments

Comments
 (0)
Please sign in to comment.