Skip to content

Commit 7995be9

Browse files
committed
Migrate some tests away from concat-idents
`concat_idents!` is in the process of being removed, but a few things it is used to test will still be relevant. Migrate these tests to something other than `concat_idents`.
1 parent d1d8e38 commit 7995be9

File tree

9 files changed

+95
-57
lines changed

9 files changed

+95
-57
lines changed

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

tests/ui/issues/issue-32950.rs

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
1-
#![feature(concat_idents)]
2-
#![expect(deprecated)] // concat_idents is deprecated
1+
// Issue: #32950
2+
// Ensure that using macros rather than a type doesn't break `derive`.
33

44
#[derive(Debug)]
5-
struct Baz<T>(
6-
concat_idents!(Foo, Bar) //~ ERROR `derive` cannot be used on items with type macros
7-
//~^ ERROR cannot find type `FooBar` in this scope
8-
);
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+
}
911

1012
fn main() {}

tests/ui/issues/issue-32950.stderr

Lines changed: 24 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,30 @@
11
error: `derive` cannot be used on items with type macros
2-
--> $DIR/issue-32950.rs:6:5
2+
--> $DIR/nonsense-input-to-debug.rs:7:22
33
|
4-
LL | concat_idents!(Foo, Bar)
5-
| ^^^^^^^^^^^^^^^^^^^^^^^^
4+
LL | should_be_vec_t: vec![T],
5+
| ^^^^^^^
66

7-
error[E0412]: cannot find type `FooBar` in this scope
8-
--> $DIR/issue-32950.rs:6:5
7+
error: expected type, found `expr` metavariable
8+
--> $DIR/nonsense-input-to-debug.rs:7:22
99
|
10-
LL | concat_idents!(Foo, Bar)
11-
| ^^^^^^^^^^^^^^^^^^^^^^^^ not found in this scope
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
1227

13-
error: aborting due to 2 previous errors
28+
error: aborting due to 3 previous errors
1429

15-
For more information about this error, try `rustc --explain E0412`.
30+
For more information about this error, try `rustc --explain E0392`.

tests/ui/issues/issue-50403.rs

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,12 @@
1-
#![feature(concat_idents)]
2-
#![expect(deprecated)] // concat_idents is deprecated
1+
// Issue 50403
2+
// Ensure that `concat` can't create empty identifiers
3+
// FIXME(macro_metavar_expr_concat): this error message could be improved
4+
5+
macro_rules! empty {
6+
() => { ${concat()} } //~ ERROR expected identifier or string literal
7+
//~^ERROR expected expression
8+
}
39

410
fn main() {
5-
let x = concat_idents!(); //~ ERROR `concat_idents!()` takes 1 or more arguments
11+
let x = empty!();
612
}

tests/ui/issues/issue-50403.stderr

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,19 @@
1-
error: `concat_idents!()` takes 1 or more arguments
2-
--> $DIR/issue-50403.rs:5:13
1+
error: expected identifier or string literal
2+
--> $DIR/empty-input.rs:6:14
33
|
4-
LL | let x = concat_idents!();
5-
| ^^^^^^^^^^^^^^^^
4+
LL | () => { ${concat()} }
5+
| ^^^^^^^^^^
66

7-
error: aborting due to 1 previous error
7+
error: expected expression, found `$`
8+
--> $DIR/empty-input.rs:6:13
9+
|
10+
LL | () => { ${concat()} }
11+
| ^ expected expression
12+
...
13+
LL | let x = empty!();
14+
| -------- in this macro invocation
15+
|
16+
= note: this error originates in the macro `empty` (in Nightly builds, run with -Z macro-backtrace for more info)
17+
18+
error: aborting due to 2 previous errors
819

