rust/tests/ui/macros/metavar-expressions/concat-raw-identifiers.rs
Trevor Gross cf5eb27910 mbe: Restructure macro_metavar_expr tests
These tests have expanded beyond the RFC, so rename the directory
`rfc-3086-metavar-expr` to `metavar-expressions`. `concat` (which wasn't
part of the RFC) now fits in this group, so merge its tests into the
`metavar-expressions` directory.

Additionally rename some related `issue-*` tests.
2025-06-23 06:25:55 -05:00

82 lines
2.0 KiB
Rust

#![feature(macro_metavar_expr_concat)]
macro_rules! idents_01 {
($rhs:ident) => {
let ${concat(abc, $rhs)}: () = ();
//~^ ERROR `${concat(..)}` currently does not support raw identifiers
};
}
macro_rules! idents_10 {
($lhs:ident) => {
let ${concat($lhs, abc)}: () = ();
//~^ ERROR `${concat(..)}` currently does not support raw identifiers
};
}
macro_rules! idents_11 {
($lhs:ident, $rhs:ident) => {
let ${concat($lhs, $rhs)}: () = ();
//~^ ERROR `${concat(..)}` currently does not support raw identifiers
//~| ERROR `${concat(..)}` currently does not support raw identifiers
//~| ERROR `${concat(..)}` currently does not support raw identifiers
};
}
macro_rules! no_params {
() => {
let ${concat(r#abc, abc)}: () = ();
//~^ ERROR expected identifier or string literal
//~| ERROR expected pattern, found `$`
let ${concat(abc, r#abc)}: () = ();
//~^ ERROR expected identifier or string literal
let ${concat(r#abc, r#abc)}: () = ();
//~^ ERROR expected identifier or string literal
};
}
macro_rules! tts_01 {
($rhs:tt) => {
let ${concat(abc, $rhs)}: () = ();
//~^ ERROR `${concat(..)}` currently does not support raw identifiers
};
}
macro_rules! tts_10 {
($lhs:tt) => {
let ${concat($lhs, abc)}: () = ();
//~^ ERROR `${concat(..)}` currently does not support raw identifiers
};
}
macro_rules! tts_11 {
($lhs:tt, $rhs:tt) => {
let ${concat($lhs, $rhs)}: () = ();
//~^ ERROR `${concat(..)}` currently does not support raw identifiers
//~| ERROR `${concat(..)}` currently does not support raw identifiers
//~| ERROR `${concat(..)}` currently does not support raw identifiers
};
}
fn main() {
idents_01!(r#_c);
idents_10!(r#_c);
idents_11!(r#_c, d);
idents_11!(_e, r#f);
idents_11!(r#_g, r#h);
tts_01!(r#_c);
tts_10!(r#_c);
tts_11!(r#_c, d);
tts_11!(_e, r#f);
tts_11!(r#_g, r#h);
no_params!();
}