rust/compiler/rustc_expand/src
Matthias Krüger 3bd84f18bc
Rollup merge of #126700 - compiler-errors:fragment, r=fmease
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:

- https://github.com/rust-lang/rust/issues/123742
2024-06-21 09:12:36 +02:00
..
mbe Rollup merge of #126700 - compiler-errors:fragment, r=fmease 2024-06-21 09:12:36 +02:00
base.rs Rollup merge of #124135 - petrochenkov:deleglob, r=fmease 2024-06-19 01:51:36 +01:00
build.rs Fix formatting 2024-06-06 20:27:25 -05:00
config.rs Rename buffer_lint_with_diagnostic to buffer_lint 2024-05-21 20:16:39 +00:00
errors.rs delegation: Implement glob delegation 2024-06-14 19:27:51 +03:00
expand.rs delegation: Implement glob delegation 2024-06-14 19:27:51 +03:00
lib.rs Move some tests from rustc_expand to rustc_parse. 2024-05-06 09:06:02 +10:00
mbe.rs Add some comments. 2024-05-23 06:03:17 +10:00
module.rs Make top-level rustc_parse functions fallible. 2024-06-05 10:38:03 +10:00
placeholders.rs Add ErrorGuaranteed to Recovered::Yes and use it more. 2024-05-09 20:12:07 +10:00
proc_macro.rs Remove stream_to_parser. 2024-06-05 10:37:59 +10:00
proc_macro_server.rs Prefer dcx methods over fields or fields' methods 2024-06-18 13:45:08 +00:00