1 #![feature(generic_associated_types)]
4 type Cursor<'a>: DocCursor<'a>;
5 //~^ ERROR: missing required bound on `Cursor`
7 fn cursor(&self) -> Self::Cursor<'_>;
10 struct DocumentImpl {}
12 impl Document for DocumentImpl {
13 type Cursor<'a> = DocCursorImpl<'a>;
15 fn cursor(&self) -> Self::Cursor<'_> {
16 DocCursorImpl { document: &self }
20 trait DocCursor<'a> {}
22 struct DocCursorImpl<'a> {
23 document: &'a DocumentImpl,
26 impl<'a> DocCursor<'a> for DocCursorImpl<'a> {}
28 struct Lexer<'d, Cursor>
30 Cursor: DocCursor<'d>,
33 _phantom: std::marker::PhantomData<&'d ()>,
36 impl<'d, Cursor> Lexer<'d, Cursor>
38 Cursor: DocCursor<'d>,
40 pub fn from<Doc>(document: &'d Doc) -> Lexer<'d, Cursor>
42 Doc: Document<Cursor<'d> = Cursor>,
44 Lexer { cursor: document.cursor(), _phantom: std::marker::PhantomData }
48 fn create_doc() -> impl Document<Cursor<'_> = DocCursorImpl<'_>> {
49 //~^ ERROR `'_` cannot be used here [E0637]
50 //~| ERROR: missing lifetime specifier
55 let doc = create_doc();
56 let lexer: Lexer<'_, DocCursorImpl<'_>> = Lexer::from(&doc);