Skip to content
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

flatc generates invalid rust code [Rust, rustc 1.68.0, linux, master] #7865

Closed
swz-git opened this issue Mar 12, 2023 · 4 comments
Closed

flatc generates invalid rust code [Rust, rustc 1.68.0, linux, master] #7865

swz-git opened this issue Mar 12, 2023 · 4 comments

Comments

@swz-git
Copy link

swz-git commented Mar 12, 2023

Running flatc (master or 23.3.3) on rlbot.fbs generates invalid rust code:

error[E0599]: no method named `message_type` found for reference `&GameMessageWrapper<'a>` in the current scope
     --> src/rlbot_generated.rs:12128:13
      |
12128 |     if self.message_type() == GameMessage::PlayerStatEvent {
      |             ^^^^^^^^^^^^ help: there is a method with a similar name: `Message_type`

error[E0599]: no method named `message_type` found for reference `&GameMessageWrapper<'a>` in the current scope
     --> src/rlbot_generated.rs:12143:13
      |
12143 |     if self.message_type() == GameMessage::PlayerSpectate {
      |             ^^^^^^^^^^^^ help: there is a method with a similar name: `Message_type`

error[E0599]: no method named `message_type` found for reference `&GameMessageWrapper<'a>` in the current scope
     --> src/rlbot_generated.rs:12158:13
      |
12158 |     if self.message_type() == GameMessage::PlayerInputChange {
      |             ^^^^^^^^^^^^ help: there is a method with a similar name: `Message_type`

error[E0599]: no method named `message_type` found for reference `&GameMessageWrapper<'_>` in the current scope
     --> src/rlbot_generated.rs:12237:18
      |
12237 |       match self.message_type() {
      |                  ^^^^^^^^^^^^ help: there is a method with a similar name: `Message_type`
@dbaileychess
Copy link
Collaborator

@CasperN can you take a look?

@cloneable
Copy link

Please also take a look at #7782 for a similar issue.

@TethysSvensson
Copy link
Contributor

I am pretty sure that's actually the same issue as #7782. It's at least very related, since the core issue is the same (the [[stuff]]_type method names for unions are not generated in the same way in different parts of the codegen).

Since that issue has been open for more than 3 months now with no response, I am not sure when it will be prioritized. If this is a problem for you, I would suggest you switch to planus instead for your rust code.

@sssooonnnggg
Copy link
Contributor

sssooonnnggg commented May 17, 2023

Hi all, I create a PR which will fix this issue, it seems that it's because rust namer hadn't dealt with case conversion with union type field

jochenparm pushed a commit to jochenparm/flatbuffers that referenced this issue Oct 29, 2024
jochenparm pushed a commit to jochenparm/flatbuffers that referenced this issue Oct 29, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants