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

Prevent ICE when formatting braced vec! when... #5878

Closed
wants to merge 2 commits into from

Conversation

tdanniels
Copy link
Contributor

@tdanniels tdanniels commented Aug 5, 2023

[edit: closing and resubmitting because I realized I misnamed the branch]

... it contains only items.

Fixes 5735

Attempting to format invocations of macros which are considered "forced
bracket macros" (currently only `vec!`), but are invoked with braces
instead of brackets, and contain only items in their token trees,
currently trigger an ICE in rustfmt. This is because the function that
handles formatting macro invocations containing only items,
`rewrite_macro_with_items`, assumes that the 'new' delimiter style of
the macro being formatted is the same as the delimiter style in the
source text when attempting to locate the span after the macro's opening
delimiter. This leads to the construction of an invalid span, triggering
the ICE.

The fix here is to pass the old delimiter style to
`rewrite_macro_with_items` as well, so that it can successfully locate
the span.
@tdanniels tdanniels closed this Aug 5, 2023
@tdanniels tdanniels deleted the issue_5730 branch August 5, 2023 04:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants