about summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--tests/ui/traits/solver-cycles/129541-recursive-enum-and-array-impl.rs22
-rw-r--r--tests/ui/traits/solver-cycles/129541-recursive-enum-and-array-impl.stderr10
-rw-r--r--tests/ui/traits/solver-cycles/129541-recursive-struct-and-array-impl.rs23
-rw-r--r--tests/ui/traits/solver-cycles/129541-recursive-struct.rs19
4 files changed, 74 insertions, 0 deletions
diff --git a/tests/ui/traits/solver-cycles/129541-recursive-enum-and-array-impl.rs b/tests/ui/traits/solver-cycles/129541-recursive-enum-and-array-impl.rs
new file mode 100644
index 00000000000..197207dfb4b
--- /dev/null
+++ b/tests/ui/traits/solver-cycles/129541-recursive-enum-and-array-impl.rs
@@ -0,0 +1,22 @@
+// Regression test for #129541
+//~^ ERROR cycle detected when computing layout of `<[Hello] as Normalize>::Assoc` [E0391]
+
+trait Bound {}
+trait Normalize {
+    type Assoc;
+}
+
+impl<T: Bound> Normalize for T {
+    type Assoc = T;
+}
+
+impl<T: Bound> Normalize for [T] {
+    type Assoc = T;
+}
+
+impl Bound for Hello {}
+enum Hello {
+    Variant(<[Hello] as Normalize>::Assoc),
+}
+
+fn main() {}
diff --git a/tests/ui/traits/solver-cycles/129541-recursive-enum-and-array-impl.stderr b/tests/ui/traits/solver-cycles/129541-recursive-enum-and-array-impl.stderr
new file mode 100644
index 00000000000..50dcea0bfac
--- /dev/null
+++ b/tests/ui/traits/solver-cycles/129541-recursive-enum-and-array-impl.stderr
@@ -0,0 +1,10 @@
+error[E0391]: cycle detected when computing layout of `<[Hello] as Normalize>::Assoc`
+   |
+   = note: ...which requires computing layout of `Hello`...
+   = note: ...which again requires computing layout of `<[Hello] as Normalize>::Assoc`, completing the cycle
+   = note: cycle used when computing layout of `Hello`
+   = note: see https://rustc-dev-guide.rust-lang.org/overview.html#queries and https://rustc-dev-guide.rust-lang.org/query.html for more information
+
+error: aborting due to 1 previous error
+
+For more information about this error, try `rustc --explain E0391`.
diff --git a/tests/ui/traits/solver-cycles/129541-recursive-struct-and-array-impl.rs b/tests/ui/traits/solver-cycles/129541-recursive-struct-and-array-impl.rs
new file mode 100644
index 00000000000..defb39aae06
--- /dev/null
+++ b/tests/ui/traits/solver-cycles/129541-recursive-struct-and-array-impl.rs
@@ -0,0 +1,23 @@
+// Regression test for #129541
+
+//@ check-pass
+
+trait Bound {}
+trait Normalize {
+    type Assoc;
+}
+
+impl<T: Bound> Normalize for T {
+    type Assoc = T;
+}
+
+impl<T: Bound> Normalize for [T] {
+    type Assoc = T;
+}
+
+impl Bound for Hello {}
+struct Hello {
+    a: <[Hello] as Normalize>::Assoc,
+}
+
+fn main() {}
diff --git a/tests/ui/traits/solver-cycles/129541-recursive-struct.rs b/tests/ui/traits/solver-cycles/129541-recursive-struct.rs
new file mode 100644
index 00000000000..d4339dd54d6
--- /dev/null
+++ b/tests/ui/traits/solver-cycles/129541-recursive-struct.rs
@@ -0,0 +1,19 @@
+// Regression test for #129541
+
+//@ check-pass
+
+trait Bound {}
+trait Normalize {
+    type Assoc;
+}
+
+impl<T: Bound> Normalize for [T] {
+    type Assoc = T;
+}
+
+impl Bound for Hello {}
+struct Hello {
+    a: <[Hello] as Normalize>::Assoc,
+}
+
+fn main() {}