JelteF / derive_more

Some more derive(Trait) options
MIT License
1.73k stars 123 forks source link

derive_more::Error panics on associated type bounds #337

Closed RapidPencil closed 8 months ago

RapidPencil commented 8 months ago

Example:

trait Foo {}
impl<T> Foo for T {}

#[derive(Debug, derive_more::Error)]
enum MyError<A, B: Foo> {
    TypeA(A),
    TypeB(B),
}

fn main() {
    let err: MyError<String, i32> = MyError::TypeA("String error".to_owned());
    println!("{:?}", err);
}

errors at compile time with

error: proc-macro derive panicked
 --> src/main.rs:4:17
  |
4 | #[derive(Debug, derive_more::Error)]
  |                 ^^^^^^^^^^^^^^^^^^
  |
  = help: message: expected `,`

For the sake of comparison, replace derive_more::Error with thiserror::Error and this then works.

JelteF commented 8 months ago

Can you try with derive_more v1.0.0-beta.6

RapidPencil commented 8 months ago

Seems to work :+1:

I'm not in the loop: What is the rough ETA for 1.0.0?

JelteF commented 8 months ago

There's two things that we still want to address before the final 1.0.0 release:

  1. https://github.com/JelteF/derive_more/issues/142
  2. https://github.com/JelteF/derive_more/pull/328

But how long it will take us to implement, I don't know (a couple of months seems likely). In general I'd recommend using the 1.0.0-beta.6 release until we release the final 1.0.0 release. It has many fixes and a lot more tests than the 0.99 series. And there won't be many additional breaking changes in the final release.

RapidPencil commented 8 months ago

Alright, tyvm!