Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

Add a new concat metavar expr #118958

Merged
merged 1 commit into from
Jun 14, 2024
Merged

Add a new concat metavar expr #118958

merged 1 commit into from
Jun 14, 2024

Conversation

c410-f3r
Copy link
Contributor

@c410-f3r c410-f3r commented Dec 15, 2023

Revival of #111930

Giving it another try now that #117050 was merged.

With the new rules, meta-variable expressions must be referenced with a dollar sign ($) and this can cause misunderstands with $concat.

macro_rules! foo {
    ( $bar:ident ) => {
        const ${concat(VAR, bar)}: i32 = 1;
    };
}

// Will produce `VARbar` instead of `VAR_123`
foo!(_123);

In other words, forgetting the dollar symbol can produce undesired outputs.

cc #29599
cc #124225

@rustbot
Copy link
Collaborator

rustbot commented Dec 15, 2023

r? @WaffleLapkin

(rustbot has picked a reviewer for you, use r? to override)

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Dec 15, 2023
compiler/rustc_expand/src/mbe/metavar_expr.rs Outdated Show resolved Hide resolved
compiler/rustc_expand/src/mbe/metavar_expr.rs Show resolved Hide resolved
compiler/rustc_expand/src/mbe/metavar_expr.rs Outdated Show resolved Hide resolved
compiler/rustc_expand/src/mbe/transcribe.rs Outdated Show resolved Hide resolved
compiler/rustc_expand/src/mbe/transcribe.rs Outdated Show resolved Hide resolved
tests/ui/macros/rfc-3086-metavar-expr/syntax-errors.rs Outdated Show resolved Hide resolved
@WaffleLapkin WaffleLapkin added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Dec 17, 2023
@rust-log-analyzer

This comment has been minimized.

@c410-f3r c410-f3r force-pushed the concat-again branch 2 times, most recently from 97b22d8 to c04e3a6 Compare December 18, 2023 22:18
@tgross35
Copy link
Contributor

@rustbot label +A-macros

@rustbot rustbot added the A-macros Area: All kinds of macros (custom derive, macro_rules!, proc macros, ..) label Dec 22, 2023
Copy link
Contributor

@tgross35 tgross35 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks pretty good to me. I started some discussion in wg-macros https://rust-lang.zulipchat.com/#narrow/stream/404510-wg-macros/topic/concat_idents.20as.20metavar.20.24.7B.2E.2E.2E.7D.

I don't think you need to mention the RFC in the title/commit message since this specific function wasn't called out in the RFC.

compiler/rustc_expand/src/mbe/metavar_expr.rs Outdated Show resolved Hide resolved
compiler/rustc_expand/src/mbe/metavar_expr.rs Outdated Show resolved Hide resolved
@rust-log-analyzer

This comment has been minimized.

@rust-log-analyzer

This comment has been minimized.

@c410-f3r c410-f3r changed the title [RFC-3086] Add a new concat metavar expr Add a new concat metavar expr Dec 26, 2023
@WaffleLapkin
Copy link
Member

(please use @rustbot review once my review is needed, this is currently S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. )

@tgross35
Copy link
Contributor

tgross35 commented Jan 5, 2024

@c410-f3r is this ready for review? I didn't intend for my comments to be blocking

@c410-f3r
Copy link
Contributor Author

c410-f3r commented Jan 5, 2024

Yeap, it is ready for review

@rustbot labels -S-waiting-on-author +S-waiting-on-review

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Jan 5, 2024
@bors

This comment was marked as resolved.

tests/ui/macros/rfc-3086-metavar-expr/syntax-errors.stderr Outdated Show resolved Hide resolved
compiler/rustc_expand/src/mbe/metavar_expr.rs Outdated Show resolved Hide resolved
compiler/rustc_expand/src/mbe/metavar_expr.rs Outdated Show resolved Hide resolved
compiler/rustc_expand/src/mbe/metavar_expr.rs Outdated Show resolved Hide resolved
compiler/rustc_expand/src/mbe/metavar_expr.rs Outdated Show resolved Hide resolved
compiler/rustc_expand/src/mbe/transcribe.rs Outdated Show resolved Hide resolved
compiler/rustc_expand/src/mbe/transcribe.rs Outdated Show resolved Hide resolved
compiler/rustc_expand/src/mbe/transcribe.rs Show resolved Hide resolved
@rustbot rustbot added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Jan 12, 2024
@rustbot rustbot added the A-testsuite Area: The testsuite used to check the correctness of rustc label Feb 4, 2024
@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Jun 12, 2024
@petrochenkov
Copy link
Contributor

