Skip to content

Commit 75a9be6

Browse files
committed
Deprecate the unstable concat_idents!
`concat_idents` has been around unstably for a long time, but there is now a better (but still unstable) way to join identifiers using `${concat(...)}` syntax with `macro_metavar_expr_concat`. This resolves a lot of the problems with `concat_idents` and is on a better track toward stabilization, so there is no need to keep both versions around. `concat_idents!` still has a lot of use in the ecosystem so deprecate it before removing, as discussed in [1]. Link: #124225 [1]: https://rust-lang.zulipchat.com/#narrow/channel/219381-t-libs/topic/Removing.20.60concat_idents.60
1 parent 3c877f6 commit 75a9be6

21 files changed

+65
-42
lines changed

library/core/src/macros/mod.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1138,6 +1138,10 @@ pub(crate) mod builtin {
11381138
issue = "29599",
11391139
reason = "`concat_idents` is not stable enough for use and is subject to change"
11401140
)]
1141+
#[deprecated(
1142+
since = "1.88.0",
1143+
note = "use `${concat(...)}` with the `macro_metavar_expr_concat` feature instead"
1144+
)]
11411145
#[rustc_builtin_macro]
11421146
#[macro_export]
11431147
macro_rules! concat_idents {

library/core/src/prelude/v1.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ pub use crate::hash::macros::Hash;
5959

6060
#[stable(feature = "builtin_macro_prelude", since = "1.38.0")]
6161
#[allow(deprecated)]
62+
#[cfg_attr(bootstrap, allow(deprecated_in_future))]
6263
#[doc(no_inline)]
6364
pub use crate::{
6465
assert, cfg, column, compile_error, concat, concat_idents, env, file, format_args,

library/std/src/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -709,6 +709,7 @@ pub use core::primitive;
709709
// Re-export built-in macros defined through core.
710710
#[stable(feature = "builtin_macro_prelude", since = "1.38.0")]
711711
#[allow(deprecated)]
712+
#[cfg_attr(bootstrap, allow(deprecated_in_future))]
712713
pub use core::{
713714
assert, assert_matches, cfg, column, compile_error, concat, concat_idents, const_format_args,
714715
env, file, format_args, format_args_nl, include, include_bytes, include_str, line, log_syntax,

library/std/src/prelude/v1.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ pub use crate::result::Result::{self, Err, Ok};
4646
// Re-exported built-in macros
4747
#[stable(feature = "builtin_macro_prelude", since = "1.38.0")]
4848
#[allow(deprecated)]
49+
#[cfg_attr(bootstrap, allow(deprecated_in_future))]
4950
#[doc(no_inline)]
5051
pub use core::prelude::v1::{
5152
assert, cfg, column, compile_error, concat, concat_idents, env, file, format_args,

src/doc/unstable-book/src/library-features/concat-idents.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,10 @@
22

33
The tracking issue for this feature is: [#29599]
44

5+
This feature is deprecated, to be replaced by [`macro_metavar_expr_concat`].
6+
57
[#29599]: https://github.com/rust-lang/rust/issues/29599
8+
[`macro_metavar_expr_concat`]: https://github.com/rust-lang/rust/issues/124225
69

710
------------------------
811

tests/ui/feature-gates/feature-gate-concat_idents.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
#![expect(deprecated)] // concat_idents is deprecated
2+
13
const XY_1: i32 = 10;
24

35
fn main() {

tests/ui/feature-gates/feature-gate-concat_idents.stderr

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
error[E0658]: use of unstable library feature `concat_idents`: `concat_idents` is not stable enough for use and is subject to change
2-
--> $DIR/feature-gate-concat_idents.rs:5:13
2+
--> $DIR/feature-gate-concat_idents.rs:7:13
33
|
44
LL | let a = concat_idents!(X, Y_1);
55
| ^^^^^^^^^^^^^
@@ -9,7 +9,7 @@ LL | let a = concat_idents!(X, Y_1);
99
= note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date
1010

1111
error[E0658]: use of unstable library feature `concat_idents`: `concat_idents` is not stable enough for use and is subject to change
12-
--> $DIR/feature-gate-concat_idents.rs:6:13
12+
--> $DIR/feature-gate-concat_idents.rs:8:13
1313
|
1414
LL | let b = concat_idents!(X, Y_2);
1515
| ^^^^^^^^^^^^^

tests/ui/feature-gates/feature-gate-concat_idents2.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
#![expect(deprecated)] // concat_idents is deprecated
2+
13
fn main() {
24
concat_idents!(a, b); //~ ERROR `concat_idents` is not stable enough
35
//~| ERROR cannot find value `ab` in this scope

tests/ui/feature-gates/feature-gate-concat_idents2.stderr

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
error[E0658]: use of unstable library feature `concat_idents`: `concat_idents` is not stable enough for use and is subject to change
2-
--> $DIR/feature-gate-concat_idents2.rs:2:5
2+
--> $DIR/feature-gate-concat_idents2.rs:4:5
33
|
44
LL | concat_idents!(a, b);
55
| ^^^^^^^^^^^^^
@@ -9,7 +9,7 @@ LL | concat_idents!(a, b);
99
= note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date
1010

1111
error[E0425]: cannot find value `ab` in this scope
12-
--> $DIR/feature-gate-concat_idents2.rs:2:5
12+
--> $DIR/feature-gate-concat_idents2.rs:4:5
1313
|
1414
LL | concat_idents!(a, b);
1515
| ^^^^^^^^^^^^^^^^^^^^ not found in this scope

tests/ui/feature-gates/feature-gate-concat_idents3.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
#![expect(deprecated)] // concat_idents is deprecated
2+
13
const XY_1: i32 = 10;
24

35
fn main() {

0 commit comments

Comments
 (0)