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

Commits on Aug 5, 2023

  1. Prevent ICE when formatting braced vec! when...

    ... 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 committed Aug 5, 2023
    Configuration menu
    Copy the full SHA
    41b4943 View commit details
    Browse the repository at this point in the history
  2. Configuration menu
    Copy the full SHA
    2ed6872 View commit details
    Browse the repository at this point in the history