rust-lang / rust-lang/rust

Fix cross-edition fragment specifier span behavior

Open
#130,484 1 comment 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

A-macros C-bug T-compiler T-lang
Dominant language
Rust
Stars
119k
Forks
16.1k
PR merge metrics
PR metrics pending

Description

In the lang call on 2024-09-04, we agreed that the span of the token used to fill in the fragment specifier should be used for deciding the behavior.

That is, if we have code like this in a Rust 2021 crate:

#[macro_export]
macro_rules! make_matcher {
    ($name:ident, $fragment_type:ident, $d:tt) => {
        #[macro_export]
        macro_rules! $name {
            ($d _:$fragment_type) => { true };
            (const { 0 }) => { false };
        }
    };
}
make_matcher!(is_expr_from_2021, expr, $);

And code like this in a Rust 2024 crate:

make_matcher!(is_expr_from_2024, expr, $);

We would expect that is_expr_from_2024 would exhibit the Rust 2024 behavior.

We'd also like to fix this for pat, pending of course a crater run.

cc #129755

cc @eholk @vincenzopalazzo @compiler-errors

Tracking:

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reproducing the Rust 2021 and Rust 2024 examples in the issue and compare the resulting fragment-specifier behavior. Read the discussion in PR #129755 and tracking issue #123742 for the agreed span semantics. Done means the behavior follows the span of the token filling the fragment specifier, including the requested pat coverage after a crater run.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
compilers
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.