about summary refs log tree commit diff
path: root/tests/ui/rfcs/rfc-2632-const-trait-impl/mbe-bare-trait-objects-const-trait-bounds.rs
diff options
context:
space:
mode:
Diffstat (limited to 'tests/ui/rfcs/rfc-2632-const-trait-impl/mbe-bare-trait-objects-const-trait-bounds.rs')
-rw-r--r--tests/ui/rfcs/rfc-2632-const-trait-impl/mbe-bare-trait-objects-const-trait-bounds.rs20
1 files changed, 20 insertions, 0 deletions
diff --git a/tests/ui/rfcs/rfc-2632-const-trait-impl/mbe-bare-trait-objects-const-trait-bounds.rs b/tests/ui/rfcs/rfc-2632-const-trait-impl/mbe-bare-trait-objects-const-trait-bounds.rs
new file mode 100644
index 00000000000..2304a766aaf
--- /dev/null
+++ b/tests/ui/rfcs/rfc-2632-const-trait-impl/mbe-bare-trait-objects-const-trait-bounds.rs
@@ -0,0 +1,20 @@
+// Ensure that we don't consider `const Trait` and `~const Trait` to
+// match the macro fragment specifier `ty` as that would be a breaking
+// change theoretically speaking. Syntactically trait object types can
+// be "bare", i.e., lack the prefix `dyn`.
+// By contrast, `?Trait` *does* match `ty` and therefore an arm like
+// `?$Trait:path` would never be reached.
+// See `parser/macro/mbe-bare-trait-object-maybe-trait-bound.rs`.
+
+// check-pass
+
+macro_rules! check {
+    ($Type:ty) => { compile_error!("ty"); };
+    (const $Trait:path) => {};
+    (~const $Trait:path) => {};
+}
+
+check! { const Trait }
+check! { ~const Trait }
+
+fn main() {}