r=me after addressing #118958 (comment).
@rustbot author

@rustbot rustbot added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Jun 13, 2024
@tgross35
Copy link
Contributor

tgross35 commented Jun 13, 2024

There still isn't a test ensuring that this syntax is rejected without the feature gate, feature-gate-macro-metavar-expr-concat.rs is run-pass #118958 (comment)

Edit: thanks, this looks good now

@rust-log-analyzer

This comment has been minimized.

@tgross35
Copy link
Contributor

Spurious failure #126430

@c410-f3r
Copy link
Contributor Author

@rustbot review

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Jun 14, 2024
@rust-log-analyzer
Copy link
Collaborator

The job x86_64-gnu-tools failed! Check out the build log: (web) (plain)

Click to see the possible cause of the failure (guessed by this bot)
.......... (120/124)
...F       (124/124)


/checkout/tests/rustdoc-gui/help-page.goml help-page... FAILED
[ERROR] `tests/rustdoc-gui/utils.goml` line 16
    from `tests/rustdoc-gui/help-page.goml` line 23
    from `tests/rustdoc-gui/help-page.goml` line 32: Error: Evaluation failed: The following errors happened: [localStorage item "rustdoc-theme" (of value "ayu") != "null"]: for command `assert-local-storage: {"rustdoc-theme": |theme|}`
Error: ()
Build completed unsuccessfully in 0:03:32
  local time: Fri Jun 14 02:02:41 UTC 2024
  network time: Fri, 14 Jun 2024 02:02:41 GMT

@petrochenkov
Copy link
Contributor

@bors r+

@bors
Copy link
Contributor

bors commented Jun 14, 2024

📌 Commit 4b82afb has been approved by petrochenkov

It is now in the queue for this repository.

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Jun 14, 2024
@bors
Copy link
Contributor

bors commented Jun 14, 2024

⌛ Testing commit 4b82afb with merge f8e5660...

@bors
Copy link
Contributor

bors commented Jun 14, 2024

☀️ Test successful - checks-actions
Approved by: petrochenkov
Pushing f8e5660 to master...

@bors bors added the merged-by-bors This PR was explicitly merged by bors. label Jun 14, 2024
@bors bors merged commit f8e5660 into rust-lang:master Jun 14, 2024
5 of 7 checks passed
@rustbot rustbot added this to the 1.81.0 milestone Jun 14, 2024
@tgross35
Copy link
Contributor

Woohoo! Thanks for all the work here, I think everyone has been needing this for a long while :)

@rust-timer
Copy link
Collaborator

Finished benchmarking commit (f8e5660): comparison URL.

Overall result: no relevant changes - no action needed

@rustbot label: -perf-regression

Instruction count

This benchmark run did not return any relevant results for this metric.

Max RSS (memory usage)

This benchmark run did not return any relevant results for this metric.

Cycles

This benchmark run did not return any relevant results for this metric.

Binary size

This benchmark run did not return any relevant results for this metric.

Bootstrap: 671.574s -> 671.997s (0.06%)
Artifact size: 319.78 MiB -> 320.43 MiB (0.20%)

@tgross35 tgross35 added the F-macro_metavar_expr_concat `#![feature(macro_metavar_expr_concat)]` label Aug 24, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-macros Area: All kinds of macros (custom derive, macro_rules!, proc macros, ..) A-testsuite Area: The testsuite used to check the correctness of rustc F-macro_metavar_expr_concat `#![feature(macro_metavar_expr_concat)]` merged-by-bors This PR was explicitly merged by bors. S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. T-bootstrap Relevant to the bootstrap subteam: Rust's build system (x.py and src/bootstrap) T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging this pull request may close these issues.