mirror of
https://github.com/rust-lang/rust.git
synced 2025-11-01 13:34:38 +00:00
Add tests showing the current state to make it more clear when output gets updated later in refactoring.
34 lines
807 B
Rust
34 lines
807 B
Rust
// Our diagnostics should be able to point to a specific input that caused an invalid
|
|
// identifier.
|
|
|
|
#![feature(macro_metavar_expr_concat)]
|
|
|
|
// See what we can do without expanding anything
|
|
macro_rules! pre_expansion {
|
|
($a:ident) => {
|
|
${concat("hi", " bye ")};
|
|
${concat("hi", "-", "bye")};
|
|
${concat($a, "-")};
|
|
}
|
|
}
|
|
|
|
macro_rules! post_expansion {
|
|
($a:literal) => {
|
|
const _: () = ${concat("hi", $a, "bye")};
|
|
//~^ ERROR is not generating a valid identifier
|
|
}
|
|
}
|
|
|
|
post_expansion!("!");
|
|
|
|
macro_rules! post_expansion_many {
|
|
($a:ident, $b:ident, $c:ident, $d:literal, $e:ident) => {
|
|
const _: () = ${concat($a, $b, $c, $d, $e)};
|
|
//~^ ERROR is not generating a valid identifier
|
|
}
|
|
}
|
|
|
|
post_expansion_many!(a, b, c, ".d", e);
|
|
|
|
fn main() {}
|