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

Remove Nonterminal and TokenKind::Interpolated #124141

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

Commits on Nov 24, 2024

  1. Remove NtVis.

    We now use invisible delimiters for expanded `vis` fragments, instead of
    `Token::Interpolated`.
    nnethercote committed Nov 24, 2024
    Configuration menu
    Copy the full SHA
    4c098db View commit details
    Browse the repository at this point in the history
  2. Remove NtTy.

    Notes about tests:
    
    - tests/ui/parser/macro/trait-object-macro-matcher.rs: the syntax error
      is duplicated, because it occurs now when parsing the decl macro
      input, and also when parsing the expanded decl macro. But this won't
      show up for normal users due to error de-duplication.
    
    - tests/ui/associated-consts/issue-93835.rs: ditto.
    
    - The changes to metavariable descriptions in this PR's earlier commits
      are now visible in error message for several tests.
    nnethercote committed Nov 24, 2024
    Configuration menu
    Copy the full SHA
    3efa325 View commit details
    Browse the repository at this point in the history
  3. Remove NtPat.

    The one notable test change is `tests/ui/macros/trace_faulty_macros.rs`.
    This commit removes the complicated `Interpolated` handling in
    `expected_expression_found` that results in a longer error message. But
    I think the new, shorter message is actually an improvement.
    
    The original complaint was in rust-lang#71039, when the error message started
    with "error: expected expression, found `1 + 1`". That was confusing
    because `1 + 1` is an expression. Other than that, the reporter said
    "the whole error message is not too bad if you ignore the first line".
    
    Subsequently, extra complexity and wording was added to the error
    message. But I don't think the extra wording actually helps all that
    much. In particular, it still says of the `1+1` that "this is expected
    to be expression". This repeats the problem from the original complaint!
    
    This commit removes the extra complexity, reverting to a simpler error
    message. This is primarily because the traversal is a pain without
    `Interpolated` tokens. Nonetheless, I think the error message is
    *improved*. It now starts with "expected expression, found `pat`
    metavariable", which is much clearer and the real problem. It also
    doesn't say anything specific about `1+1`, which is good, because the
    `1+1` isn't really relevant to the error -- it's the `$e:pat` that's
    important.
    nnethercote committed Nov 24, 2024
    Configuration menu
    Copy the full SHA
    ce05de5 View commit details
    Browse the repository at this point in the history
  4. Remove NtItem and NtStmt.

    This involves replacing `nt_pretty_printing_compatibility_hack` with
    `stream_pretty_printing_compatibility_hack`.
    
    The handling of statements in `transcribe` is slightly different to
    other nonterminal kinds, due to the lack of `from_ast` implementation
    for empty statements.
    
    Notable test changes:
    - `tests/ui/proc-macro/expand-to-derive.rs`: the diff looks large but
      the only difference is the insertion of a single invisible-delimited
      group around a metavar.
    nnethercote committed Nov 24, 2024
    Configuration menu
    Copy the full SHA
    2dfeaa9 View commit details
    Browse the repository at this point in the history
  5. More denesting of invisibly-delimited groups.

    This time when converting them to proc-macro `Group` form.
    nnethercote committed Nov 24, 2024
    Configuration menu
    Copy the full SHA
    d4fbe1f View commit details
    Browse the repository at this point in the history
  6. Remove NtMeta.

    Note: there was an existing code path involving `Interpolated` in
    `MetaItem::from_tokens` that was dead. This commit transfers that to the
    new form, but puts an `unreachable!` call inside it.
    nnethercote committed Nov 24, 2024
    Configuration menu
    Copy the full SHA
    f5acfd7 View commit details
    Browse the repository at this point in the history
  7. Remove NtPath.

    nnethercote committed Nov 24, 2024
    Configuration menu
    Copy the full SHA
    6af929b View commit details
    Browse the repository at this point in the history
  8. Remove NtExpr and NtLiteral.

    Notes about tests:
    - tests/ui/rfcs/rfc-2294-if-let-guard/feature-gate.rs: some messages are
      now duplicated due to repeated parsing.
    
    - tests/ui/rfcs/rfc-2497-if-let-chains/disallowed-positions.rs: ditto.
    
    - `tests/ui/proc-macro/macro-rules-derive-cfg.rs`: the diff looks large
      but the only difference is the insertion of a single
      invisible-delimited group around a metavar.
    nnethercote committed Nov 24, 2024
    Configuration menu
    Copy the full SHA
    f797ad5 View commit details
    Browse the repository at this point in the history
  9. Configuration menu
    Copy the full SHA
    febfb8d View commit details
    Browse the repository at this point in the history

Commits on Nov 25, 2024

  1. Remove NtBlock, Nonterminal, and TokenKind::Interpolated.

    `NtBlock` is the last remaining variant of `Nonterminal`, so once it is
    gone then `Nonterminal` can be removed as well.
    nnethercote committed Nov 25, 2024
    Configuration menu
    Copy the full SHA
    0a3c9b5 View commit details
    Browse the repository at this point in the history
  2. Configuration menu
    Copy the full SHA
    db50c0f View commit details
    Browse the repository at this point in the history
  3. Remove TokenStream::flattened and InvisibleOrigin::FlattenToken.

    They are no longer needed.
    
    This does slightly worsen the error message for a single test, but that
    test contains code that is so badly broken that I'm not worried about
    it.
    nnethercote committed Nov 25, 2024
    Configuration menu
    Copy the full SHA
    2479f6c View commit details
    Browse the repository at this point in the history