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`.
This commit is contained in:
Trevor Gross
2025-06-19 06:12:22 +00:00
parent d1d8e386c5
commit f8ab9343b8
9 changed files with 95 additions and 57 deletions

View File

@@ -1,4 +1,3 @@
#![feature(concat_idents)]
#![allow(nonstandard_style)]
/// Generate 250 items that all match the query, starting with the longest.
/// Those long items should be dropped from the result set, and the short ones

View File

@@ -1,10 +1,12 @@
#![feature(concat_idents)]
#![expect(deprecated)] // concat_idents is deprecated
// Issue: #32950
// Ensure that using macros rather than a type doesn't break `derive`.
#[derive(Debug)]
struct Baz<T>(
concat_idents!(Foo, Bar) //~ ERROR `derive` cannot be used on items with type macros
//~^ ERROR cannot find type `FooBar` in this scope
);
struct Nonsense<T> {
//~^ ERROR type parameter `T` is never used
should_be_vec_t: vec![T],
//~^ ERROR `derive` cannot be used on items with type macros
//~| ERROR expected type, found `expr` metavariable
}
fn main() {}

View File

@@ -1,15 +1,30 @@
error: `derive` cannot be used on items with type macros
--> $DIR/issue-32950.rs:6:5
--> $DIR/issue-32950.rs:7:22
|
LL | concat_idents!(Foo, Bar)
| ^^^^^^^^^^^^^^^^^^^^^^^^
LL | should_be_vec_t: vec![T],
| ^^^^^^^
error[E0412]: cannot find type `FooBar` in this scope
--> $DIR/issue-32950.rs:6:5
error: expected type, found `expr` metavariable
--> $DIR/issue-32950.rs:7:22
|
LL | concat_idents!(Foo, Bar)
| ^^^^^^^^^^^^^^^^^^^^^^^^ not found in this scope
LL | should_be_vec_t: vec![T],
| ^^^^^^^
| |
| expected type
| in this macro invocation
| this macro call doesn't expand to a type
|
= note: this error originates in the macro `vec` (in Nightly builds, run with -Z macro-backtrace for more info)
error: aborting due to 2 previous errors
error[E0392]: type parameter `T` is never used
--> $DIR/issue-32950.rs:5:17
|
LL | struct Nonsense<T> {
| ^ unused type parameter
|
= help: consider removing `T`, referring to it in a field, or using a marker such as `PhantomData`
= help: if you intended `T` to be a const parameter, use `const T: /* Type */` instead
For more information about this error, try `rustc --explain E0412`.
error: aborting due to 3 previous errors
For more information about this error, try `rustc --explain E0392`.

View File

@@ -1,6 +1,12 @@
#![feature(concat_idents)]
#![expect(deprecated)] // concat_idents is deprecated
// Issue 50403
// Ensure that `concat` can't create empty identifiers
// FIXME(macro_metavar_expr_concat): this error message could be improved
macro_rules! empty {
() => { ${concat()} } //~ ERROR expected identifier or string literal
//~^ERROR expected expression
}
fn main() {
let x = concat_idents!(); //~ ERROR `concat_idents!()` takes 1 or more arguments
let x = empty!();
}

View File

@@ -1,8 +1,19 @@
error: `concat_idents!()` takes 1 or more arguments
--> $DIR/issue-50403.rs:5:13
error: expected identifier or string literal
--> $DIR/issue-50403.rs:6:14
|
LL | let x = concat_idents!();
| ^^^^^^^^^^^^^^^^
LL | () => { ${concat()} }
| ^^^^^^^^^^
error: aborting due to 1 previous error
error: expected expression, found `$`
--> $DIR/issue-50403.rs:6:13
|
LL | () => { ${concat()} }
| ^ expected expression
...
LL | let x = empty!();
| -------- in this macro invocation
|
= note: this error originates in the macro `empty` (in Nightly builds, run with -Z macro-backtrace for more info)
error: aborting due to 2 previous errors

View File

@@ -12,7 +12,6 @@
#![feature(auto_traits)]
#![feature(box_patterns)]
#![feature(builtin_syntax)]
#![feature(concat_idents)]
#![feature(const_trait_impl)]
#![feature(decl_macro)]
#![feature(deref_patterns)]
@@ -309,7 +308,6 @@ mod expressions {
// concat_idents is deprecated
@@ -622,8 +620,12 @@ mod types {
/*! there is no syntax for this */
}
/// TyKind::MacCall
#[expect(deprecated)]
fn ty_mac_call() { let _: T; let _: T; let _: T; }
fn ty_mac_call() {
macro_rules! ty { ($ty:ty) => { $ty } }
let _: T;
let _: T;
let _: T;
}
/// TyKind::CVarArgs
fn ty_c_var_args() {
/*! FIXME: todo */

View File

@@ -1,17 +1,17 @@
error[E0697]: closures cannot be static
--> $DIR/exhaustive.rs:211:9
--> $DIR/exhaustive.rs:210:9
|
LL | static || value;
| ^^^^^^^^^
error[E0697]: closures cannot be static
--> $DIR/exhaustive.rs:212:9
--> $DIR/exhaustive.rs:211:9
|
LL | static move || value;
| ^^^^^^^^^^^^^^
error[E0728]: `await` is only allowed inside `async` functions and blocks
--> $DIR/exhaustive.rs:241:13
--> $DIR/exhaustive.rs:240:13
|
LL | fn expr_await() {
| --------------- this is not `async`
@@ -20,19 +20,19 @@ LL | fut.await;
| ^^^^^ only allowed inside `async` functions and blocks
error: in expressions, `_` can only be used on the left-hand side of an assignment
--> $DIR/exhaustive.rs:290:9
--> $DIR/exhaustive.rs:289:9
|
LL | _;
| ^ `_` not allowed here
error[E0214]: parenthesized type parameters may only be used with a `Fn` trait
--> $DIR/exhaustive.rs:300:9
--> $DIR/exhaustive.rs:299:9
|
LL | x::();
| ^^^^^ only `Fn` traits may use parentheses
error[E0214]: parenthesized type parameters may only be used with a `Fn` trait
--> $DIR/exhaustive.rs:301:9
--> $DIR/exhaustive.rs:300:9
|
LL | x::(T, T) -> T;
| ^^^^^^^^^^^^^^ only `Fn` traits may use parentheses
@@ -44,31 +44,31 @@ LL + x::<T, T> -> T;
|
error[E0214]: parenthesized type parameters may only be used with a `Fn` trait
--> $DIR/exhaustive.rs:302:9
--> $DIR/exhaustive.rs:301:9
|
LL | crate::() -> ()::expressions::() -> ()::expr_path;
| ^^^^^^^^^^^^^^^ only `Fn` traits may use parentheses
error[E0214]: parenthesized type parameters may only be used with a `Fn` trait
--> $DIR/exhaustive.rs:302:26
--> $DIR/exhaustive.rs:301:26
|
LL | crate::() -> ()::expressions::() -> ()::expr_path;
| ^^^^^^^^^^^^^^^^^^^^^ only `Fn` traits may use parentheses
error[E0214]: parenthesized type parameters may only be used with a `Fn` trait
--> $DIR/exhaustive.rs:305:9
--> $DIR/exhaustive.rs:304:9
|
LL | core::()::marker::()::PhantomData;
| ^^^^^^^^ only `Fn` traits may use parentheses
error[E0214]: parenthesized type parameters may only be used with a `Fn` trait
--> $DIR/exhaustive.rs:305:19
--> $DIR/exhaustive.rs:304:19
|
LL | core::()::marker::()::PhantomData;
| ^^^^^^^^^^ only `Fn` traits may use parentheses
error: `yield` can only be used in `#[coroutine]` closures, or `gen` blocks
--> $DIR/exhaustive.rs:392:9
--> $DIR/exhaustive.rs:391:9
|
LL | yield;
| ^^^^^
@@ -79,7 +79,7 @@ LL | #[coroutine] fn expr_yield() {
| ++++++++++++
error[E0703]: invalid ABI: found `C++`
--> $DIR/exhaustive.rs:472:23
--> $DIR/exhaustive.rs:471:23
|
LL | unsafe extern "C++" {}
| ^^^^^ invalid ABI
@@ -87,7 +87,7 @@ LL | unsafe extern "C++" {}
= note: invoke `rustc --print=calling-conventions` for a full list of supported calling conventions
error: `..` patterns are not allowed here
--> $DIR/exhaustive.rs:679:13
--> $DIR/exhaustive.rs:678:13
|
LL | let ..;
| ^^
@@ -95,13 +95,13 @@ LL | let ..;
= note: only allowed in tuple, tuple struct, and slice patterns
error[E0214]: parenthesized type parameters may only be used with a `Fn` trait
--> $DIR/exhaustive.rs:794:16
--> $DIR/exhaustive.rs:793:16
|
LL | let _: T() -> !;
| ^^^^^^^^ only `Fn` traits may use parentheses
error[E0562]: `impl Trait` is not allowed in the type of variable bindings
--> $DIR/exhaustive.rs:809:16
--> $DIR/exhaustive.rs:808:16
|
LL | let _: impl Send;
| ^^^^^^^^^
@@ -112,7 +112,7 @@ LL | let _: impl Send;
= note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date
error[E0562]: `impl Trait` is not allowed in the type of variable bindings
--> $DIR/exhaustive.rs:810:16
--> $DIR/exhaustive.rs:809:16
|
LL | let _: impl Send + 'static;
| ^^^^^^^^^^^^^^^^^^^
@@ -123,7 +123,7 @@ LL | let _: impl Send + 'static;
= note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date
error[E0562]: `impl Trait` is not allowed in the type of variable bindings
--> $DIR/exhaustive.rs:811:16
--> $DIR/exhaustive.rs:810:16
|
LL | let _: impl 'static + Send;
| ^^^^^^^^^^^^^^^^^^^
@@ -134,7 +134,7 @@ LL | let _: impl 'static + Send;
= note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date
error[E0562]: `impl Trait` is not allowed in the type of variable bindings
--> $DIR/exhaustive.rs:812:16
--> $DIR/exhaustive.rs:811:16
|
LL | let _: impl ?Sized;
| ^^^^^^^^^^^
@@ -145,7 +145,7 @@ LL | let _: impl ?Sized;
= note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date
error[E0562]: `impl Trait` is not allowed in the type of variable bindings
--> $DIR/exhaustive.rs:813:16
--> $DIR/exhaustive.rs:812:16
|
LL | let _: impl ~const Clone;
| ^^^^^^^^^^^^^^^^^
@@ -156,7 +156,7 @@ LL | let _: impl ~const Clone;
= note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date
error[E0562]: `impl Trait` is not allowed in the type of variable bindings
--> $DIR/exhaustive.rs:814:16
--> $DIR/exhaustive.rs:813:16
|
LL | let _: impl for<'a> Send;
| ^^^^^^^^^^^^^^^^^

