Skip to content
This repository has been archived by the owner on May 23, 2024. It is now read-only.

ices/70303.rs: fixed with errors #638

Merged
merged 1 commit into from
Feb 6, 2021
Merged

Conversation

github-actions[bot]
Copy link
Contributor

@github-actions github-actions bot commented Feb 6, 2021

Issue: rust-lang/rust#70303

#![feature(generic_associated_types)]
#![allow(dead_code, incomplete_features)]
#![crate_type = "lib"]

trait Document {
    type Cursor<'a>: DocCursor<'a>;

    fn cursor(&self) -> Self::Cursor<'_>;
}

struct DocumentImpl {}

impl Document for DocumentImpl {
    type Cursor<'a> = DocCursorImpl<'a>;

    fn cursor(&self) -> Self::Cursor<'_> {
        DocCursorImpl { document: &self }
    }
}

trait DocCursor<'a> {}

struct DocCursorImpl<'a> {
    document: &'a DocumentImpl,
}

impl<'a> DocCursor<'a> for DocCursorImpl<'a> {}

struct Lexer<'d, Cursor>
where
    Cursor: DocCursor<'d>,
{
    cursor: Cursor,
    _phantom: std::marker::PhantomData<&'d ()>,
}

impl<'d, Cursor> Lexer<'d, Cursor>
where
    Cursor: DocCursor<'d>,
{
    pub fn from<Doc>(document: &'d Doc) -> Lexer<'d, Cursor>
    where
        Doc: Document<Cursor = Cursor>,
    {
        Lexer {
            cursor: document.cursor(),
            _phantom: std::marker::PhantomData,
        }
    }
}

pub fn test() {
    let doc = DocumentImpl {};
    let _lexer: Lexer<'_, DocCursorImpl<'_>> = Lexer::from(&doc);
}
=== stdout ===
=== stderr ===
error[E0107]: missing generics for associated type `Document::Cursor`
 --> /home/runner/work/glacier/glacier/ices/70303.rs:6:10
  |
6 |     type Cursor<'a>: DocCursor<'a>;
  |          ^^^^^^ expected 1 lifetime argument
  |
note: associated type defined here, with 1 lifetime parameter: `'a`
 --> /home/runner/work/glacier/glacier/ices/70303.rs:6:10
  |
6 |     type Cursor<'a>: DocCursor<'a>;
  |          ^^^^^^ --
help: use angle brackets to add missing lifetime argument
  |
6 |     type Cursor<'a><'a>: DocCursor<'a>;
  |                ^^^^

error: aborting due to previous error

For more information about this error, try `rustc --explain E0107`.
==============

=== stdout ===
=== stderr ===
error[E0107]: missing generics for associated type `Document::Cursor`
 --> /home/runner/work/glacier/glacier/ices/70303.rs:6:10
  |
6 |     type Cursor<'a>: DocCursor<'a>;
  |          ^^^^^^ expected 1 lifetime argument
  |
note: associated type defined here, with 1 lifetime parameter: `'a`
 --> /home/runner/work/glacier/glacier/ices/70303.rs:6:10
  |
6 |     type Cursor<'a>: DocCursor<'a>;
  |          ^^^^^^ --
help: use angle brackets to add missing lifetime argument
  |
6 |     type Cursor<'a><'a>: DocCursor<'a>;
  |                ^^^^

error: aborting due to previous error

For more information about this error, try `rustc --explain E0107`.
==============
@Alexendoo Alexendoo merged commit b16b5e9 into master Feb 6, 2021
@Alexendoo Alexendoo deleted the autofix/ices/70303.rs branch February 6, 2021 13:42
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants