godot-rust / gdnative

Rust bindings for Godot 3
https://godot-rust.github.io
MIT License
3.61k stars 210 forks source link

Rust Analyzer breaks without "one-class-one-file" feature. Enable "one-class-one-file" by default. #1053

Closed TCROC closed 11 months ago

TCROC commented 11 months ago

The Rust Analyzer extension does not work with gdnative out of the box. This is the main extension used in several IDEs for Rust: https://github.com/rust-lang/rust-analyzer

@chitoyuu suggested enabling the "one-class-one-file" feature on gdnative-bindings. I did this and autocomplete suggestions, hovering comments, etc. start working again! :)

I ran several builds on my machine with "one-class-one-file" enabled and disabled using this command per @fpdotmonkey's suggestion

cargo clean && cargo build --timings

And got this result:

Finished dev [unoptimized + debuginfo] target(s) in 18.15s

Each build has been between 18 ~ 19 seconds on my machine. There were not any discernible performance differences between the feature being enabled or disabled. In both cases, the builds were between 18 ~ 19 seconds and neither would consistently run any faster than the other.

However, without having this feature enabled, rust-analyzer does not work with gdnative. Therefore, I suggest enabling this feature by default.

I will also be putting in an issue with rust-analyzer as I do think rust-analyzer should work with minified libraries. But for now, this is a good workaround, and improves the user experience with gdnative.

TCROC commented 11 months ago

Here is an example repo on how to reproduce and how to fix:

https://github.com/TCROC/rust-analyzer-gdnative-issue-example