# HG changeset patch # User Link Mauve # Date 1760445689 0 # Node ID 94033091458b44bd9c1eb947763e33d083e25db2 # Parent 28d8b892fd0672477fda2224c43d05808e506029 formats: Update to ${concat(…)} to build on current nightly ${concat(…)} replaces the removed concat_idents!() macro, but doesn’t support being used in nested repetitions for now. We can remove the gen_match!() macro once this is supported again. diff --git a/formats/src/lib.rs b/formats/src/lib.rs --- a/formats/src/lib.rs +++ b/formats/src/lib.rs @@ -1,4 +1,4 @@ -#![feature(concat_idents)] +#![feature(macro_metavar_expr_concat)] #![deny(missing_docs)] //! Touhou formats. diff --git a/formats/src/th06/anm0.rs b/formats/src/th06/anm0.rs --- a/formats/src/th06/anm0.rs +++ b/formats/src/th06/anm0.rs @@ -108,6 +108,12 @@ })) } +macro_rules! gen_match { + ($arg_type:ident) => { + ${concat(le_, $arg_type)} + }; +} + macro_rules! declare_anm_instructions { ($($opcode:tt => fn $name:ident($($arg:ident: $arg_type:ident),*)),*,) => { /// Available instructions in an `Anm0`. @@ -124,7 +130,7 @@ $( $opcode => { $( - let (i2, $arg) = concat_idents!(le_, $arg_type)(i)?; + let (i2, $arg) = gen_match!($arg_type)(i)?; i = i2; )* Instruction::$name($($arg),*) diff --git a/formats/src/th06/ecl.rs b/formats/src/th06/ecl.rs --- a/formats/src/th06/ecl.rs +++ b/formats/src/th06/ecl.rs @@ -117,6 +117,12 @@ } } +macro_rules! gen_match { + ($arg_type:ident) => { + ${concat(le_, $arg_type)} + }; +} + macro_rules! declare_main_instructions { ($($opcode:tt => fn $name:ident($($arg:ident: $arg_type:ident),*)),*,) => { /// Available instructions in an `Ecl`. @@ -134,7 +140,7 @@ $( $opcode => { $( - let (i2, $arg) = concat_idents!(le_, $arg_type)(i)?; + let (i2, $arg) = gen_match!($arg_type)(i)?; i = i2; )* MainInstruction::$name($($arg),*) @@ -172,7 +178,7 @@ $( $opcode => { $( - let (i2, $arg) = concat_idents!(le_, $arg_type)(i)?; + let (i2, $arg) = gen_match!($arg_type)(i)?; i = i2; )* SubInstruction::$name($($arg),*) diff --git a/formats/src/th06/std.rs b/formats/src/th06/std.rs --- a/formats/src/th06/std.rs +++ b/formats/src/th06/std.rs @@ -124,6 +124,12 @@ } } +macro_rules! gen_match { + ($arg_type:ident) => { + ${concat(le_, $arg_type)} + }; +} + macro_rules! declare_stage_instructions { ($($opcode:tt => fn $name:ident($($arg:ident: $arg_type:ident),*)),*,) => { /// Available instructions in an `Stage`. @@ -141,7 +147,7 @@ $( $opcode => { $( - let (i2, $arg) = concat_idents!(le_, $arg_type)(i)?; + let (i2, $arg) = gen_match!($arg_type)(i)?; i = i2; )* Instruction::$name($($arg),*)