about summary refs log tree commit diff
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/ui/traits/next-solver/cycles/rayon-hang-1.rs32
-rw-r--r--tests/ui/traits/next-solver/cycles/rayon-hang-2.rs49
2 files changed, 81 insertions, 0 deletions
diff --git a/tests/ui/traits/next-solver/cycles/rayon-hang-1.rs b/tests/ui/traits/next-solver/cycles/rayon-hang-1.rs
new file mode 100644
index 00000000000..61e1f1b200f
--- /dev/null
+++ b/tests/ui/traits/next-solver/cycles/rayon-hang-1.rs
@@ -0,0 +1,32 @@
+//@ compile-flags: -Znext-solver
+//@ check-pass
+
+// A regression test for trait-system-refactor-initiative#109.
+
+trait ParallelIterator: Sized {
+    type Item;
+}
+trait IntoParallelIterator {
+    type Iter: ParallelIterator<Item = Self::Item>;
+    type Item;
+}
+impl<T: ParallelIterator> IntoParallelIterator for T {
+    type Iter = T;
+    type Item = T::Item;
+}
+
+macro_rules! multizip_impls {
+    ($($T:ident),+) => {
+       fn foo<$( $T, )+>() where
+        $(
+            $T: IntoParallelIterator,
+            $T::Iter: ParallelIterator,
+        )+
+            ($( $T, )+): IntoParallelIterator<Item = ($( $T::Item, )+)>,
+        {}
+    }
+}
+
+multizip_impls! { A, B, C, D, E, F, G, H, I, J, K, L }
+
+fn main() {}
diff --git a/tests/ui/traits/next-solver/cycles/rayon-hang-2.rs b/tests/ui/traits/next-solver/cycles/rayon-hang-2.rs
new file mode 100644
index 00000000000..bb5d8335dd6
--- /dev/null
+++ b/tests/ui/traits/next-solver/cycles/rayon-hang-2.rs
@@ -0,0 +1,49 @@
+//@ compile-flags: -Znext-solver
+//@ check-pass
+
+// A regression test for trait-system-refactor-initiative#109.
+// Unlike `rayon-hang-1.rs` the cycles in this test are not
+// unproductive, which causes the `AliasRelate` goal when trying
+// to apply where-clauses to only error in the second iteration.
+//
+// This makes the exponential blowup to be significantly harder
+// to avoid.
+
+trait ParallelIterator: Sized {
+    type Item;
+}
+
+trait IntoParallelIteratorIndir {
+    type Iter: ParallelIterator<Item = Self::Item>;
+    type Item;
+}
+impl<I> IntoParallelIteratorIndir for I
+where
+    Box<I>: IntoParallelIterator,
+{
+    type Iter = <Box<I> as IntoParallelIterator>::Iter;
+    type Item = <Box<I> as IntoParallelIterator>::Item;
+}
+trait IntoParallelIterator {
+    type Iter: ParallelIterator<Item = Self::Item>;
+    type Item;
+}
+impl<T: ParallelIterator> IntoParallelIterator for T {
+    type Iter = T;
+    type Item = T::Item;
+}
+
+macro_rules! multizip_impls {
+    ($($T:ident),+) => {
+       fn foo<'a, $( $T, )+>() where
+        $(
+            $T: IntoParallelIteratorIndir,
+            $T::Iter: ParallelIterator,
+        )+
+        {}
+    }
+}
+
+multizip_impls! { A, B, C, D, E, F, G, H, I, J, K, L }
+
+fn main() {}