JelteF / derive_more

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

Ambiguous associated item error when deriving `TryFrom`, `TryInto` or `FromStr` #409

Closed bluurryy closed 1 month ago

bluurryy commented 2 months ago

Deriving TryFrom, TryInto or FromStr when there's an associated item called Error or Err will fail.

All of these derives fail:

use derive_more::*;

#[derive(TryFrom)]
#[try_from(repr)]
#[repr(u8)]
enum LogLevel {
    Error,
}

#[derive(FromStr)]
enum EnumNoFields {
    Err,
}

#[derive(TryInto)]
enum MixedInts {
    Foo(LogLevel),
}

I will send a PR shortly that will fix this issue.