add a ui test for issue #91883
This commit is contained in:
parent
d40f24e956
commit
30724ebc17
42
src/test/ui/generic-associated-types/issue-91883.rs
Normal file
42
src/test/ui/generic-associated-types/issue-91883.rs
Normal file
@ -0,0 +1,42 @@
|
|||||||
|
#![feature(generic_associated_types)]
|
||||||
|
|
||||||
|
use std::fmt::Debug;
|
||||||
|
use std::marker::PhantomData;
|
||||||
|
|
||||||
|
#[derive(Debug)]
|
||||||
|
pub struct TransactionImpl<'db> {
|
||||||
|
_marker: PhantomData<&'db ()>,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Debug)]
|
||||||
|
pub struct CursorImpl<'txn> {
|
||||||
|
_marker: PhantomData<&'txn ()>,
|
||||||
|
}
|
||||||
|
|
||||||
|
pub trait Cursor<'txn> {}
|
||||||
|
|
||||||
|
pub trait Transaction<'db>: Send + Sync + Debug + Sized {
|
||||||
|
type Cursor<'tx>: Cursor<'tx>
|
||||||
|
where
|
||||||
|
'db: 'tx,
|
||||||
|
Self: 'tx;
|
||||||
|
|
||||||
|
fn cursor<'tx>(&'tx self) -> Result<Self::Cursor<'tx>, ()>
|
||||||
|
where
|
||||||
|
'db: 'tx;
|
||||||
|
}
|
||||||
|
|
||||||
|
impl<'tx> Cursor<'tx> for CursorImpl<'tx> {}
|
||||||
|
|
||||||
|
impl<'db> Transaction<'db> for TransactionImpl<'db> {
|
||||||
|
type Cursor<'tx> = CursorImpl<'tx>; //~ ERROR lifetime bound not satisfied
|
||||||
|
|
||||||
|
fn cursor<'tx>(&'tx self) -> Result<Self::Cursor<'tx>, ()>
|
||||||
|
where
|
||||||
|
'db: 'tx,
|
||||||
|
{
|
||||||
|
loop {}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fn main() {}
|
26
src/test/ui/generic-associated-types/issue-91883.stderr
Normal file
26
src/test/ui/generic-associated-types/issue-91883.stderr
Normal file
@ -0,0 +1,26 @@
|
|||||||
|
error[E0478]: lifetime bound not satisfied
|
||||||
|
--> $DIR/issue-91883.rs:32:24
|
||||||
|
|
|
||||||
|
LL | / type Cursor<'tx>: Cursor<'tx>
|
||||||
|
LL | | where
|
||||||
|
LL | | 'db: 'tx,
|
||||||
|
LL | | Self: 'tx;
|
||||||
|
| |__________________- definition of `Cursor` from trait
|
||||||
|
...
|
||||||
|
LL | type Cursor<'tx> = CursorImpl<'tx>;
|
||||||
|
| ^^^^^^^^^^^^^^^- help: try copying these clauses from the trait: `where 'db: 'tx, Self: 'tx`
|
||||||
|
|
|
||||||
|
note: lifetime parameter instantiated with the lifetime `'db` as defined here
|
||||||
|
--> $DIR/issue-91883.rs:31:6
|
||||||
|
|
|
||||||
|
LL | impl<'db> Transaction<'db> for TransactionImpl<'db> {
|
||||||
|
| ^^^
|
||||||
|
note: but lifetime parameter must outlive the lifetime `'tx` as defined here
|
||||||
|
--> $DIR/issue-91883.rs:32:17
|
||||||
|
|
|
||||||
|
LL | type Cursor<'tx> = CursorImpl<'tx>;
|
||||||
|
| ^^^
|
||||||
|
|
||||||
|
error: aborting due to previous error
|
||||||
|
|
||||||
|
For more information about this error, try `rustc --explain E0478`.
|
Loading…
Reference in New Issue
Block a user