pub struct Char3(pub [i8; 3]);
macro_rules! values {
($($token:ident($value:literal) $(as $inner:ty)? => $attr:meta,)*) => {
#[derive(Debug)]
pub enum TokenKind {
$(
#[$attr]
$token $(Char3([$inner, -3, $inner]))? = $value,
)*
}
};
}
values!(STRING(1) as (String) => cfg(test),);
pub fn main() {}
rustc 1.93.0-nightly (01867557c 2025-11-12)
binary: rustc
commit-hash: 01867557cd7dbe256a031a7b8e28d05daecd75ab
commit-date: 2025-11-12
host: x86_64-apple-darwin
release: 1.93.0-nightly
LLVM version: 21.1.5
error: expected `;` or `]`, found `,`
--> 04.rs:9:39
|
6 | pub enum TokenKind {
| --------- while parsing this enum
...
9 | $token $(Char3([$inner, -3, $inner]))? = $value,
| ^ expected `;` or `]`
...
15 | values!(STRING(1) as (String) => cfg(test),);
| -------------------------------------------- in this macro invocation
|
= help: enum variants can be `Variant`, `Variant = <integer>`, `Variant(Type, ..., TypeN)` or `Variant { fields: Types }`
= note: this error originates in the macro `values` (in Nightly builds, run with -Z macro-backtrace for more info)
error: expected one of `(`, `,`, `=`, `{`, or `}`, found `Char3`
--> 04.rs:9:26
|
9 | $token $(Char3([$inner, -3, $inner]))? = $value,
| - ^^^^^ expected one of `(`, `,`, `=`, `{`, or `}`
| |
| help: missing `,`
...
15 | values!(STRING(1) as (String) => cfg(test),);
| -------------------------------------------- in this macro invocation
|
= note: this error originates in the macro `values` (in Nightly builds, run with -Z macro-backtrace for more info)
error: macro expansion ignores `)` and any tokens following
--> 04.rs:9:52
|
9 | $token $(Char3([$inner, -3, $inner]))? = $value,
| ^
...
15 | values!(STRING(1) as (String) => cfg(test),);
| -------------------------------------------- caused by the macro expansion here
|
= note: the usage of `values!` is likely invalid in item context
thread 'rustc' (303421) panicked at compiler/rustc_builtin_macros/src/cfg_eval.rs:116:70:
called `Option::unwrap()` on a `None` value
Code
A mutant of
glacier2's fixed/96818.rsMeta
rustc --version --verbose:Error output
Command:
rustcBacktrace
Notes
compiler/rustc_builtin_macros/src/cfg_eval.rs Line-116rust/compiler/rustc_builtin_macros/src/cfg_eval.rs
Lines 111 to 119 in 0186755
Duplication Check