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

Special case matches! macro #5554

Open
wants to merge 10 commits into
base: master
Choose a base branch
from

Commits on Mar 9, 2023

  1. Configuration menu
    Copy the full SHA
    f2942d2 View commit details
    Browse the repository at this point in the history
  2. Parse matches! macro

    The first step in being able to format the `matches!` macro is to parse
    it into ast nodes that we know how to rewrite.
    ytmimi committed Mar 9, 2023
    Configuration menu
    Copy the full SHA
    00b9003 View commit details
    Browse the repository at this point in the history
  3. Configuration menu
    Copy the full SHA
    735efa6 View commit details
    Browse the repository at this point in the history
  4. Better encapsulate guard rewrite logic in relation to pattern rewirte

    The guard rewrite rules vary based on how the pattern was rewritten.
    That logic was previously written in `rewrite_match_arm`, but now it's
    fully encapsulates in `rewrite_guard`.
    ytmimi committed Mar 9, 2023
    Configuration menu
    Copy the full SHA
    fbcc07a View commit details
    Browse the repository at this point in the history
  5. Add MatchesMacroItem and imp Rewrite, Spanned, and IntoOverflowableItem

    These traits will make it easier to implement rewriting matches! in terms
    of `overflow::rewrite_with_*` methods.
    ytmimi committed Mar 9, 2023
    Configuration menu
    Copy the full SHA
    8de2540 View commit details
    Browse the repository at this point in the history
  6. Special case matches! macro

    Now that we're able to parse the TokenStream of `matches!` calls into a
     `Matches` struct and then convert that `Matches` struct into an
    iterable which implments `IntoOverflowableItem` we're able to implement
    `matches!` rewriting in terms of `overflow::rewrite_with_*` calls.
    ytmimi committed Mar 9, 2023
    Configuration menu
    Copy the full SHA
    9d6a512 View commit details
    Browse the repository at this point in the history
  7. Version gate matches! special case formatting

    After special casing `matches!`, the formatting more closely resembles
    `match` expressions. These changes cause breaking formatting changes to
    that need to be version gated.
    ytmimi committed Mar 9, 2023
    Configuration menu
    Copy the full SHA
    e563f1b View commit details
    Browse the repository at this point in the history
  8. Add unit tests for matches! special case formatting

    The unit tests cover version One and Two formatting
    ytmimi committed Mar 9, 2023
    Configuration menu
    Copy the full SHA
    9e37c1e View commit details
    Browse the repository at this point in the history
  9. Configuration menu
    Copy the full SHA
    93130c0 View commit details
    Browse the repository at this point in the history
  10. Apply updated matches! formatting to rustfmt

    Since rustfmt uses version two formatting the self tests were failing
    due to the new special case handling for `matches!`. various `matches!`
    calls in the codebase were updated to address this issue.
    ytmimi committed Mar 9, 2023
    Configuration menu
    Copy the full SHA
    0c5552d View commit details
    Browse the repository at this point in the history