capnproto-rust
capnproto-rust copied to clipboard
Annotation and struct module names can conflict
In the capnp docs they mention a pattern where an annotation and the struct for its value share the same name.
struct Grault {
value @0 :Int32 = 123;
}
annotation grault(file) :Grault;
Because both annations and structs get corresponding rust modules the generated code won't build.
I'm not sure what the right solution is here. A robust but maybe annoying option would be to add a prefix to annotation modules so you get something like annotation_grault and grault. Just naming the struct GraultOpts isn't a big deal either.
One thing we could do is make the $Rust.name annotation work on annotations: https://github.com/capnproto/capnproto-rust/blob/977b3db3f97c142a0d6dff50302aa42908858fc9/capnpc/rust.capnp#L9