-
Notifications
You must be signed in to change notification settings - Fork 27
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
generated_* files seem to throw ides for a loop #440
Comments
This might be as simple as replacing the include with #[path = “path/to/generated_whatever.rs”]
mod generated;
pub use generated::*; We’d need to add an additional import for |
This was a known problem in rust-analyzer, but checking now it looks like it was fixed last month? Are you running the latest rust-analayzer? see rust-lang/rust-analyzer#3767. I did previously use chad's solution, but I believe that this introduced other problems, perhaps around visibility? iirc everything works best when the generated code and the hand-written code is defined in the same module, instead of having the generated code be a submodule. edit: hmm, okay reading more carefully I do also see your problem, with goto not working from within a generated file. Will look and see if there's an open issue for this in rust-analyzer.. |
okay I opened rust-lang/rust-analyzer#14937 to inquire about support in rust-analyzer. Barring that, though, I'm not aware of a good solution to this problem. I personally just end up searching the file for the relevant symbol 😒 |
It's possible to hand-write code for which the tools work. I'm not clear what makes that intractable for machine-written code? |
So while playing with this yesterday, I also realized that my rust-analyzer goto-def was just working with the includes now. I'm completely ambivalent on making this change now that the pain point is gone. |
If update RA fixes it we can close, I will try this afternoon.
…On Wed, May 31, 2023, 12:50 PM Chad Brokaw ***@***.***> wrote:
So while playing with this yesterday, I also realized that my
rust-analyzer goto-def was just working with the includes now. I'm
completely ambivalent on making this change now that the pain point is gone.
—
Reply to this email directly, view it on GitHub
<#440 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/ABRKXACESBW7GGGNGBBBCR3XI6OHZANCNFSM6AAAAAAYTOEYU4>
.
You are receiving this because you authored the thread.Message ID:
***@***.***>
|
Per IM it seems you can jump into the generated file but not navigate within it. Navigate within is what I want fixed. |
Per further IM, if we generate code under src and make it a "normal" module (no include!) this should work. Downsides to this include:
Preferred solution is RA fixes it. If that seems unlikely to happen soon we can fix it ourselves. |
a note: it doesn't even need to be under source, we can use the notation chad mentions about to specify an arbitrary path to a module. This means we wouldn't need to move the files, which means we could keep all the generated files in their own directory (which makes the project easier to navigate, and makes it easier to know what to ignore in code review) |
VSCode + rust-analyzer does far worse at things like jump to definition on the generated_X files. For example, in generated_layout.rs you can't go to definition on the struct for the enum formats here:
I suspect the use via include! might be related. Could we generate them but have them act more like handwritten files, notably not use include! to pull them in?
This slowed me down considerably when confused about how some of the layout types and macros worked.
The text was updated successfully, but these errors were encountered: