Repository navigation
Tracking Issue for macro_metavar_expr_concat #124225
Description
This is a tracking issue for the experimental feature macro metavariable expressions concat and concat_str (RFC pending).
The feature gate for the issue is #![feature(macro_metavar_expr_concat)].
concat provides a modern alternative to the concat_idents! macro, while concat_str provides an alternative to the concat! macro in places where macros cannot be used.
#![feature(macro_metavar_expr_concat)]
macro_rules! many_idents {
($a:ident, $c:ident) => {
const ${concat($a, B, $c, D)}: &str = ${concat_str($A, $C)};
};
}
fn main() {
many_idents!(A, C);
assert_eq!(ABCD, 1);
}About experimental features
An experimental feature is one that has not yet had an RFC. The idea is to allow implementation work to proceed to better inform an upcoming RFC. Experimental features cannot be stabilized without first having an RFC. The existence of an experimental feature does not indicate lang team consensus that the feature is desirable, only that there is a problem that is worthy of being solved and that the idea has enough merit to consider exploring. See the lang team process page for more details.
About tracking issues
Tracking issues are used to record the overall progress of implementation.
They are also used as hubs connecting to other relevant issues, e.g., bugs or open design questions.
A tracking issue is however not meant for large scale discussion, questions, or bug reports about a feature.
Instead, open a dedicated issue for the specific matter and add the relevant feature gate label.
Steps / History
- Implementation (Add a new concat metavar expr #118958)
- macro_metavar_expr_concat: support concatenating into string literals #160570
- Write an RFC
- Adjust documentation (see instructions on rustc-dev-guide)
- Formatting for new syntax has been added to the Style Guide (nightly-style-procedure)
- Stabilization PR (see instructions on rustc-dev-guide)
Unresolved Questions
- Should the syntax use commas? Add a new concat metavar expr #118958 (comment)
- Should numeric literals be allowed? (yes) Add a new concat metavar expr #118958 (comment)
- Which span should the resulting identifier have? Should it be related to the macro, the concatenated values, or customizable? Add a new concat metavar expr #118958 (comment)
- What should be done with
r#fooraw identifiers? Add a new concat metavar expr #118958 (comment)
References
Metadata
Metadata
Assignees
Labels
Type
Projects
- StatusShow more project fieldsExploration
Activity
fmease commentedon Apr 21, 2024
This still needs a T-lang shepherd, right?
c410-f3r commentedon Apr 21, 2024
Unfortunately I am not familiar or aware of this procedure.
fmease commentedon Apr 21, 2024
All language features have to go through the RFC process eventually. However, the implementation can be done before an RFC has been written by following T-lang's experimental feature process which requires a T-lang member to support — shepherd — the venture. Only “small” language (not compiler) “fixes” don't need to follow the RFC process, they just need a T-lang FCP.
fmease commentedon Apr 21, 2024
T-lang, this feature is seeking a shepherd, therefore I'm nominating this for you.
An implementation is already under way (#118958). This feature adds a new kind of macro metavariable expression (the latter (overarching) feature has been approved by the merged RFC 3086, see also its tracking issue and stabilization PR (proposed FCP, disposition: merge)). The feature represents a more potent alternative / potential successor to the unstable built-in macro
concat_idents(the latter has stalled, blocked on design concerns, see its tracking issue).Please consult the tracking issue description for more context.
joshtriplett commentedon May 15, 2024
Happy to second this with my T-lang hat on.
@c410-f3r Good luck, and please reach out to #t-lang on Zulip if you have any questions. Feel free to @ me there if needed.
c410-f3r commentedon May 15, 2024
Thank you @joshtriplett
Auto merge of rust-lang#118958 - c410-f3r:concat-again, r=petrochenkov
UserIsntAvailable commentedon Jun 15, 2024
Sorry if this is the wrong place to discuss this, but should
${concat}provide its own case-conversion mechanism (just likepaste!does), or should we instead provide a standalone${case}metavar expr to handle this?If we where to follow
paste!syntax, then it would look like:Or with a future
${case}metavar expr:Which I think is way too verbose, but maybe I'm just too used to
paste!simplicity. The advantage of${case}over${concat}would be that, currently,${concat}requires 2 operands to be able to be used (this could technically be changed), so${case}would allow:With that said, maybe there is a world where both approaches are accepted, but I think there is probably less motivation to do that?
cc @c410-f3r @joshtriplett for opinions about this.
41 remaining items
Rollup merge of rust-lang#146064 - jullanggit:patch-1, r=fmease
Rollup merge of rust-lang#146064 - jullanggit:patch-1, r=fmease
Rollup merge of rust-lang#146064 - jullanggit:patch-1, r=fmease
Unrolled build for #146064
vron commentedon Sep 9, 2025
Hi, @c410-f3r ,
I just updated to latest nightly to note that this had replaced the old macro.
However, this does not work for my use case and I was asked to report it here.
More info:
https://users.rust-lang.org/t/macro-metavar-expr-concat-not-working-as-concat-idents/133737/2
Rollup merge of rust-lang#146308 - cyrgani:concat-integer-literals, r…
Rollup merge of rust-lang#146308 - cyrgani:concat-integer-literals, r…
Rollup merge of rust-lang#146308 - cyrgani:concat-integer-literals, r…
Unrolled build for #146308
Rollup merge of #146308 - cyrgani:concat-integer-literals, r=jackh726
Rollup merge of #146064 - jullanggit:patch-1, r=fmease
Rollup merge of rust-lang#146064 - jullanggit:patch-1, r=fmease
Greatly simplify ffi_wrap_enum
Greatly simplify ffi_wrap_enum
Greatly simplify ffi_wrap_enum