Skip to content

feat: Add config to replace specific proc-macros with dummy expanders #11193

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

Merged
merged 3 commits into from
Jan 6, 2022

Conversation

Veykril
Copy link
Member

@Veykril Veykril commented Jan 4, 2022

With this one can specify proc-macros from crates to expand into their input as a (temporary) workaround for the current completion problems with some of the bigger attribute proc-macros like async_trait.

This could've been done by just not expanding these macros, but that would require fiddling with nameres. I felt like this approach was simpler to pull off while also keeping the behaviour of the attributes/proc-macro in that they still expand instead of being dead syntax to us.

Fixes #11052

Code_I5waElTi7N

@Veykril Veykril force-pushed the proc-config branch 2 times, most recently from e4cfb01 to a6d4bc3 Compare January 5, 2022 19:08
@Veykril Veykril marked this pull request as ready for review January 5, 2022 20:25
@Veykril
Copy link
Member Author

Veykril commented Jan 5, 2022

r? @matklad

Since you have a better view on the project_model crate.

@matklad
Copy link
Member

matklad commented Jan 5, 2022

Make sense!

I wonder if, as a follow up, we should allow to specify this in metadata section of cargo-toml?

pub(crate) fn load_proc_macro(
client: Option<&ProcMacroServer>,
path: &AbsPath,
dummy_replace: &[Box<str>],
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder if perhaps we should implement this on the higher level and treat such macros as inert attributes?

ah, I see you’ve considered that. I wonder if we can treat this as a custom tool attribute (#[rustfmt and such)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

tool attribute would be nice in theory, but since those are unstable and therefor require a feature flag I am doubtful that people would even bother using it

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I mean, we presumably have some infrastruture internally to track tool/intert attributes and say things like "inline does nothing". We can use that same infrastructure to implement this feature. Ie, this is about impl detail rather thatn about API.

Basically, make #[tokio::main] behave like #[inline] rather than #[identity].

@Veykril
Copy link
Member Author

Veykril commented Jan 6, 2022

I wonder if, as a follow up, we should allow to specify this in metadata section of cargo-toml?

As in proc-macro crates can tell r-a to not have their macros expand(be dummy expanded)?

@Veykril
Copy link
Member Author

Veykril commented Jan 6, 2022

bors r+

@bors
Copy link
Contributor

bors bot commented Jan 6, 2022

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Provide an option to exclude particular proc macros expansion
2 participants