tests/ui/unpretty/exhaustive.expanded.stdout

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
#![feature(auto_traits)]
1313
#![feature(box_patterns)]
1414
#![feature(builtin_syntax)]
15-
#![feature(concat_idents)]
1615
#![feature(const_trait_impl)]
1716
#![feature(decl_macro)]
1817
#![feature(deref_patterns)]
@@ -309,7 +308,6 @@ mod expressions {
309308

310309

311310

312-
// concat_idents is deprecated
313311

314312

315313

@@ -622,8 +620,12 @@ mod types {
622620
/*! there is no syntax for this */
623621
}
624622
/// TyKind::MacCall
625-
#[expect(deprecated)]
626-
fn ty_mac_call() { let _: T; let _: T; let _: T; }
623+
fn ty_mac_call() {
624+
macro_rules! ty { ($ty:ty) => { $ty } }
625+
let _: T;
626+
let _: T;
627+
let _: T;
628+
}
627629
/// TyKind::CVarArgs
628630
fn ty_c_var_args() {
629631
/*! FIXME: todo */

tests/ui/unpretty/exhaustive.hir.stderr

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,17 @@
11
error[E0697]: closures cannot be static
2-
--> $DIR/exhaustive.rs:211:9
2+
--> $DIR/exhaustive.rs:210:9
33
|
44
LL | static || value;
55
| ^^^^^^^^^
66

77
error[E0697]: closures cannot be static
8-
--> $DIR/exhaustive.rs:212:9
8+
--> $DIR/exhaustive.rs:211:9
99
|
1010
LL | static move || value;
1111
| ^^^^^^^^^^^^^^
1212

1313
error[E0728]: `await` is only allowed inside `async` functions and blocks
14-
--> $DIR/exhaustive.rs:241:13
14+
--> $DIR/exhaustive.rs:240:13
1515
|
1616
LL | fn expr_await() {
1717
| --------------- this is not `async`
@@ -20,19 +20,19 @@ LL | fut.await;
2020
| ^^^^^ only allowed inside `async` functions and blocks
2121

2222
error: in expressions, `_` can only be used on the left-hand side of an assignment
23-
--> $DIR/exhaustive.rs:290:9
23+
--> $DIR/exhaustive.rs:289:9
2424
|
2525
LL | _;
2626
| ^ `_` not allowed here
2727

2828
error[E0214]: parenthesized type parameters may only be used with a `Fn` trait
29-
--> $DIR/exhaustive.rs:300:9
29+
--> $DIR/exhaustive.rs:299:9
3030
|
3131
LL | x::();
3232
| ^^^^^ only `Fn` traits may use parentheses
3333

3434
error[E0214]: parenthesized type parameters may only be used with a `Fn` trait
35-
--> $DIR/exhaustive.rs:301:9
35+
--> $DIR/exhaustive.rs:300:9
3636
|
3737
LL | x::(T, T) -> T;
3838
| ^^^^^^^^^^^^^^ only `Fn` traits may use parentheses
@@ -44,31 +44,31 @@ LL + x::<T, T> -> T;
4444
|
4545

4646
error[E0214]: parenthesized type parameters may only be used with a `Fn` trait
47-
--> $DIR/exhaustive.rs:302:9
47+
--> $DIR/exhaustive.rs:301:9
4848
|
4949
LL | crate::() -> ()::expressions::() -> ()::expr_path;
5050
| ^^^^^^^^^^^^^^^ only `Fn` traits may use parentheses
5151

5252
error[E0214]: parenthesized type parameters may only be used with a `Fn` trait
53-
--> $DIR/exhaustive.rs:302:26
53+
--> $DIR/exhaustive.rs:301:26
5454
|
5555
LL | crate::() -> ()::expressions::() -> ()::expr_path;
5656
| ^^^^^^^^^^^^^^^^^^^^^ only `Fn` traits may use parentheses
5757

5858
error[E0214]: parenthesized type parameters may only be used with a `Fn` trait
59-
--> $DIR/exhaustive.rs:305:9
59+
--> $DIR/exhaustive.rs:304:9
6060
|
6161
LL | core::()::marker::()::PhantomData;
6262
| ^^^^^^^^ only `Fn` traits may use parentheses
6363

6464
error[E0214]: parenthesized type parameters may only be used with a `Fn` trait
65-
--> $DIR/exhaustive.rs:305:19
65+
--> $DIR/exhaustive.rs:304:19
6666
|
6767
LL | core::()::marker::()::PhantomData;
6868
| ^^^^^^^^^^ only `Fn` traits may use parentheses
6969

7070
error: `yield` can only be used in `#[coroutine]` closures, or `gen` blocks
71-
--> $DIR/exhaustive.rs:392:9
71+
--> $DIR/exhaustive.rs:391:9
7272
|
7373
LL | yield;
7474
| ^^^^^
@@ -79,29 +79,29 @@ LL | #[coroutine] fn expr_yield() {
7979
| ++++++++++++
8080

8181
error[E0703]: invalid ABI: found `C++`
82-
--> $DIR/exhaustive.rs:472:23
82+
--> $DIR/exhaustive.rs:471:23
8383
|
8484
LL | unsafe extern "C++" {}
8585
| ^^^^^ invalid ABI
8686
|
8787
= note: invoke `rustc --print=calling-conventions` for a full list of supported calling conventions
8888

8989
error: `..` patterns are not allowed here
90-
--> $DIR/exhaustive.rs:679:13
90+
--> $DIR/exhaustive.rs:678:13
9191
|
9292
LL | let ..;
9393
| ^^
9494
|
9595
= note: only allowed in tuple, tuple struct, and slice patterns
9696

9797
error[E0214]: parenthesized type parameters may only be used with a `Fn` trait
98-
--> $DIR/exhaustive.rs:794:16
98+
--> $DIR/exhaustive.rs:793:16
9999
|
100100
LL | let _: T() -> !;
101101
| ^^^^^^^^ only `Fn` traits may use parentheses
102102

103103
error[E0562]: `impl Trait` is not allowed in the type of variable bindings
104-
--> $DIR/exhaustive.rs:809:16
104+
--> $DIR/exhaustive.rs:808:16
105105
|
106106
LL | let _: impl Send;
107107
| ^^^^^^^^^
@@ -112,7 +112,7 @@ LL | let _: impl Send;
112112
= note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date
113113

114114
error[E0562]: `impl Trait` is not allowed in the type of variable bindings
115-
--> $DIR/exhaustive.rs:810:16
115+
--> $DIR/exhaustive.rs:809:16
116116
|
117117
LL | let _: impl Send + 'static;
118118
| ^^^^^^^^^^^^^^^^^^^
@@ -123,7 +123,7 @@ LL | let _: impl Send + 'static;
123123
= note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date
124124

125125
error[E0562]: `impl Trait` is not allowed in the type of variable bindings
126-
--> $DIR/exhaustive.rs:811:16
126+
--> $DIR/exhaustive.rs:810:16
127127
|
128128
LL | let _: impl 'static + Send;
129129
| ^^^^^^^^^^^^^^^^^^^
@@ -134,7 +134,7 @@ LL | let _: impl 'static + Send;
134134
= note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date
135135

136136
error[E0562]: `impl Trait` is not allowed in the type of variable bindings
137-
--> $DIR/exhaustive.rs:812:16
137+
--> $DIR/exhaustive.rs:811:16
138138
|
139139
LL | let _: impl ?Sized;
140140
| ^^^^^^^^^^^
@@ -145,7 +145,7 @@ LL | let _: impl ?Sized;
145145
= note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date
146146

147147
error[E0562]: `impl Trait` is not allowed in the type of variable bindings
148-
--> $DIR/exhaustive.rs:813:16
148+
--> $DIR/exhaustive.rs:812:16
149149
|
150150
LL | let _: impl ~const Clone;
151151
| ^^^^^^^^^^^^^^^^^
@@ -156,7 +156,7 @@ LL | let _: impl ~const Clone;
156156
= note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date
157157

158158
error[E0562]: `impl Trait` is not allowed in the type of variable bindings
159-
--> $DIR/exhaustive.rs:814:16
159+
--> $DIR/exhaustive.rs:813:16
160160
|
161161
LL | let _: impl for<'a> Send;
162162
| ^^^^^^^^^^^^^^^^^

tests/ui/unpretty/exhaustive.hir.stdout

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111
#![feature(auto_traits)]
1212
#![feature(box_patterns)]
1313
#![feature(builtin_syntax)]
14-
#![feature(concat_idents)]
1514
#![feature(const_trait_impl)]
1615
#![feature(decl_macro)]
1716
#![feature(deref_patterns)]
@@ -349,7 +348,6 @@ mod expressions {
349348

350349

351350

352-
// concat_idents is deprecated
353351

354352

355353

@@ -696,8 +694,12 @@ mod types {
696694
/*! there is no syntax for this */
697695
fn ty_implicit_self() { }
698696
/// TyKind::MacCall
699-
#[expect(deprecated)]
700-
fn ty_mac_call() { let _: T; let _: T; let _: T; }
697+
fn ty_mac_call() {
698+
macro_rules! ty { ($ty:ty) => { $ty } }
699+
let _: T;
700+
let _: T;
701+
let _: T;
702+
}
701703
/// TyKind::CVarArgs
702704
/*! FIXME: todo */
703705
fn ty_c_var_args() { }

tests/ui/unpretty/exhaustive.rs

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111
#![feature(auto_traits)]
1212
#![feature(box_patterns)]
1313
#![feature(builtin_syntax)]
14-
#![feature(concat_idents)]
1514
#![feature(const_trait_impl)]
1615
#![feature(decl_macro)]
1716
#![feature(deref_patterns)]
@@ -835,11 +834,13 @@ mod types {
835834
}
836835

837836
/// TyKind::MacCall
838-
#[expect(deprecated)] // concat_idents is deprecated
839837
fn ty_mac_call() {
840-
let _: concat_idents!(T);
841-
let _: concat_idents![T];
842-
let _: concat_idents! { T };
838+
macro_rules! ty {
839+
($ty:ty) => { $ty }
840+
}
841+
let _: ty!(T);
842+
let _: ty![T];
843+
let _: ty! { T };
843844
}
844845

845846
/// TyKind::CVarArgs

0 commit comments

Comments
 (0)