Skip to content

Commit 1f5783c

Browse files
Auto merge of #142704 - tgross35:remove-concat_idents, r=<try>
Remove the deprecated `concat_idents!` macro In [#137653], the lang and libs-API teams did a joint FCP to deprecate and eventually remove the long-unstable `concat_idents!` macro. The deprecation is landing in 1.88, so do the removal here (target version 1.90). This macro has been superseded by the more recent `${concat(...)}` metavariable expression language feature, which avoids some of the limitations of `concat_idents!`. The metavar expression is unstably available under the [`macro_metavar_expr_concat`] feature. History is mildly interesting here: `concat_idents!` goes back to 2011 when it was introduced with 513276e ("Add #concat_idents[] and #ident_to_str[]"). The syntax looks a bit different but it still works about the same: let asdf_fdsa = "<.<"; assert(#concat_idents[asd,f_f,dsa] == "<.<"); assert(#ident_to_str[use_mention_distinction] == "use_mention_distinction"); (That test existed from introduction until its removal here.) Closes: #29599 [#137653]: #137653 [`macro_metavar_expr_concat`]: #124225
2 parents 8a65ee0 + 938b6f5 commit 1f5783c

36 files changed

+138
-412
lines changed

compiler/rustc_builtin_macros/messages.ftl

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -116,10 +116,6 @@ builtin_macros_concat_bytes_oob = numeric literal is out of bounds
116116
builtin_macros_concat_bytestr = cannot concatenate a byte string literal
117117
builtin_macros_concat_c_str_lit = cannot concatenate a C string literal
118118
119-
builtin_macros_concat_idents_ident_args = `concat_idents!()` requires ident args
120-
121-
builtin_macros_concat_idents_missing_args = `concat_idents!()` takes 1 or more arguments
122-
builtin_macros_concat_idents_missing_comma = `concat_idents!()` expecting comma
123119
builtin_macros_concat_missing_literal = expected a literal
124120
.note = only literals (like `"foo"`, `-42` and `3.14`) can be passed to `concat!()`
125121

compiler/rustc_builtin_macros/src/concat_idents.rs

Lines changed: 0 additions & 71 deletions
This file was deleted.

compiler/rustc_builtin_macros/src/errors.rs

Lines changed: 0 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -290,27 +290,6 @@ pub(crate) struct ConcatBytesBadRepeat {
290290
pub(crate) span: Span,
291291
}
292292

293-
#[derive(Diagnostic)]
294-
#[diag(builtin_macros_concat_idents_missing_args)]
295-
pub(crate) struct ConcatIdentsMissingArgs {
296-
#[primary_span]
297-
pub(crate) span: Span,
298-
}
299-
300-
#[derive(Diagnostic)]
301-
#[diag(builtin_macros_concat_idents_missing_comma)]
302-
pub(crate) struct ConcatIdentsMissingComma {
303-
#[primary_span]
304-
pub(crate) span: Span,
305-
}
306-
307-
#[derive(Diagnostic)]
308-
#[diag(builtin_macros_concat_idents_ident_args)]
309-
pub(crate) struct ConcatIdentsIdentArgs {
310-
#[primary_span]
311-
pub(crate) span: Span,
312-
}
313-
314293
#[derive(Diagnostic)]
315294
#[diag(builtin_macros_bad_derive_target, code = E0774)]
316295
pub(crate) struct BadDeriveTarget {

compiler/rustc_builtin_macros/src/lib.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,6 @@ mod cfg_eval;
3636
mod compile_error;
3737
mod concat;
3838
mod concat_bytes;
39-
mod concat_idents;
4039
mod define_opaque;
4140
mod derive;
4241
mod deriving;
@@ -84,7 +83,6 @@ pub fn register_builtin_macros(resolver: &mut dyn ResolverExpand) {
8483
compile_error: compile_error::expand_compile_error,
8584
concat: concat::expand_concat,
8685
concat_bytes: concat_bytes::expand_concat_bytes,
87-
concat_idents: concat_idents::expand_concat_idents,
8886
const_format_args: format::expand_format_args,
8987
core_panic: edition_panic::expand_panic,
9088
env: env::expand_env,

compiler/rustc_span/src/symbol.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -684,7 +684,6 @@ symbols! {
684684
compiler_fence,
685685
concat,
686686
concat_bytes,
687-
concat_idents,
688687
conservative_impl_trait,
689688
console,
690689
const_allocate,

library/core/src/macros/mod.rs

Lines changed: 0 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -1109,45 +1109,6 @@ pub(crate) mod builtin {
11091109
($name:expr $(,)?) => {{ /* compiler built-in */ }};
11101110
}
11111111

1112-
/// Concatenates identifiers into one identifier.
1113-
///
1114-
/// This macro takes any number of comma-separated identifiers, and
1115-
/// concatenates them all into one, yielding an expression which is a new
1116-
/// identifier. Note that hygiene makes it such that this macro cannot
1117-
/// capture local variables. Also, as a general rule, macros are only
1118-
/// allowed in item, statement or expression position. That means while
1119-
/// you may use this macro for referring to existing variables, functions or
1120-
/// modules etc, you cannot define a new one with it.
1121-
///
1122-
/// # Examples
1123-
///
1124-
/// ```
1125-
/// #![feature(concat_idents)]
1126-
///
1127-
/// # fn main() {
1128-
/// fn foobar() -> u32 { 23 }
1129-
///
1130-
/// let f = concat_idents!(foo, bar);
1131-
/// println!("{}", f());
1132-
///
1133-
/// // fn concat_idents!(new, fun, name) { } // not usable in this way!
1134-
/// # }
1135-
/// ```
1136-
#[unstable(
1137-
feature = "concat_idents",
1138-
issue = "29599",
1139-
reason = "`concat_idents` is not stable enough for use and is subject to change"
1140-
)]
1141-
#[deprecated(
1142-
since = "1.88.0",
1143-
note = "use `${concat(...)}` with the `macro_metavar_expr_concat` feature instead"
1144-
)]
1145-
#[rustc_builtin_macro]
1146-
#[macro_export]
1147-
macro_rules! concat_idents {
1148-
($($e:ident),+ $(,)?) => {{ /* compiler built-in */ }};
1149-
}
1150-
11511112
/// Concatenates literals into a byte slice.
11521113
///
11531114
/// This macro takes any number of comma-separated literals, and concatenates them all into

library/core/src/prelude/v1.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,10 +58,9 @@ pub use crate::fmt::macros::Debug;
5858
pub use crate::hash::macros::Hash;
5959

6060
#[stable(feature = "builtin_macro_prelude", since = "1.38.0")]
61-
#[allow(deprecated)]
6261
#[doc(no_inline)]
6362
pub use crate::{
64-
assert, cfg, column, compile_error, concat, concat_idents, env, file, format_args,
63+
assert, cfg, column, compile_error, concat, env, file, format_args,
6564
format_args_nl, include, include_bytes, include_str, line, log_syntax, module_path, option_env,
6665
stringify, trace_macros,
6766
};

library/std/src/lib.rs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -281,7 +281,6 @@
281281
#![feature(cfg_target_thread_local)]
282282
#![feature(cfi_encoding)]
283283
#![feature(char_max_len)]
284-
#![feature(concat_idents)]
285284
#![feature(core_float_math)]
286285
#![feature(decl_macro)]
287286
#![feature(deprecated_suggestion)]
@@ -717,10 +716,9 @@ pub use core::primitive;
717716
pub use core::todo;
718717
// Re-export built-in macros defined through core.
719718
#[stable(feature = "builtin_macro_prelude", since = "1.38.0")]
720-
#[allow(deprecated)]
721719
pub use core::{
722-
assert, assert_matches, cfg, column, compile_error, concat, concat_idents, const_format_args,
723-
env, file, format_args, format_args_nl, include, include_bytes, include_str, line, log_syntax,
720+
assert, assert_matches, cfg, column, compile_error, concat, const_format_args, env, file,
721+
format_args, format_args_nl, include, include_bytes, include_str, line, log_syntax,
724722
module_path, option_env, stringify, trace_macros,
725723
};
726724
// Re-export macros defined in core.

library/std/src/prelude/v1.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,10 +45,9 @@ pub use crate::result::Result::{self, Err, Ok};
4545

4646
// Re-exported built-in macros
4747
#[stable(feature = "builtin_macro_prelude", since = "1.38.0")]
48-
#[allow(deprecated)]
4948
#[doc(no_inline)]
5049
pub use core::prelude::v1::{
51-
assert, cfg, column, compile_error, concat, concat_idents, env, file, format_args,
50+
assert, cfg, column, compile_error, concat, env, file, format_args,
5251
format_args_nl, include, include_bytes, include_str, line, log_syntax, module_path, option_env,
5352
stringify, trace_macros, Clone, Copy, Debug, Default, Eq, Hash, Ord, PartialEq, PartialOrd,
5453
};

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,8 @@ In stable Rust, there is no way to create new identifiers by joining identifiers
88
`#![feature(macro_metavar_expr_concat)]` introduces a way to do this, using the concat metavariable expression.
99

1010
> This feature uses the syntax from [`macro_metavar_expr`] but is otherwise
11-
> independent. It replaces the old unstable feature [`concat_idents`].
11+
> independent. It replaces the since-removed unstable feature
12+
> [`concat_idents`].
1213
1314
> This is an experimental feature; it and its syntax will require a RFC before stabilization.
1415
@@ -126,8 +127,7 @@ test result: ok. 6 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; fini
126127

127128
[`paste`]: https://crates.io/crates/paste
128129
[RFC 3086]: https://rust-lang.github.io/rfcs/3086-macro-metavar-expr.html
129-
[`concat_idents!`]: https://doc.rust-lang.org/nightly/std/macro.concat_idents.html
130130
[`macro_metavar_expr`]: ../language-features/macro-metavar-expr.md
131-
[`concat_idents`]: ../library-features/concat-idents.md
131+
[`concat_idents`]: https://github.com/rust-lang/rust/issues/29599
132132
[#124225]: https://github.com/rust-lang/rust/issues/124225
133133
[declarative macros]: https://doc.rust-lang.org/stable/reference/macros-by-example.html

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

Lines changed: 0 additions & 27 deletions
This file was deleted.

src/tools/tidy/src/issues.txt

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2071,7 +2071,6 @@ ui/issues/issue-32782.rs
20712071
ui/issues/issue-32797.rs
20722072
ui/issues/issue-32805.rs
20732073
ui/issues/issue-3290.rs
2074-
ui/issues/issue-32950.rs
20752074
ui/issues/issue-32995-2.rs
20762075
ui/issues/issue-32995.rs
20772076
ui/issues/issue-33202.rs
@@ -2341,7 +2340,6 @@ ui/issues/issue-49934.rs
23412340
ui/issues/issue-49955.rs
23422341
ui/issues/issue-49973.rs
23432342
ui/issues/issue-50187.rs
2344-
ui/issues/issue-50403.rs
23452343
ui/issues/issue-50411.rs
23462344
ui/issues/issue-50415.rs
23472345
ui/issues/issue-50442.rs

src/tools/tidy/src/ui_tests.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ use ignore::Walk;
1717
const ENTRY_LIMIT: u32 = 901;
1818
// FIXME: The following limits should be reduced eventually.
1919

20-
const ISSUES_ENTRY_LIMIT: u32 = 1623;
20+
const ISSUES_ENTRY_LIMIT: u32 = 1619;
2121

2222
const EXPECTED_TEST_FILE_EXTENSIONS: &[&str] = &[
2323
"rs", // test source files

tests/rustdoc-js/big-result.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
#![feature(concat_idents)]
21
#![allow(nonstandard_style)]
32
/// Generate 250 items that all match the query, starting with the longest.
43
/// Those long items should be dropped from the result set, and the short ones
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
// Issue 32950
2+
// Ensure that using macros rather than a type doesn't break `derive`.
3+
4+
#[derive(Debug)]
5+
struct Nonsense<T> {
6+
//~^ ERROR type parameter `T` is never used
7+
should_be_vec_t: vec![T]
8+
//~^ ERROR `derive` cannot be used on items with type macros
9+
//~| ERROR expected type, found `expr` metavariable
10+
}
11+
12+
fn main() {}
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
error: `derive` cannot be used on items with type macros
2+
--> $DIR/nonsense-input-to-debug.rs:7:22
3+
|
4+
LL | should_be_vec_t: vec![T]
5+
| ^^^^^^^
6+
7+
error: expected type, found `expr` metavariable
8+
--> $DIR/nonsense-input-to-debug.rs:7:22
9+
|
10+
LL | should_be_vec_t: vec![T]
11+
| ^^^^^^^
12+
| |
13+
| expected type
14+
| in this macro invocation
15+
| this macro call doesn't expand to a type
16+
|
17+
= note: this error originates in the macro `vec` (in Nightly builds, run with -Z macro-backtrace for more info)
18+
19+
error[E0392]: type parameter `T` is never used
20+
--> $DIR/nonsense-input-to-debug.rs:5:17
21+
|
22+
LL | struct Nonsense<T> {
23+
| ^ unused type parameter
24+
|
25+
= help: consider removing `T`, referring to it in a field, or using a marker such as `PhantomData`
26+
= help: if you intended `T` to be a const parameter, use `const T: /* Type */` instead
27+
28+
error: aborting due to 3 previous errors
29+
30+
For more information about this error, try `rustc --explain E0392`.

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

Lines changed: 0 additions & 11 deletions
This file was deleted.

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

Lines changed: 0 additions & 23 deletions
This file was deleted.

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

Lines changed: 0 additions & 6 deletions
This file was deleted.

0 commit comments

Comments
 (0)