Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Fix cross-edition fragment specifier span behavior #130484

Open
traviscross opened this issue Sep 17, 2024 · 1 comment
Open

Fix cross-edition fragment specifier span behavior #130484

traviscross opened this issue Sep 17, 2024 · 1 comment
Labels
A-macros Area: All kinds of macros (custom derive, macro_rules!, proc macros, ..) C-bug Category: This is a bug. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. T-lang Relevant to the language team, which will review and decide on the PR/issue.

Comments

@traviscross
Copy link
Contributor

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:

@traviscross traviscross added the C-bug Category: This is a bug. label Sep 17, 2024
@rustbot rustbot added the needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. label Sep 17, 2024
@compiler-errors
Copy link
Member

I mentioned in the linked PR, but I don't see it here, so I'll repeat myself for clarity:

#129755 (comment)

I actually don't think this is possible to implement, due to existing bugs (#85708). Namely, we have trouble determining the span of a nonterminal token (which is used to compute the edition) when there's extern crates involved.

I would prefer if we decouple fixing this bug (both expr_2021 and pat) given that this is essentially a theoretical regression, and go ahead with this behavior.

That is, we go ahead with the existing behavior for now, and not further block the stabilization of expr_2021 on this issue. I do agree with the desired behavior from T-lang though.

@traviscross traviscross removed the needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. label Sep 17, 2024
@jieyouxu jieyouxu added T-lang Relevant to the language team, which will review and decide on the PR/issue. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. A-macros Area: All kinds of macros (custom derive, macro_rules!, proc macros, ..) labels Sep 18, 2024
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
A-macros Area: All kinds of macros (custom derive, macro_rules!, proc macros, ..) C-bug Category: This is a bug. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. T-lang Relevant to the language team, which will review and decide on the PR/issue.
Projects
None yet
Development

No branches or pull requests

4 participants