Skip to content
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

Cannot compile when enum is map value #376

Closed
quininer opened this issue Jan 14, 2019 · 2 comments
Closed

Cannot compile when enum is map value #376

quininer opened this issue Jan 14, 2019 · 2 comments

Comments

@quininer
Copy link

quininer commented Jan 14, 2019

syntax = "proto2";

enum Command {
	AAA = 0;
}

message CommandMap {
	map<string, Command> map = 1;
}
error[E0277]: the trait bound `bad::Command: std::default::Default` is not satisfied
  --> src/bad.rs:74:21
   |
74 |                     ::protobuf::rt::read_map_into::<::protobuf::types::ProtobufTypeString, ::protobuf::types::ProtobufTypeEnum<Command>>(wire_type, is, &mut self.map)?;
   |                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `std::default::Default` is not implemented for `bad::Command`
   |
   = note: required by `protobuf::rt::read_map_into`
stepancheg added a commit that referenced this issue Jan 29, 2019
stepancheg added a commit that referenced this issue Jan 29, 2019
@stepancheg
Copy link
Owner

The issue is implicitly fixed in master where all enums implement Default.

I decided to create a new stable branch — v2.3 — and cherry-pick that change from master. I think it would be backwards compatible, and proper fix not very trivial.

@stepancheg
Copy link
Owner

Published v2.3.0. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants