about summary refs log tree commit diff
path: root/tests/ui/macros/metavar-expressions/usage-errors.rs
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2025-07-01 05:31:05 +0000
committerbors <bors@rust-lang.org>2025-07-01 05:31:05 +0000
commitf46ce66fcc3d6058f90ac5bf0930f940f1e7b0ca (patch)
tree17a06668752fe94c0824b6b9788c02e7fbf56f1e /tests/ui/macros/metavar-expressions/usage-errors.rs
parent6988a8fea774a2a20ebebddb7dbf15dd6ef594f9 (diff)
parent3944c8ce447404dc45c00e125baf6bbbd728b501 (diff)
downloadrust-f46ce66fcc3d6058f90ac5bf0930f940f1e7b0ca.tar.gz
rust-f46ce66fcc3d6058f90ac5bf0930f940f1e7b0ca.zip
Auto merge of #143267 - matthiaskrgr:rollup-suvzar6, r=matthiaskrgr
Rollup of 8 pull requests

Successful merges:

 - rust-lang/rust#143125 (Disable f16 on Aarch64 without neon for llvm < 20.1.1)
 - rust-lang/rust#143156 (inherit `#[align]` from trait method prototypes)
 - rust-lang/rust#143178 (rustdoc default faviocon)
 - rust-lang/rust#143234 (Replace `ItemCtxt::report_placeholder_type_error` match with a call to `TyCtxt::def_descr`)
 - rust-lang/rust#143245 (mbe: Add tests and restructure metavariable expressions)
 - rust-lang/rust#143257 (Upgrade dependencies in run-make-support)
 - rust-lang/rust#143263 (linkify CodeSuggestion in doc comments)
 - rust-lang/rust#143264 (fix: Emit suggestion filename if primary diagnostic span is dummy)

Failed merges:

 - rust-lang/rust#143251 (bootstrap: add build.tidy-extra-checks option)

r? `@ghost`
`@rustbot` modify labels: rollup
Diffstat (limited to 'tests/ui/macros/metavar-expressions/usage-errors.rs')
-rw-r--r--tests/ui/macros/metavar-expressions/usage-errors.rs55
1 files changed, 55 insertions, 0 deletions
diff --git a/tests/ui/macros/metavar-expressions/usage-errors.rs b/tests/ui/macros/metavar-expressions/usage-errors.rs
new file mode 100644
index 00000000000..feff02e2ce4
--- /dev/null
+++ b/tests/ui/macros/metavar-expressions/usage-errors.rs
@@ -0,0 +1,55 @@
+// Errors for the `count` and `length` metavariable expressions
+
+#![feature(macro_metavar_expr)]
+
+// `curly` = Right hand side curly brackets
+// `no_rhs_dollar` = No dollar sign at the right hand side meta variable "function"
+// `round` = Left hand side round brackets
+
+macro_rules! curly__no_rhs_dollar__round {
+    ( $( $i:ident ),* ) => { ${ count($i) } };
+}
+const _: u32 = curly__no_rhs_dollar__round!(a, b, c);
+
+macro_rules! curly__no_rhs_dollar__no_round {
+    ( $i:ident ) => { ${ count($i) } };
+    //~^ ERROR `count` can not be placed inside the innermost repetition
+}
+curly__no_rhs_dollar__no_round!(a);
+
+macro_rules! curly__rhs_dollar__no_round {
+    ( $i:ident ) => { ${ count($i) } };
+    //~^ ERROR `count` can not be placed inside the innermost repetition
+}
+curly__rhs_dollar__no_round !(a);
+
+#[rustfmt::skip] // autoformatters can break a few of the error traces
+macro_rules! no_curly__no_rhs_dollar__round {
+    ( $( $i:ident ),* ) => { count(i) };
+    //~^ ERROR missing `fn` or `struct` for function or struct definition
+}
+no_curly__no_rhs_dollar__round !(a, b, c);
+
+#[rustfmt::skip] // autoformatters can break a few of the error traces
+macro_rules! no_curly__no_rhs_dollar__no_round {
+    ( $i:ident ) => { count(i) };
+    //~^ ERROR missing `fn` or `struct` for function or struct definition
+}
+no_curly__no_rhs_dollar__no_round !(a);
+
+#[rustfmt::skip] // autoformatters can break a few of the error traces
+macro_rules! no_curly__rhs_dollar__round {
+    ( $( $i:ident ),* ) => { count($i) };
+    //~^ ERROR variable `i` is still repeating at this depth
+}
+no_curly__rhs_dollar__round! (a);
+
+#[rustfmt::skip] // autoformatters can break a few of the error traces
+macro_rules! no_curly__rhs_dollar__no_round {
+    ( $i:ident ) => { count($i) };
+    //~^ ERROR cannot find function `count` in this scope
+}
+const _: u32 = no_curly__rhs_dollar__no_round! (a);
+//~^ ERROR cannot find value `a` in this scope
+
+fn main() {}