diff options
| author | Trevor Gross <tmgross@umich.edu> | 2025-06-23 00:42:06 -0500 |
|---|---|---|
| committer | Trevor Gross <tmgross@umich.edu> | 2025-06-30 19:02:36 +0000 |
| commit | b3d74da9b8edb47b9b785afb7ac9f1a9a1841835 (patch) | |
| tree | c27b4a69fa10f816b17c230e3592828074d6f329 /tests/ui/macros/metavar-expressions/concat-trace-errors.rs | |
| parent | 876835de11c3405f5de83a6b14755583bb3ff185 (diff) | |
| download | rust-b3d74da9b8edb47b9b785afb7ac9f1a9a1841835.tar.gz rust-b3d74da9b8edb47b9b785afb7ac9f1a9a1841835.zip | |
mbe: Extend metavariable expression tests
Add tests showing the current state to make it more clear when output gets updated later in refactoring.
Diffstat (limited to 'tests/ui/macros/metavar-expressions/concat-trace-errors.rs')
| -rw-r--r-- | tests/ui/macros/metavar-expressions/concat-trace-errors.rs | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/tests/ui/macros/metavar-expressions/concat-trace-errors.rs b/tests/ui/macros/metavar-expressions/concat-trace-errors.rs new file mode 100644 index 00000000000..45407f5e86d --- /dev/null +++ b/tests/ui/macros/metavar-expressions/concat-trace-errors.rs @@ -0,0 +1,33 @@ +// 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() {} |
