about summary refs log tree commit diff
path: root/tests
diff options
context:
space:
mode:
authorMichael Goulet <michael@errs.io>2025-06-18 17:57:22 +0000
committerMichael Goulet <michael@errs.io>2025-06-25 15:42:11 +0000
commit8cd3fa04e2e023967cf2cfe3e4170b636fd25019 (patch)
tree42fc183b7cee5f294bde109c934bf417619062f0 /tests
parent2801f9aaf9b7580d9b230b532b0700709857cc88 (diff)
downloadrust-8cd3fa04e2e023967cf2cfe3e4170b636fd25019.tar.gz
rust-8cd3fa04e2e023967cf2cfe3e4170b636fd25019.zip
Don't give APITs names with macro expansion placeholder fragments in it
Diffstat (limited to 'tests')
-rw-r--r--tests/crashes/140333.rs9
-rw-r--r--tests/ui/impl-trait/name-mentioning-macro.rs12
-rw-r--r--tests/ui/impl-trait/name-mentioning-macro.stderr16
-rw-r--r--tests/ui/impl-trait/struct-field-fragment-in-name.rs16
4 files changed, 44 insertions, 9 deletions
diff --git a/tests/crashes/140333.rs b/tests/crashes/140333.rs
deleted file mode 100644
index cec1100e6ad..00000000000
--- a/tests/crashes/140333.rs
+++ /dev/null
@@ -1,9 +0,0 @@
-//@ known-bug: #140333
-fn a() -> impl b<
-    [c; {
-        struct d {
-            #[a]
-            bar: e,
-        }
-    }],
->;
diff --git a/tests/ui/impl-trait/name-mentioning-macro.rs b/tests/ui/impl-trait/name-mentioning-macro.rs
new file mode 100644
index 00000000000..8a81911c0bb
--- /dev/null
+++ b/tests/ui/impl-trait/name-mentioning-macro.rs
@@ -0,0 +1,12 @@
+trait Foo<T> {}
+
+macro_rules! bar {
+    () => { () }
+}
+
+fn foo(x: impl Foo<bar!()>) {
+    let () = x;
+    //~^ ERROR mismatched types
+}
+
+fn main() {}
diff --git a/tests/ui/impl-trait/name-mentioning-macro.stderr b/tests/ui/impl-trait/name-mentioning-macro.stderr
new file mode 100644
index 00000000000..adb4c64f812
--- /dev/null
+++ b/tests/ui/impl-trait/name-mentioning-macro.stderr
@@ -0,0 +1,16 @@
+error[E0308]: mismatched types
+  --> $DIR/name-mentioning-macro.rs:8:9
+   |
+LL | fn foo(x: impl Foo<bar!()>) {
+   |           ---------------- expected this type parameter
+LL |     let () = x;
+   |         ^^   - this expression has type `impl Foo<bar!()>`
+   |         |
+   |         expected type parameter `impl Foo<bar!()>`, found `()`
+   |
+   = note: expected type parameter `impl Foo<bar!()>`
+                   found unit type `()`
+
+error: aborting due to 1 previous error
+
+For more information about this error, try `rustc --explain E0308`.
diff --git a/tests/ui/impl-trait/struct-field-fragment-in-name.rs b/tests/ui/impl-trait/struct-field-fragment-in-name.rs
new file mode 100644
index 00000000000..b98cd864ccb
--- /dev/null
+++ b/tests/ui/impl-trait/struct-field-fragment-in-name.rs
@@ -0,0 +1,16 @@
+//@ check-pass
+
+trait Trait<T> {}
+
+fn a(_: impl Trait<
+    [(); {
+        struct D {
+            #[rustfmt::skip]
+            bar: (),
+        }
+        0
+    }],
+>) {
+}
+
+fn main() {}