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

Message with enum field containing keyword generates illegal code. #295

Closed
peterhuene opened this issue May 27, 2018 · 3 comments
Closed

Comments

@peterhuene
Copy link

peterhuene commented May 27, 2018

Repro Steps

Compile the following proto file:

syntax = "proto3";

package Example;

enum E {
  in = 0; // Uses the Rust 'in' keyword
}

message M {
  E e = 1;
}

Expected Results

The generated Rust code compiles.

Actual Results

The enum E is generated correctly:

#[derive(Clone,PartialEq,Eq,Debug,Hash)]
pub enum E {
    value_in = 0,
}

However, the following methods of M reference E::in instead of E::value_in:

  • clear_e
  • compute_size
  • write_to_with_cached_sizes

This leads to three compilation errors: expected identifier, found keyword.

@peterhuene
Copy link
Author

Thanks for the quick response, @stepancheg!

@stepancheg
Copy link
Owner

You are welcome! Going to backport it to stable branches now.

@stepancheg
Copy link
Owner

stepancheg commented May 27, 2018

Published versions 2.0.1 and 1.7.2.

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