Skip to content

Consider adding a where bound (that's already present) #53908

Closed
@CAD97

Description

@CAD97

playground, r/rust thread (includes larger examples)

use std::marker::PhantomData;

pub trait FromPest<'a>: Sized {
    type Rule;
    const RULE: Self::Rule;
}

impl<'a, T> FromPest<'a> for PhantomData<T>
where
    T: FromPest<'a>,
{
    type Rule = T::Rule;
    const RULE: T::Rule = T::RULE;
}
error[E0277]: the trait bound `T: FromPest<'a>` is not satisfied
  --> src/lib.rs:13:5
   |
13 |     const RULE: T::Rule = T::RULE;
   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `FromPest<'a>` is not implemented for `T`
   |
   = help: consider adding a `where T: FromPest<'a>` bound

I'm unsure as to whether this is a compiler bug or something I've missed, but at the very least, this error is less than helpful at exposing the actual issue.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions