prost: Bug on codegen in ::prost::Enumeration

error[E0119]: conflicting implementations of trait `TryFrom<i32>` for type `grpc_codegen::Action`
   --> /Users/bapperson/Code/MyProjects/valorem/trade-api/target/debug/build/mycodegen/out/mycodegen.v1.rs:341:68
    |
341 | #[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord, ::prost::Enumeration)]
    |                                                                    ^^^^^^^^^^^^^^^^^^^^
    |
    = note: conflicting implementation in crate `core`:
            - impl<T, U> TryFrom<U> for T
              where U: Into<T>;
    = note: this error originates in the derive macro `::prost::Enumeration` (in Nightly builds, run with -Z macro-backtrace for more info)

Using tonic 0.10.1 and prost-types/prost 0.12.1, on building codegen for proto with an enumeration defined:

pub enum Action {
    Buy = 0,
    Sell = 1,
    Invalid = 255,
}

I see this bug, which prevents build from succeeding. This appears to be a regression in 0.9.2->0.10.1 tonic and 0.11.9 prost.

This was also noted in #812 in a recent comment.

About this issue

  • Original URL
  • State: open
  • Created 3 years ago
  • Reactions: 1
  • Comments: 15 (2 by maintainers)

Most upvoted comments

@sukhmel in my case it was generating conflicting code only for enums that are inside a message. Like this:

message SearchEntityRequest {
   enum CategoryType {
    LocationName = 0;
    CustomerName = 1;
    ...
  }
  ...
}

All enums that were outside a message generated correct non-conflicting code.

Seems like this bug is still in prost 0.13.5