flatbuffers: [Rust] Missing 'use' statements when generating from .fbs that has imports

Flatbuffers v1.11.0
Ubuntu 19.04

When generating code from multiple schema files, the necessary Rust use statements are not generated, therefore the generated code does not compile.

For example, when generating code for Apache Arrow Tensor.fbs, which includes Schema.fbs, I get the following compilation error:

error[E0412]: cannot find type `Type` in this scope
   --> arrow/src/ipc/gen/Tensor_generated.rs:443:27
    |
443 |     self.fbb_.push_slot::<Type>(Tensor::VT_TYPE_TYPE, type_type, Type::NONE);
    |                           ^^^^ not found in this scope
help: possible candidate is found in another module, you can import it into scope
    |
38  |   use crate::ipc::gen::Schema_generated::org::apache::arrow::flatbuf::Type;

The workaround is for me to manually add use crate::ipc::gen::Schema_generated::org::apache::arrow::flatbuf::Type to the generated code.

About this issue

  • Original URL
  • State: closed
  • Created 5 years ago
  • Comments: 23 (1 by maintainers)

Commits related to this issue

Most upvoted comments

Ok, I finally made time to try a solution. My current plan is to go the way of Go and Csharp and generate types in their own files, which is simpler than what I suggested in https://github.com/google/flatbuffers/issues/5589#issuecomment-713114642 since it doesn’t include the .fbs filename.