Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 4f7ea23

Browse files
committedFeb 26, 2025
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 cb06d12 commit 4f7ea23

21 files changed

+65
-42
lines changed
 

‎library/core/src/macros/mod.rs

+4
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

+1
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

+1
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

+1
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

+3
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

+2
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

+2-2
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

+2
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

+2-2
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

+2
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_idents3.stderr

+2-2
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_idents3.rs:5:20
2+
--> $DIR/feature-gate-concat_idents3.rs:7:20
33
|
44
LL | assert_eq!(10, concat_idents!(X, Y_1));
55
| ^^^^^^^^^^^^^
@@ -9,7 +9,7 @@ LL | assert_eq!(10, 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_idents3.rs:6:20
12+
--> $DIR/feature-gate-concat_idents3.rs:8:20
1313
|
1414
LL | assert_eq!(20, concat_idents!(X, Y_2));
1515
| ^^^^^^^^^^^^^

‎tests/ui/issues/issue-32950.rs

+1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
#![feature(concat_idents)]
2+
#![expect(deprecated)] // concat_idents is deprecated
23

34
#[derive(Debug)]
45
struct Baz<T>(

‎tests/ui/issues/issue-32950.stderr

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
error: `derive` cannot be used on items with type macros
2-
--> $DIR/issue-32950.rs:5:5
2+
--> $DIR/issue-32950.rs:6:5
33
|
44
LL | concat_idents!(Foo, Bar)
55
| ^^^^^^^^^^^^^^^^^^^^^^^^
66

77
error[E0412]: cannot find type `FooBar` in this scope
8-
--> $DIR/issue-32950.rs:5:5
8+
--> $DIR/issue-32950.rs:6:5
99
|
1010
LL | concat_idents!(Foo, Bar)
1111
| ^^^^^^^^^^^^^^^^^^^^^^^^ not found in this scope

‎tests/ui/issues/issue-50403.rs

+1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
#![feature(concat_idents)]
2+
#![expect(deprecated)] // concat_idents is deprecated
23

34
fn main() {
45
let x = concat_idents!(); //~ ERROR `concat_idents!()` takes 1 or more arguments

‎tests/ui/issues/issue-50403.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
error: `concat_idents!()` takes 1 or more arguments
2-
--> $DIR/issue-50403.rs:4:13
2+
--> $DIR/issue-50403.rs:5:13
33
|
44
LL | let x = concat_idents!();
55
| ^^^^^^^^^^^^^^^^

‎tests/ui/macros/macros-nonfatal-errors.rs

+1
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55

66
#![feature(trace_macros, concat_idents)]
77
#![feature(stmt_expr_attributes)]
8+
#![expect(deprecated)] // concat_idents is deprecated
89

910
use std::arch::asm;
1011

There was a problem loading the remainder of the diff.

0 commit comments

Comments
 (0)
Failed to load comments.