Skip to content

Commit ecac1cc

Browse files
committed
Mark concat_idents! deprecated
`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 cb06d12 commit ecac1cc

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
@@ -1137,6 +1137,10 @@ pub(crate) mod builtin {
11371137
issue = "29599",
11381138
reason = "`concat_idents` is not stable enough for use and is subject to change"
11391139
)]
1140+
#[deprecated(
1141+
since = "1.87.0",
1142+
note = "use `${concat(...)}` with the `macro_metavar_expr_concat` feature instead"
1143+
)]
11401144
#[rustc_builtin_macro]
11411145
#[macro_export]
11421146
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
@@ -704,6 +704,7 @@ pub use core::primitive;
704704
// Re-export built-in macros defined through core.
705705
#[stable(feature = "builtin_macro_prelude", since = "1.38.0")]
706706
#[allow(deprecated)]
707+
#[cfg_attr(bootstrap, allow(deprecated_in_future))]
707708
pub use core::{
708709
assert, assert_matches, cfg, column, compile_error, concat, concat_idents, const_format_args,
709710
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)