Uh oh!
There was an error while loading. Please reload this page.
test: cross-edition metavar fragment specifiers - #129755
Conversation
rustbot
commented
Aug 29, 2024
r? @chenyukang rustbot has assigned @chenyukang. Use |
eholk
commented
Aug 29, 2024
Nominating for T-lang to get a gut check on what the desired behavior is here. |
This comment has been minimized.
This comment has been minimized.
Uh oh!
There was an error while loading. Please reload this page.
compiler-errors
commented
Aug 29, 2024
For the record, I believe that this is totally fine behavior. The span of the identifier that is used for the nonterminal should be the thing that determines the edition, since it's coming from the edition that's "instantiating" the edition. It's otherwise a somewhat arbitrary choice, though. |
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
So regardless of how we want this to work, this is also how (edit: I misread the behavior of the test) |
compiler-errors
commented
Aug 30, 2024
errs note: I think I may have ended up changing my mind. We should consider whether we want to use the uninterpolated span of the nonterminal-kind's identifier. This would require fixing |
eholk
commented
Aug 30, 2024
Something I realized is that the current behavior leaks the edition of the crate defining the macro. In our example, if the I think we probably want to change the behavior in this test. |
traviscross
commented
Sep 4, 2024
@rustbot labels -I-lang-nominated We discussed this in the lang call today. 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 We'd also like to fix this for |
f861467 to
e07b011Comparecompiler-errors
commented
Sep 10, 2024
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 Re-lang-nominating to confirm this. @rustbot label: -S-waiting-on-review +S-waiting-on-team +I-lang-nominated |
eholk
commented
Sep 17, 2024
I just pushed a change that adds coverage for |
While you're at it, can you squash that |
There's a subtle interaction between macros with metavar expressions and the edition-dependent fragment matching behavior. This test illustrates the current behavior when using macro-generating-macros across crate boundaries with different editions. Co-Authored-By: Vincenzo Palazzo <vincenzopalazzodev@gmail.com> Co-Authored-By: Eric Holk <eric@theincredibleholk.org>
In 2021 pat was changed to recognize `|` at the top level, with pat_param added to retain the old behavior. This means pat is subject to the same cross-edition behavior as expr will be in 2024. Co-authored-by: Vincenzo Palazzo <vincenzopalazzodev@gmail.com>
1e3d482 to
7653811Compareeholk
commented
Sep 17, 2024
Done! |
This comment has been minimized.
This comment has been minimized.
I filed #130484 so as to be able to separately address this later. I'd suggest marking the test as: //@ known-bug: #130484 |
compiler-errors
commented
Sep 18, 2024
T-lang decided in the meeting that it would be fine for this to remain an open bug to decouple fixing this from the edition. r=me after updating the issue to have |
eholk
commented
Sep 18, 2024
@bors r=compiler-errors |
bors
commented
Sep 18, 2024
…acros-between-edition, r=compiler-errors test: cross-edition metavar fragment specifiers There's a subtle interaction between macros with metavar expressions and the edition-dependent fragment matching behavior. This test illustrates the current behavior when using macro-generating-macros across crate boundaries with different editions. See the original suggestion rust-lang#123865 (comment) Tracking: - rust-lang#123742
…kingjubilee Rollup of 3 pull requests Successful merges: - rust-lang#129755 (test: cross-edition metavar fragment specifiers) - rust-lang#130511 (Support `char::encode_utf8` in const scenarios.) - rust-lang#130531 (Check params for unsafety in THIR) r? `@ghost` `@rustbot` modify labels: rollup
bors
commented
Sep 19, 2024
…ros-between-edition, r=compiler-errors test: cross-edition metavar fragment specifiers There's a subtle interaction between macros with metavar expressions and the edition-dependent fragment matching behavior. This test illustrates the current behavior when using macro-generating-macros across crate boundaries with different editions. See the original suggestion rust-lang#123865 (comment) Tracking: - rust-lang#123742
rust-log-analyzer
commented
Sep 19, 2024
The job Click to see the possible cause of the failure (guessed by this bot) |
bors
commented
Sep 19, 2024
💔 Test failed - checks-actions |
compiler-errors
commented
Sep 20, 2024
@bors retry |
…llaumeGomez Rollup of 6 pull requests Successful merges: - rust-lang#129542 (Add regression test for rust-lang#129541) - rust-lang#129755 (test: cross-edition metavar fragment specifiers) - rust-lang#130566 (Break up compiletest `runtest.rs` into smaller helper modules) - rust-lang#130585 (Add tidy check for rustdoc templates to ensure the whitespace characters are all stripped) - rust-lang#130605 (Fix feature name in test) - rust-lang#130607 ([Clippy] Remove final std paths for diagnostic item) r? `@ghost` `@rustbot` modify labels: rollup
Rollup merge of rust-lang#129755 - vincenzopalazzo:macros/recursive-macros-between-edition, r=compiler-errors test: cross-edition metavar fragment specifiers There's a subtle interaction between macros with metavar expressions and the edition-dependent fragment matching behavior. This test illustrates the current behavior when using macro-generating-macros across crate boundaries with different editions. See the original suggestion rust-lang#123865 (comment) Tracking: - rust-lang#123742
There's a subtle interaction between macros with metavar expressions and the edition-dependent fragment matching behavior. This test illustrates the current behavior when using macro-generating-macros across crate boundaries with different editions.
See the original suggestion #123865 (comment)
Tracking:
exprmacro fragment specifier for Rust 2024 #123742