You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit 9c60af0
Browse filesBrowse the repository at this point in the historyBrowse files
Rollup merge of #160570 - mejrs:concat_str, r=petrochenkov
macro_metavar_expr_concat: support concatenating into string literals
Usually if you want to concatenate string literals in macros you expand into some combination of concat! and stringify! invocations. However this does not work in nested MetaItems, since those are never expanded (unlike `#[path = EXPR]` attributes like `#[doc = include_str!("README.md")]`.
This PR adds support for that using `${concat_str(...)}`, similar to `${concat(...)}`. It is unstable under the same `macro_metavar_expr_concat` feature. See the tests in this PR for examples.
My motivation for adding this is that I've seen (and had myself) some cases where this would have been really useful. Thus I'd like to add this experimentally.
LL | let ${concat($lhs, $rhs)}: &'static str = ${concat_str($lhs, $rhs)};
5
5
| ^^^^^^^^^^^^^^^^^^^^
6
6
|
7
7
= note: see issue #124225 <https://github.com/rust-lang/rust/issues/124225> for more information
8
8
= help: add `#![feature(macro_metavar_expr_concat)]` to the crate attributes to enable
9
9
= note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date
10
10
11
-
error: aborting due to 1 previous error
11
+
error[E0658]: the `concat_str` meta-variable expression is unstable
LL | let ${concat($lhs, $rhs)}: &'static str = ${concat_str($lhs, $rhs)};
15
+
| ^^^^^^^^^^^^^^^^^^^^^^^^
16
+
|
17
+
= note: see issue #124225 <https://github.com/rust-lang/rust/issues/124225> for more information
18
+
= help: add `#![feature(macro_metavar_expr_concat)]` to the crate attributes to enable
19
+
= note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date
20
+
21
+
error: aborting due to 2 previous errors
12
22
13
23
For more information about this error, try `rustc --explain E0658`.
0 commit comments