Skip to content

Unable to find modules generated by proc_macro #6258

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

Closed
dodomorandi opened this issue Oct 16, 2020 · 8 comments
Closed

Unable to find modules generated by proc_macro #6258

dodomorandi opened this issue Oct 16, 2020 · 8 comments
Labels
A-macro macro expansion E-unknown It's unclear if the issue is E-hard or E-easy without digging in S-actionable Someone could pick this issue up and work on it right now

Comments

@dodomorandi
Copy link

I feel slightly bad for posting this, because I really suspect this can be a PITA.

Crates like graphql_client creates a pretty good amount of modules, structs and impls based on graphql files an a few derives. Unfortunately rust-analyzer does not like the situation: it is unable to deduce most of the things, and, even worse, it is unable to detect the modules automatically generated, leaving annoying errors around.

I crated a small dummy repository based on the official github example in order to make testing easier, you can find it here.

Please don't hate me for this matklad and others, I am really a huge fan of your work -- it took me more than two weeks to finally think "I just need to let them know"...

@bjorn3
Copy link
Member

bjorn3 commented Oct 16, 2020

You can enable proc-macro support using

{
    "rust-analyzer.cargo.loadOutDirsFromCheck": true,
    "rust-analyzer.procMacro.enable": true,
}

@dodomorandi
Copy link
Author

At the beginning I thought that the two parameters (and the fix of the last week, if I remember correctly) would have solved the issue, but unfortunately it does not work.

Did you try the repository I linked? I am assuming (and maybe I am wrong) that the issue should not depend on the editor -- I am using NeoVim with CoC and the related rust-analyzer plugin.

@bjorn3
Copy link
Member

bjorn3 commented Oct 17, 2020

I just tested your reproduction repo. I get the same problems with proc macros enabled. @matklad Is it possible that modules defined by proc macros are ignored?

@matklad
Copy link
Member

matklad commented Oct 17, 2020

Possible, but not intended.

@matklad matklad added E-unknown It's unclear if the issue is E-hard or E-easy without digging in S-actionable Someone could pick this issue up and work on it right now labels Oct 17, 2020
@jonas-schievink jonas-schievink added the A-macro macro expansion label Oct 22, 2020
@jplatte
Copy link
Contributor

jplatte commented Oct 31, 2020

In ruma, lots of (probably all) proc-macro-generated types are also not found (both generated by a derive macro and a function-like macro). Both should work, right?

@edwin0cheng
Copy link
Member

@dodomorandi I just checked that in current master it works, would you like to test it again ?

Screenshot 2020-12-28 223819

@dodomorandi
Copy link
Author

@edwin0cheng Thank you for the check! The situation is much better, you are right. I am not sure the completion engine is able to handle things from the modules generated with proc-macro, but I am with NeoVim + CoC, it could also be a different issue.

@jplatte are you seeing the same improvements developing ruma? In that case I think we can close this issue 😊

@jplatte
Copy link
Contributor

jplatte commented Dec 28, 2020

Yeah, no issues here anymore 🙂

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-macro macro expansion E-unknown It's unclear if the issue is E-hard or E-easy without digging in S-actionable Someone could pick this issue up and work on it right now
Projects
None yet
Development

No branches or pull requests

6 participants