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

Always preserve None-delimited groups in a captured TokenStream #83548

Merged
merged 1 commit into from
Mar 27, 2021

Commits on Mar 27, 2021

  1. Always preserve None-delimited groups in a captured TokenStream

    Previously, we would silently remove any `None`-delimiters when
    capturing a `TokenStream`, 'flattenting' them to their inner tokens.
    This was not normally visible, since we usually have
    `TokenKind::Interpolated` (which gets converted to a `None`-delimited
    group during macro invocation) instead of an actual `None`-delimited
    group.
    
    However, there are a couple of cases where this becomes visible to
    proc-macros:
    1. A cross-crate `macro_rules!` macro has a `None`-delimited group
       stored in its body (as a result of being produced by another
       `macro_rules!` macro). The cross-crate `macro_rules!` invocation
       can then expand to an attribute macro invocation, which needs
       to be able to see the `None`-delimited group.
    2. A proc-macro can invoke an attribute proc-macro with its re-collected
       input. If there are any nonterminals present in the input, they will
       get re-collected to `None`-delimited groups, which will then get
       captured as part of the attribute macro invocation.
    
    Both of these cases are incredibly obscure, so there hopefully won't be
    any breakage. This change will allow more agressive 'flattenting' of
    nonterminals in rust-lang#82608 without losing `None`-delimited groups.
    Aaron1011 committed Mar 27, 2021
    Configuration menu
    Copy the full SHA
    f94360f View commit details
    Browse the repository at this point in the history