about summary refs log tree commit diff
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/crashes/132826.rs10
-rw-r--r--tests/ui/coherence/orphan-check-error-reporting-ty-var.rs17
-rw-r--r--tests/ui/coherence/orphan-check-error-reporting-ty-var.stderr16
3 files changed, 33 insertions, 10 deletions
diff --git a/tests/crashes/132826.rs b/tests/crashes/132826.rs
deleted file mode 100644
index 9889cecdac5..00000000000
--- a/tests/crashes/132826.rs
+++ /dev/null
@@ -1,10 +0,0 @@
-//@ known-bug: #132826
-pub trait MyTrait {
-    type Item;
-}
-
-impl<K> MyTrait for Vec<K> {
-    type Item = Vec<K>;
-}
-
-impl<K> From<Vec<K>> for <Vec<K> as MyTrait>::Item {}
diff --git a/tests/ui/coherence/orphan-check-error-reporting-ty-var.rs b/tests/ui/coherence/orphan-check-error-reporting-ty-var.rs
new file mode 100644
index 00000000000..99a83453354
--- /dev/null
+++ b/tests/ui/coherence/orphan-check-error-reporting-ty-var.rs
@@ -0,0 +1,17 @@
+// Regression test for #132826.
+
+// Make sure we don't try to resolve the variable `K1` in the generics of the impl
+// (which only has `K2`).
+
+pub trait MyTrait {
+    type Item;
+}
+
+impl<K1> MyTrait for Vec<K1> {
+    type Item = Vec<K1>;
+}
+
+impl<K2> From<Vec<K2>> for <Vec<K2> as MyTrait>::Item {}
+//~^ ERROR only traits defined in the current crate can be implemented for arbitrary types
+
+fn main() {}
diff --git a/tests/ui/coherence/orphan-check-error-reporting-ty-var.stderr b/tests/ui/coherence/orphan-check-error-reporting-ty-var.stderr
new file mode 100644
index 00000000000..f229f8b2e38
--- /dev/null
+++ b/tests/ui/coherence/orphan-check-error-reporting-ty-var.stderr
@@ -0,0 +1,16 @@
+error[E0117]: only traits defined in the current crate can be implemented for arbitrary types
+  --> $DIR/orphan-check-error-reporting-ty-var.rs:14:1
+   |
+LL | impl<K2> From<Vec<K2>> for <Vec<K2> as MyTrait>::Item {}
+   | ^^^^^^^^^-------------^^^^^--------------------------
+   |          |                 |
+   |          |                 `Vec` is not defined in the current crate
+   |          `Vec` is not defined in the current crate
+   |
+   = note: impl doesn't have any local type before any uncovered type parameters
+   = note: for more information see https://doc.rust-lang.org/reference/items/implementations.html#orphan-rules
+   = note: define and implement a trait or new type instead
+
+error: aborting due to 1 previous error
+
+For more information about this error, try `rustc --explain E0117`.