Skip to content

Provide an option to exclude particular proc macros expansion #11052

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
Veetaha opened this issue Dec 18, 2021 · 1 comment · Fixed by #11193
Closed

Provide an option to exclude particular proc macros expansion #11052

Veetaha opened this issue Dec 18, 2021 · 1 comment · Fixed by #11193
Assignees
Labels
A-config configuration A-macro macro expansion Broken Window Bugs / technical debt to be addressed immediately S-actionable Someone could pick this issue up and work on it right now

Comments

@Veetaha
Copy link
Contributor

Veetaha commented Dec 18, 2021

As for now, the expansion of proc macros works good enough, however, not always. For example, if we are modifying the code that is fed to a proc macro the user experience is very poor. The main use case is writing code under #[async_trait]. The default behavior where #[async_trait] isn't expanded and analyzed is much smoother: we don't see the code highlighting broken. So the general IDE experience is way better when #[async_trait] isn't expanded by rust-analyzer's logic.

I propose to add configuration knobs to rust-analyzer that specify the list of macros that the user explicitly doesn't want for the IDE to ever expand.

Another potential use case that we can imagine is excluding special macros that do some expensive I/O or CPU-intensive work and they are not important for the general IDE experience, so we would like rust-analyzer to ignore them.

@Veetaha Veetaha added the A-config configuration label Dec 18, 2021
@Veykril Veykril added A-macro macro expansion Broken Window Bugs / technical debt to be addressed immediately S-actionable Someone could pick this issue up and work on it right now labels Dec 18, 2021
@Veykril
Copy link
Member

Veykril commented Dec 18, 2021

Ye I agree, this is rather problematic for some macros(especially async_trait as mentioned). I had a few people complaining the past week as well, as async_trait is probably one of the more used attributes that are affected by this.

One simple way I could see here is to just allow the user to list the names of proc-macro exporting crates which to ignore the expansion of, in which case we will just keep the dummy expander for the macros exported by those crates.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-config configuration A-macro macro expansion Broken Window Bugs / technical debt to be addressed immediately S-actionable Someone could pick this issue up and work on it right now
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants