Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Deprecate the unstable concat_idents! #137653

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions library/core/src/macros/mod.rs
Original file line number Diff line number Diff line change
@@ -1137,6 +1137,10 @@ pub(crate) mod builtin {
issue = "29599",
reason = "`concat_idents` is not stable enough for use and is subject to change"
)]
#[deprecated(
since = "1.87.0",
note = "use `${concat(...)}` with the `macro_metavar_expr_concat` feature instead"
)]
#[rustc_builtin_macro]
#[macro_export]
macro_rules! concat_idents {
1 change: 1 addition & 0 deletions library/core/src/prelude/v1.rs
Original file line number Diff line number Diff line change
@@ -59,6 +59,7 @@ pub use crate::hash::macros::Hash;

#[stable(feature = "builtin_macro_prelude", since = "1.38.0")]
#[allow(deprecated)]
#[cfg_attr(bootstrap, allow(deprecated_in_future))]
#[doc(no_inline)]
pub use crate::{
assert, cfg, column, compile_error, concat, concat_idents, env, file, format_args,
1 change: 1 addition & 0 deletions library/std/src/lib.rs
Original file line number Diff line number Diff line change
@@ -704,6 +704,7 @@ pub use core::primitive;
// Re-export built-in macros defined through core.
#[stable(feature = "builtin_macro_prelude", since = "1.38.0")]
#[allow(deprecated)]
#[cfg_attr(bootstrap, allow(deprecated_in_future))]
pub use core::{
assert, assert_matches, cfg, column, compile_error, concat, concat_idents, const_format_args,
env, file, format_args, format_args_nl, include, include_bytes, include_str, line, log_syntax,
1 change: 1 addition & 0 deletions library/std/src/prelude/v1.rs
Original file line number Diff line number Diff line change
@@ -46,6 +46,7 @@ pub use crate::result::Result::{self, Err, Ok};
// Re-exported built-in macros
#[stable(feature = "builtin_macro_prelude", since = "1.38.0")]
#[allow(deprecated)]
#[cfg_attr(bootstrap, allow(deprecated_in_future))]
#[doc(no_inline)]
pub use core::prelude::v1::{
assert, cfg, column, compile_error, concat, concat_idents, env, file, format_args,
3 changes: 3 additions & 0 deletions src/doc/unstable-book/src/library-features/concat-idents.md
Original file line number Diff line number Diff line change
@@ -2,7 +2,10 @@

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

This feature is deprecated, to be replaced by [`macro_metavar_expr_concat`].

[#29599]: https://github.com/rust-lang/rust/issues/29599
[`macro_metavar_expr_concat`]: https://github.com/rust-lang/rust/issues/124225

------------------------

2 changes: 2 additions & 0 deletions tests/ui/feature-gates/feature-gate-concat_idents.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#![expect(deprecated)] // concat_idents is deprecated

const XY_1: i32 = 10;

fn main() {
4 changes: 2 additions & 2 deletions tests/ui/feature-gates/feature-gate-concat_idents.stderr
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
error[E0658]: use of unstable library feature `concat_idents`: `concat_idents` is not stable enough for use and is subject to change
--> $DIR/feature-gate-concat_idents.rs:5:13
--> $DIR/feature-gate-concat_idents.rs:7:13
|
LL | let a = concat_idents!(X, Y_1);
| ^^^^^^^^^^^^^
@@ -9,7 +9,7 @@ LL | let a = concat_idents!(X, Y_1);
= note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date

error[E0658]: use of unstable library feature `concat_idents`: `concat_idents` is not stable enough for use and is subject to change
--> $DIR/feature-gate-concat_idents.rs:6:13
--> $DIR/feature-gate-concat_idents.rs:8:13
|
LL | let b = concat_idents!(X, Y_2);
| ^^^^^^^^^^^^^
2 changes: 2 additions & 0 deletions tests/ui/feature-gates/feature-gate-concat_idents2.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#![expect(deprecated)] // concat_idents is deprecated

fn main() {
concat_idents!(a, b); //~ ERROR `concat_idents` is not stable enough
//~| ERROR cannot find value `ab` in this scope
4 changes: 2 additions & 2 deletions tests/ui/feature-gates/feature-gate-concat_idents2.stderr
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
error[E0658]: use of unstable library feature `concat_idents`: `concat_idents` is not stable enough for use and is subject to change
--> $DIR/feature-gate-concat_idents2.rs:2:5
--> $DIR/feature-gate-concat_idents2.rs:4:5
|
LL | concat_idents!(a, b);
| ^^^^^^^^^^^^^
@@ -9,7 +9,7 @@ LL | concat_idents!(a, b);
= note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date

error[E0425]: cannot find value `ab` in this scope
--> $DIR/feature-gate-concat_idents2.rs:2:5
--> $DIR/feature-gate-concat_idents2.rs:4:5
|
LL | concat_idents!(a, b);
| ^^^^^^^^^^^^^^^^^^^^ not found in this scope
2 changes: 2 additions & 0 deletions tests/ui/feature-gates/feature-gate-concat_idents3.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#![expect(deprecated)] // concat_idents is deprecated

const XY_1: i32 = 10;

fn main() {
4 changes: 2 additions & 2 deletions tests/ui/feature-gates/feature-gate-concat_idents3.stderr
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
error[E0658]: use of unstable library feature `concat_idents`: `concat_idents` is not stable enough for use and is subject to change
--> $DIR/feature-gate-concat_idents3.rs:5:20
--> $DIR/feature-gate-concat_idents3.rs:7:20
|
LL | assert_eq!(10, concat_idents!(X, Y_1));
| ^^^^^^^^^^^^^
@@ -9,7 +9,7 @@ LL | assert_eq!(10, concat_idents!(X, Y_1));
= note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date

error[E0658]: use of unstable library feature `concat_idents`: `concat_idents` is not stable enough for use and is subject to change
--> $DIR/feature-gate-concat_idents3.rs:6:20
--> $DIR/feature-gate-concat_idents3.rs:8:20
|
LL | assert_eq!(20, concat_idents!(X, Y_2));
| ^^^^^^^^^^^^^
1 change: 1 addition & 0 deletions tests/ui/issues/issue-32950.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#![feature(concat_idents)]
#![expect(deprecated)] // concat_idents is deprecated

#[derive(Debug)]
struct Baz<T>(
4 changes: 2 additions & 2 deletions tests/ui/issues/issue-32950.stderr
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
error: `derive` cannot be used on items with type macros
--> $DIR/issue-32950.rs:5:5
--> $DIR/issue-32950.rs:6:5
|
LL | concat_idents!(Foo, Bar)
| ^^^^^^^^^^^^^^^^^^^^^^^^

error[E0412]: cannot find type `FooBar` in this scope
--> $DIR/issue-32950.rs:5:5
--> $DIR/issue-32950.rs:6:5
|
LL | concat_idents!(Foo, Bar)
| ^^^^^^^^^^^^^^^^^^^^^^^^ not found in this scope
1 change: 1 addition & 0 deletions tests/ui/issues/issue-50403.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#![feature(concat_idents)]
#![expect(deprecated)] // concat_idents is deprecated

fn main() {
let x = concat_idents!(); //~ ERROR `concat_idents!()` takes 1 or more arguments
2 changes: 1 addition & 1 deletion tests/ui/issues/issue-50403.stderr
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
error: `concat_idents!()` takes 1 or more arguments
--> $DIR/issue-50403.rs:4:13
--> $DIR/issue-50403.rs:5:13
|
LL | let x = concat_idents!();
| ^^^^^^^^^^^^^^^^
1 change: 1 addition & 0 deletions tests/ui/macros/macros-nonfatal-errors.rs
Original file line number Diff line number Diff line change
@@ -5,6 +5,7 @@

#![feature(trace_macros, concat_idents)]
#![feature(stmt_expr_attributes)]
#![expect(deprecated)] // concat_idents is deprecated

use std::arch::asm;

Loading
Loading