-
Notifications
You must be signed in to change notification settings - Fork 527
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Adding #[derive(Eq)] to type_attribute conflicts with the generated code for Enumeration #332
Comments
IMHO adding it to each message specifically is impractical because if you have even 20 messages, it's already a lot to do by hand, but what if one has 100 different messages? I think there should be a way to add type_attribute to all messages or to all enums. |
See also #371 |
Hitting this also. Ideally would be great of prost-build could just merge derives. Only workaround I could find is to manually list out every non-enum to add Having some visibility into what prost-build is doing via visitors (or just being able to add a pass that runs over all types) would be a really nice escape hatch for this kind of stuff. |
I just ran into this because Rust 1.63.0 now has a new Clippy lint for deriving Like @robo-corg said, being able to merge derives would help. This would presumably work not by parsing out the Alternatively there could be some solution specific to |
Imho prost shouldn't be deriving Eq over encoded messages and esp protobuf which have a lot of backwards/forward compat featuers. C++ provides this https://developers.google.com/protocol-buffers/docs/reference/cpp/google.protobuf.util.message_differencer which we could try to implement but requires features we are missing. We could add that derive iterator feature but in addition, there are many things that we can add to decorate the codegen and I am not really happy with the current approach. It doesn't feel sustainable to use |
@LucioFranco That makes sense. The use case I was using it for was using protobufs as keys in a The right call here seems like allowing |
I got bitten by this bug: tokio-rs/prost#332 when I added the enum `ShieldedProtocol` to the file `service.proto`. The problem is that `prost` implicitly derives `Eq` for enums, so deriving it explicitly via `type_attribute` causes a conflict. Lukily, there is another method `message_attribute` that operates only on messages and not enums.
I solved this issue by calling message_attribute instead of type_attribute. |
* Add lightwalletd's protobuf types * Don't explicitly derive `Eq` for enums I got bitten by this bug: tokio-rs/prost#332 when I added the enum `ShieldedProtocol` to the file `service.proto`. The problem is that `prost` implicitly derives `Eq` for enums, so deriving it explicitly via `type_attribute` causes a conflict. Lukily, there is another method `message_attribute` that operates only on messages and not enums. * Test the `z_getsubtreesbyindex` RPC * Fix a typo * Add test vectors
* Add lightwalletd's protobuf types * Don't explicitly derive `Eq` for enums I got bitten by this bug: tokio-rs/prost#332 when I added the enum `ShieldedProtocol` to the file `service.proto`. The problem is that `prost` implicitly derives `Eq` for enums, so deriving it explicitly via `type_attribute` causes a conflict. Lukily, there is another method `message_attribute` that operates only on messages and not enums. * Test the `z_getsubtreesbyindex` RPC * Fix a typo * Add test vectors
The original issue is indeed solved by using |
The following code stated in the documentation won't work, because enums already derive from Eq, so it produces an error.
Here is an error:
How to add
#[derive(Eq)]
only to all Messages?The text was updated successfully, but these errors were encountered: