Macro_metavar_expr_concat not working as concat_idents

⚓ Rust    📅 2025-09-08    👤 surdeus    👁️ 2      

surdeus

Hi,

I just updated nightly and noted that concat_idents! is no longer ok for use. I've tried to migrate to the new macro_metavar_expr_concat but struggling to make it work.

I used to have the following macro for generating methods calling the underlying assembly methods in the Sleef library:

macro_rules! im_simd_f {
    ($i:ident,$( $x:ident ),* ) => {
        #[inline(always)]
        fn $i(self) -> Self {Self(unsafe { concat_idents!(Sleef_, $($x,)*)(self.0.into()) }.into())}
    };
}


// For example called as the following for the exp_m1 function (for a 16 lane type):
im_simd_f!(exp_m1, expm1, f16, _u10);

However, trying to do the same thing with the new concat(..):


#[cfg(target_os = "windows")]
macro_rules! im_simd_f {
    ($i:ident,$( $x:ident ),* ) => {
        #[inline(always)]
        fn $i(self) -> Self {Self(unsafe {  ${concat(Sleef_, $($x,)*)} (self.0.into()) }.into())}
    };
}

I seem unable to escape the compiler errors messages:


error: expected identifier or string literal
  --> ad\src\macros.rs:78:63
   |
78 |         fn $i(self) -> Self {Self(unsafe {  ${concat(Sleef_, $($x,)*)} (self.0.into()) }.into())}
   |                                                               ^^^^^


Does anyone have any pointers here?

Regards

1 post - 1 participant

Read full topic

🏷️ Rust_feed