Skip to content
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

for<> is erased from macro calls #5316

Open
WaffleLapkin opened this issue Apr 20, 2022 · 4 comments
Open

for<> is erased from macro calls #5316

WaffleLapkin opened this issue Apr 20, 2022 · 4 comments
Labels
a-macros bug Panic, non-idempotency, invalid code, etc. p-low

Comments

@WaffleLapkin
Copy link
Member

Given this input:

a!(for<> A);
a!(for<A> A);
a!(for<A: A> A);
a!(for<A: ?A> A);

rustfmt produces the following output:

a!(A);
a!(A);
a!(A);
a!(A);

Which is incorrect since macros can depend on the for<...>. (playground)

@ytmimi ytmimi added a-macros bug Panic, non-idempotency, invalid code, etc. labels Apr 20, 2022
@ytmimi
Copy link
Contributor

ytmimi commented Apr 20, 2022

Thanks for the report!

Seems like this could be related to #4631 as both deal with dropping tokens in macro calls.

EDIT: upon further investigation these issues don't seem to be related. #4631 deals more with adding tokens to macro calls. specifically adding commas ,.

@ytmimi
Copy link
Contributor

ytmimi commented Apr 20, 2022

I wonder if the advice from #4631 (comment) would help? I know that rustfmt doesn't typically format macros that use {}.

@ytmimi
Copy link
Contributor

ytmimi commented Apr 21, 2022

Doing some testing and it seems like #5301 will fix some of the examples you outlined, but the first case a!(for<> A); is still an issue even after testing this snippet on that branch.

@ytmimi
Copy link
Contributor

ytmimi commented Jul 21, 2023

I believe all but the first issue were resolved by #5848. @compiler-errors do you have any interest in digging into the empty for<> case?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
a-macros bug Panic, non-idempotency, invalid code, etc. p-low
Projects
None yet
Development

No branches or pull requests

2 participants