rfcs
rfcs copied to clipboard
RFC: Autogenerated Attribute
Summary
This RFC introduces an attribute for marking files as autogenerated. This syntax can be used by everything from rustbindgen to protoc (protobuf compiler) and understood by humans and tools alike.
mod foo {
#![autogenerated(
by = "example tool",
suppress_lints = false,
format = true,
regen_hint = "./regen_example_tool",
document = false,
stable_api = true,
)]
// autogenerated code here...
}
Consider alternative: use @generated text in comments, which is used by Meta, and adopted by various tools already (in particular, rustfmt understands it). Like this:
// @generated by my schema compiler
The advantage of @generated marker is that
- it is not specific to rust
- tools that need to understand whether the file is generated do not need to parse rust syntax; only check for for
@generatedmarker in the file header - easier to implement on both generator and parser site
This proposal RFC might be over-engineered a bit: in 99% of cases one just needs to know whether file is generated or not.
I love this idea it would be great for wgsl_to_wgpu's bindgen.
Notes:
- I feel that
regen_hintshould be split intoregen_perams(array) andregen_cmd(string) byshould have a related version field, so the tool version can be identified, maybe renaming it togeneratorwith an optionalgenerator_version