Add rename rule for generated associated constant's base name #1034
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
In FFI Rust code it is often necessary to use constants instead of enums for compatibility reasons. The most natural thing to do to somewhat preserve grouping is to use associated constants. E.g.:
For the above, the generated constants would be called
Foo_FLAG1
&Foo_FLAG2
. Many Linux core C libraries adhere to a slightly different casing, however, where the type prefix is fully upper cased:FOO_FLAG1
. Currently, it does not seem possible to generate such constants.This change introduces a new config option to structured types that enables this use case: the
struct.associated_constants_rename_base_name
option expects a rename rule (as other rename related config options) and applies it to thestruct
base name as used in conjunction with associated constants to form the final name of the constant.