Skip to content

Fix cross-edition fragment specifier span behavior #130484

Open
@traviscross

Description

@traviscross

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:

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-macrosArea: All kinds of macros (custom derive, macro_rules!, proc macros, ..)C-bugCategory: This is a bug.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.T-langRelevant to the language team

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions