1
Fork 0

Auto merge of #118958 - c410-f3r:concat-again, r=petrochenkov

Add a new concat metavar expr

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`.

```rust
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 https://github.com/rust-lang/rust/issues/124225
This commit is contained in:
bors 2024-06-14 16:41:39 +00:00
commit f8e5660532
15 changed files with 551 additions and 29 deletions

View file

@ -1118,6 +1118,7 @@ symbols! {
macro_lifetime_matcher,
macro_literal_matcher,
macro_metavar_expr,
macro_metavar_expr_concat,
macro_reexport,
macro_use,
macro_vis_matcher,