-
Notifications
You must be signed in to change notification settings - Fork 3.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Rust] generated code doesn't support multiple schema files #5275
Comments
@rnarubin Thanks for surfacing this! We've known about the lack of this feature since the Rust port was merged. You can see here that I added a // TODO(rw): make generated sub-namespace files importable Would you have any interest in trying to get this working with a PR? |
I see. I'd consider trying to fix this if it's unaddressed for a while longer, but in the near term we've settled on dumb workaround of stripping |
Is it a purely rust thing to get it working, or does one have to also write some cpp? It's something I'd also like to work on, maybe with a bit of guidance |
This requires changes to the code generator, so it's principally cpp work. |
This issue has been automatically marked as stale because it has not had activity for 1 year. It will be automatically closed if no further activity occurs. To keep it open, simply post a new comment. Maintainers will re-open on new activity. Thank you for your contributions. |
Still broken as of 1.12.0. |
Hi! This is really crucial for us and this is currently a serious limitation. Do you have any estimate when it could be done? We are just moving some of our code to Rust and this causes serious problems on our side right now. |
Subscribe to this. Are there any updates to this issue? |
This issue is stale because it has been open 6 months with no activity. Please comment or this will be closed in 14 days. |
Any plans to support this in the future? |
I definitely want to, but I can't promise a timeline :/ The current high level plan for this issue is: #5589 (comment) Note that this interacts with some other efforts like build.rs integration, #5216, and a refactoring of flatc to use an IR #6428, so there may be some throwaway work / churn, but that's probably worth it. |
I think this is fixed at HEAD by #6731 |
Generated Rust code encounters compiler errors when referencing types defined in different schema files. Consider this example:
first_file.fbs:
second_file.fbs:
main.rs:
$ flatc --rust first_file.fbs second_file.fbs && cargo build
:flatc version 1.10.0
cargo 1.33.0 (f099fe94b 2019-02-12)
I think the fix for this issue is simple, the generated sources need additional
mod
declarations for the different files they access.What's more complicated, however, is when the same namespace is used in these separate schemas:
first_file.fbs:
second_file.fbs:
in which case the types aren't qualified in the generated source:
Unlike e.g. C++ namespaces or Java packages, Rust modules of the same name in different files are distinct, so these usages would probably need to have qualified types. Then it becomes similar to the first problem of cross-file type access.
The text was updated successfully, but these errors were encountered: