diff options
| author | Matthias Krüger <476013+matthiaskrgr@users.noreply.github.com> | 2025-07-01 04:25:36 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-07-01 04:25:36 +0200 |
| commit | cfe1942a3f1a98ea733b544559bd4845e41d5797 (patch) | |
| tree | d5503c6f0ad2ff03ab758d510e5f2f4981e0ab18 /tests/ui/macros/metavar-expressions/concat-trace-errors.rs | |
| parent | e2ea213874477e0874af598eecdb730ef2a52b32 (diff) | |
| parent | a1a066999b9fbfc10e93931d9a552bf87dc32e4d (diff) | |
| download | rust-cfe1942a3f1a98ea733b544559bd4845e41d5797.tar.gz rust-cfe1942a3f1a98ea733b544559bd4845e41d5797.zip | |
Rollup merge of #143245 - tgross35:metavariable-expr-organization, r=petrochenkov
mbe: Add tests and restructure metavariable expressions Add tests that show better diagnostics, and factor `concat` handling to a separate function. Each commit message has further details. This performs the nonfunctional perparation for further changes such as https://github.com/rust-lang/rust/pull/142950 and https://github.com/rust-lang/rust/pull/142975 .
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() {} |
