Skip to content
This repository has been archived by the owner on Apr 8, 2024. It is now read-only.

Avoid collisions with protobuf fields that are rust keywords #179

Open
DazWilkin opened this issue Apr 13, 2020 · 0 comments
Open

Avoid collisions with protobuf fields that are rust keywords #179

DazWilkin opened this issue Apr 13, 2020 · 0 comments

Comments

@DazWilkin
Copy link

E.g. googleapis/google/api/auth.proto#JwtLocation:

// Specifies a location to extract JWT from an API request.
message JwtLocation {
  oneof in {
    // Specifies HTTP header name to extract JWT token.
    string header = 1;

    // Specifies URL query parameter name to extract JWT token.
    string query = 2;
  }

protoc_rust_grpc generates:

auth.rs:

#[derive(PartialEq,Clone,Default)]
pub struct JwtLocation {
    // message fields
    pub value_prefix: ::std::string::String,
    // message oneof groups
    pub in: ::std::option::Option<JwtLocation_oneof_in>,
    // special fields
    pub unknown_fields: ::protobuf::UnknownFields,
    pub cached_size: ::protobuf::CachedSize,
}

Results in:

expected identifier, found keyword `in`

expected identifier, found keyword

help: you can escape reserved keywords to use them as identifiers: `r#in`

It's unclear to me whether prefixing all|keyword fields with raw string literals would address this issue comprehensively.

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

No branches or pull requests

1 participant