View File

@@ -11,7 +11,6 @@
#![feature(auto_traits)]
#![feature(box_patterns)]
#![feature(builtin_syntax)]
#![feature(concat_idents)]
#![feature(const_trait_impl)]
#![feature(decl_macro)]
#![feature(deref_patterns)]
@@ -349,7 +348,6 @@ mod expressions {
// concat_idents is deprecated
@@ -696,8 +694,12 @@ mod types {
/*! there is no syntax for this */
fn ty_implicit_self() { }
/// TyKind::MacCall
#[expect(deprecated)]
fn ty_mac_call() { let _: T; let _: T; let _: T; }
fn ty_mac_call() {
macro_rules! ty { ($ty:ty) => { $ty } }
let _: T;
let _: T;
let _: T;
}
/// TyKind::CVarArgs
/*! FIXME: todo */
fn ty_c_var_args() { }

View File

@@ -11,7 +11,6 @@
#![feature(auto_traits)]
#![feature(box_patterns)]
#![feature(builtin_syntax)]
#![feature(concat_idents)]
#![feature(const_trait_impl)]
#![feature(decl_macro)]
#![feature(deref_patterns)]
@@ -835,11 +834,13 @@ mod types {
}
/// TyKind::MacCall
#[expect(deprecated)] // concat_idents is deprecated
fn ty_mac_call() {
let _: concat_idents!(T);
let _: concat_idents![T];
let _: concat_idents! { T };
macro_rules! ty {
($ty:ty) => { $ty }
}
let _: ty!(T);
let _: ty![T];
let _: ty! { T };
}
/// TyKind::CVarArgs