-
Notifications
You must be signed in to change notification settings - Fork 120
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
Make rust-analyzer work with generated code #122
Comments
(Conversation split off #121.) Regarding 1, re-stating what I said in #121 (comment):
...and the Cargo Book (emphasis mine):
...seem to hint that we should not do that. Personally I agree that it's a bit dirty for a build script to write to the filesystem other than the controlled I don't feel too comfortable writing outside of Regarding 2, not only git bloat bothers me (although we're not committing a binary file, it's still a text file over 2MB which compresses to zip to 200KB, and it changes fairly regularly), but also the fact that, if some content can be generated from a versioned source, what should be versioned is said source and not the content, or it will very likely go out of sync eventually. Actually, perhaps the reason I didn't do this was because 1. I don't want it committed to git and 2. I wonder if it would be possible to teach RA at all about the |
As a library user, I'm for 2. We're reading its source and looking for definitions far more frequently than we update the schema file. I'd commit it right away and be done with it. |
There are some other experiences against this change in https://t.me/gramme_rs/14807.
While this requires two windows open, I'd also recommend building the documentation offline and having it open to quickly navigate through the types. |
File is there, but go-to-definition does not work. And instead of single click user has to search in 2.5mb text file.
YMMV, but for me working RA far outweights any inconveniences when updating layers (and that is done far less frequently than jumping to various structs in generated code).
It is real, but this bloat is pretty local (one file) and can be ignored when moving through history.
Documentation and working RA are separate issues. Having both is better 😄 There's an open issue in RA to support this case rust-lang/rust-analyzer#3767 but it's open for two years now and looks like it requires some deep changes in RA structures. Far more difficult than putting generated code in a place where RA can see it. |
What I mean is, "go to definition" on the Sorry but I'm still not sold on the idea, mainly because once it's done "there's no turning back" (the file will forever remain in git history, unless we do certain shenanigans I would rather not). |
I will close the issue as I'm still not willing to commit such a large blob of generated code to the repository. For me go to definition works in the generated code, but perhaps that's because I develop directly on the library (and maybe only path or git dependencies work, not from crates.io? I'm not sure.) |
Right now
.tl
files are compiled togenerated.rs
that is put into cargo'sOUT_DIR
and then included from source code.This breaks rust-analyzer's go-to-definition feature (as it jumps to file containing
include!
macro).Proposed fixes:
generated.rs
file directly intosrc/
(that can cause double-compilation and considered dirty practice)generated.rs
file outside of build process, put it intosrc/
(and add to git).Personally I'd go with 2, as I see no real downsides (okay, more under version control but I'm sure git will manage).
Is there any better way?
The text was updated successfully, but these errors were encountered: