Skip to content

Commit 1724230

Browse files
committed
Apply more feedback
1 parent 16ad7b9 commit 1724230

File tree

1 file changed

+4
-23
lines changed

1 file changed

+4
-23
lines changed

src/doc/unstable-book/src/language-features/macro-metavar-expr-concat.md

+4-23
Original file line numberDiff line numberDiff line change
@@ -7,32 +7,15 @@ The tracking issue for this feature is: [#124225]
77
In stable Rust, there is no way to create new identifiers by joining identifiers to literals or other identifiers without using procedural macros such as [`paste`].
88
`#![feature(macro_metavar_expr_concat)]` introduces a way to do this, using the concat metavariable expression.
99

10-
> This feature is not to be confused with [`macro_metavar_expr`] or [`concat_idents`].
10+
> This feature uses the syntax from [`macro_metavar_expr`] but is otherwise
11+
> independent. It replaces the old unstable feature [`concat_idents`].
1112
1213
> This is an experimental feature; it and its syntax will require a RFC before stabilization.
1314
1415

1516
### Overview
1617

17-
At this time, [declarative macros] cannot create new identifiers.
18-
A common use case is the need to create names for structs or functions. The following cannot be done on stable Rust[^1]:
19-
20-
```rust,compile_fail
21-
macro_rules! create_some_structs {
22-
($name:ident) => {
23-
// Invalid syntax
24-
pub struct First$name;
25-
// Also invalid syntax
26-
pub struct Second($name);
27-
// Macros are not allowed in this position
28-
// (This restriction is what makes `concat_idents!` useless)
29-
pub struct concat_idents!(Third, $name);
30-
}
31-
}
32-
# create_some_structs!(Thing);
33-
```
34-
35-
`#![feature(macro_metavar_expr_concat)]` provides the `concat` metavariable to concatenate idents:
18+
`#![feature(macro_metavar_expr_concat)]` provides the `concat` metavariable expression for creating new identifiers:
3619

3720
```rust
3821
#![feature(macro_metavar_expr_concat)]
@@ -59,7 +42,7 @@ pub struct ThirdThing;
5942
### Syntax
6043

6144
This feature builds upon the metavariable expression syntax `${ .. }` as specified in [RFC 3086] ([`macro_metavar_expr`]).
62-
`concat` is available like `${ concat(items) }`, where `items` is a comma separated sequence of idents and/or string literals.
45+
`concat` is available like `${ concat(items) }`, where `items` is a comma separated sequence of idents and/or literals.
6346

6447
### Examples
6548

@@ -141,8 +124,6 @@ test test_u64_subtraction ... ok
141124
test result: ok. 6 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.00s
142125
```
143126

144-
[^1]: An alternative is the [`paste`] crate.
145-
146127
[`paste`]: https://crates.io/crates/paste
147128
[RFC 3086]: https://rust-lang.github.io/rfcs/3086-macro-metavar-expr.html
148129
[`concat_idents!`]: https://doc.rust-lang.org/nightly/std/macro.concat_idents.html

0 commit comments

Comments
 (0)