Skip to content

Cannot derive on enum with variants wrapping associated types #85

@SuperFluffy

Description

@SuperFluffy

Using the most recent thiserror, I am getting an error when trying to compile the following example:

use thiserror::Error;

trait AssocError {
    type Error: std::error::Error;
}

#[derive(Error, Debug)]
pub enum MyExpandedError<A>
where
    A: AssocError,
{
    #[error("My Foo error")]
    Foo,
    #[error("Error from associated type")]
    Assoc(#[from] A::Error),
}

And this is the error:

error[E0119]: conflicting implementations of trait `std::convert::From<MyExpandedError<_>>` for type `MyExpandedError<_>`:
 --> src/lib.rs:7:10
  |
7 | #[derive(Error, Debug)]
  |          ^^^^^
  |
  = note: conflicting implementation in crate `core`:
          - impl<T> std::convert::From<T> for T;
  = note: this error originates in a derive macro (in Nightly builds, run with -Z macro-backtrace for more info)

error: aborting due to previous error

For more information about this error, try `rustc --explain E0119`.
error: could not compile `thiserror_from`.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions