mirror of
https://github.com/vee1e/flatbuffers.git
synced 2026-09-02 02:07:25 +00:00
* Bugfix for Rust generation of union fields named with language keywords
Looking at ParseField, it appears that in the case of unions, an extra field with a `UnionTypeFieldSuffix` is added to the type definition, however, if the name of this field is a keyword in the target language, it isn't escaped.
For example, if generating code for rust for a union field named `type`, flatc will generate a (non-keyword escaped) field named `type_type` for this hidden union field, and one (keyword escaped) called `type_` for the actual union contents.
When the union accessors are generated, they refer to this `type_type` field, but they will escape it mistakenly, generating code like this:
```
#[inline]
#[allow(non_snake_case)]
pub fn type__as_int(&self) -> Option<Int<'a>> {
if self.type__type() == Type::Int {
self.type_().map(|u| Int::init_from_table(u))
} else {
None
}
}
```
Which will fail to build because the field is called `self.type_type()`, not `self.type__type()`.
* [Rust] Add crate-relative use statements for FBS includes.
At present if a flatbuffer description includes a reference to a type in
another file, the generated Rust code needs to be hand-modified to add
the appropriate `use` statements.
This assumes that the dependencies are built into the same crate, which
I think is a reasonable assumption?
* Revert "[Rust] Add crate-relative use statements for FBS includes."
This reverts commit d554d79fecf5afd6da6fb993b30b4cd523a5889a.
* Address comments raised in PR
* Update documentation comments per feedback
* Fix typo
* [rust] Make enum variant names public.
* Update generated test files
* Add test for public enum names
|
||
|---|---|---|
| .. | ||
| cpp17 | ||
| docker | ||
| evolution_test | ||
| FlatBuffers.Benchmarks | ||
| FlatBuffers.Test | ||
| fuzzer | ||
| include_test | ||
| MyGame | ||
| namespace_test | ||
| prototest | ||
| rust_usage_test | ||
| union_vector | ||
| arrays_test.bfbs | ||
| arrays_test.fbs | ||
| arrays_test.golden | ||
| arrays_test.schema.json | ||
| arrays_test_generated.h | ||
| BUILD | ||
| DartTest.sh | ||
| generate_code.bat | ||
| generate_code.sh | ||
| go_test.go | ||
| GoTest.sh | ||
| JavaScriptTest.js | ||
| JavaScriptTest.sh | ||
| JavaScriptUnionVectorTest.js | ||
| JavaTest.bat | ||
| javatest.bin | ||
| JavaTest.java | ||
| JavaTest.sh | ||
| KotlinTest.kt | ||
| KotlinTest.sh | ||
| lobstertest.lobster | ||
| LuaTest.bat | ||
| luatest.lua | ||
| LuaTest.sh | ||
| monster_extra.fbs | ||
| monster_extra_generated.h | ||
| monster_test.bfbs | ||
| monster_test.fbs | ||
| monster_test.grpc.fb.cc | ||
| monster_test.grpc.fb.h | ||
| monster_test.schema.json | ||
| monster_test_generated.h | ||
| monster_test_generated.js | ||
| monster_test_generated.lobster | ||
| monster_test_generated.rs | ||
| monster_test_generated.ts | ||
| monster_test_my_game.example2_generated.dart | ||
| monster_test_my_game.example_generated.dart | ||
| monster_test_my_game_generated.dart | ||
| monsterdata_extra.json | ||
| monsterdata_python_wire.mon | ||
| monsterdata_test.golden | ||
| monsterdata_test.json | ||
| monsterdata_test.mon | ||
| native_type_test.fbs | ||
| native_type_test_generated.h | ||
| native_type_test_impl.cpp | ||
| native_type_test_impl.h | ||
| phpTest.php | ||
| phpUnionVectorTest.php | ||
| phpUnionVectorTest.sh | ||
| py_test.py | ||
| PythonTest.sh | ||
| RustTest.bat | ||
| RustTest.sh | ||
| test.cpp | ||
| test_assert.cpp | ||
| test_assert.h | ||
| test_builder.cpp | ||
| test_builder.h | ||
| TestAll.sh | ||
| TypeScriptTest.sh | ||
| unicode_test.json | ||