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

issue with Self keyword #257

Closed
awestlake87 opened this issue Dec 2, 2017 · 3 comments
Closed

issue with Self keyword #257

awestlake87 opened this issue Dec 2, 2017 · 3 comments

Comments

@awestlake87
Copy link

awestlake87 commented Dec 2, 2017

when I generate this simple protobuf (excerpt taken from s2client-proto), the Self identifier triggers a compile error in rust.

protobuf file:

enum Alliance {
  Self = 1;
  Ally = 2;
  Neutral = 3;
  Enemy = 4;
}

generated code (using programmatic protoc-rust in build.rs)

...
#[derive(Clone,PartialEq,Eq,Debug,Hash)]
pub enum Alliance {
    Self = 1,
    Ally = 2,
    Neutral = 3,
    Enemy = 4,
}
...

Is Self supposed to be suffixed with _pb since it's a keyword?

@stepancheg
Copy link
Owner

Enum values are not escaped now. Going to look how hard is to fix it.

@stepancheg
Copy link
Owner

I've created a patch (currently testing) which adds value_ prefix to keywords, so Self becomes value_Self.

For a long time already field names which are rust keywords are prefixed with field_, so I followed this scheme.

Not sure about naming.

stepancheg added a commit that referenced this issue Dec 3, 2017
@stepancheg
Copy link
Owner

Published fix as 1.4.3.

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