Skip to content

Commit

Permalink
Rollup merge of #126700 - compiler-errors:fragment, r=fmease
Browse files Browse the repository at this point in the history
Make edition dependent `:expr` macro fragment act like the edition-dependent `:pat` fragment does

Parse the `:expr` fragment as `:expr_2021` in editions <=2021, and as `:expr` in edition 2024. This is similar to how we parse `:pat` as `:pat_param` in edition <=2018 and `:pat_with_or` in >=2021, and means we can get rid of a span dependency from `nonterminal_may_begin_with`.

Specifically, this fixes a theoretical regression since the `expr_2021` macro fragment previously would allow `const {}` if the *caller* is edition 2024. This is inconsistent with the way that the `pat` macro fragment was upgraded, and also leads to surprising behavior when a macro *caller* crate upgrades to edtion 2024, since they may have parsing changes that they never asked for (with no way of opting out of it).

This PR also allows using `expr_2021` in all editions. Why was this was disallowed in the first place? It's purely additive, and also it's still feature gated?

r? ```@fmease``` ```@eholk``` cc ```@vincenzopalazzo```
cc #123865

Tracking:

- rust-lang/rust#123742
  • Loading branch information
matthiaskrgr authored Jun 21, 2024
2 parents 6d28bbc + 73bac59 commit 27327f3
Showing 0 changed files with 0 additions and 0 deletions.

0 comments on commit 27327f3

Please sign in to comment.