Skip to content

Unsupported raw identifiers in 0.5 #179

Closed
@fujiapple852

Description

I have a proto file (that I do not control) which contains a field named self (of type Unit). In PROST 0.4 this is generated as Self_ which works whereas in PROST 0.5 it is generated as r#Self which fails to compile in stable rust (1.34) with r#Self is not currently supported (see discussion on why here).

Workaround is either to use PROST 0.4 (which in turn forces using Rust 2015 and therefore the PROST generated code needs to be in a separate crate for Rust 2018 projects) or some clunky pre or post processing of the proto file or generated code.

Suggested fix: revert to appending an _ to keyword identifiers for the list of 5 keywords not supported by raw identifiers.

Aside: I tried using the field_attributes option to prepend an _ to the field but this doesn't work as it is rendered as a separate token to the identifier:

    #[prost(message, tag="1")]
    _
    r#Self(super::Unit),

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions