about summary refs log tree commit diff
path: root/tests/ui/parser/macro/mbe-bare-trait-object-maybe-trait-bound.rs
diff options
context:
space:
mode:
Diffstat (limited to 'tests/ui/parser/macro/mbe-bare-trait-object-maybe-trait-bound.rs')
-rw-r--r--tests/ui/parser/macro/mbe-bare-trait-object-maybe-trait-bound.rs16
1 files changed, 16 insertions, 0 deletions
diff --git a/tests/ui/parser/macro/mbe-bare-trait-object-maybe-trait-bound.rs b/tests/ui/parser/macro/mbe-bare-trait-object-maybe-trait-bound.rs
new file mode 100644
index 00000000000..fe062d62e5a
--- /dev/null
+++ b/tests/ui/parser/macro/mbe-bare-trait-object-maybe-trait-bound.rs
@@ -0,0 +1,16 @@
+// Check that `?Trait` matches the macro fragment specifier `ty`.
+// Syntactically trait object types can be "bare" (i.e., lack the prefix `dyn`),
+// even in newer editions like Rust 2021.
+// Therefore the arm `?$Trait:path` shouldn't get reached.
+
+// edition: 2021
+// check-pass
+
+macro_rules! check {
+    ($Ty:ty) => {};
+    (?$Trait:path) => { compile_error!("non-ty"); };
+}
+
+check! { ?Trait }
+
+fn main() {}