Name clash in generated Rust code (regression in 2.0.0)
- Dominant language
- C++
- Stars
- 26.5k
- Forks
- 3.7k
- PR merge metrics
- No merged PRs in 30d
Description
The following worked fine in 0.12:
```
union stage {LS_IN_PRE_LB, LS_OUT_PRE_LB}
table __Table_stage {
v: stage;
}
table Flow {
stage: stage; // NOTE: field name shadows union name, which is valid `.fbs` syntax
}
```
but in 2.0.0, I get the following error:
```
error[E0530]: function parameters cannot shadow tuple structs
--> src/flatbuf_generated.rs:3658:31
|
42 | pub struct stage(pub u8);
| ------------------------- the tuple struct `stage` is defined here
...
3658 | pub fn add_stage(&mut self, stage: flatbuffers::WIPOffset) {
| ^^^^^ cannot be named the same as a tuple struct
```
Looking into it, `union stage` used to compile into a Rust `enum` in 0.12, but in 2.0 it is a tuple struct, which is not allowed to name-clash with a function argument.
Contributor guide
Assessment
This issue has not been assessed yet.