about summary refs log tree commit diff
diff options
context:
space:
mode:
authorlcnr <rust@lcnr.de>2025-09-23 07:55:43 +0200
committerlcnr <rust@lcnr.de>2025-09-23 08:02:54 +0200
commit465e373542b529055cd1302849f79db13a617a98 (patch)
treea64a6adb345442ae94c17890f84d3cf6437f270d
parentf6092f224d2b1774b31033f12d0bee626943b02f (diff)
downloadrust-465e373542b529055cd1302849f79db13a617a98.tar.gz
rust-465e373542b529055cd1302849f79db13a617a98.zip
add regression test
-rw-r--r--tests/ui/methods/overflow-if-subtyping.rs30
1 files changed, 30 insertions, 0 deletions
diff --git a/tests/ui/methods/overflow-if-subtyping.rs b/tests/ui/methods/overflow-if-subtyping.rs
new file mode 100644
index 00000000000..a97f29f1f6d
--- /dev/null
+++ b/tests/ui/methods/overflow-if-subtyping.rs
@@ -0,0 +1,30 @@
+//@ check-pass
+
+// Regression test for #128887.
+#![allow(unconditional_recursion)]
+trait Mappable<T> {
+    type Output;
+}
+
+trait Bound<T> {}
+// Deleting this impl made it compile on beta
+impl<T> Bound<T> for T {}
+
+trait Generic<M> {}
+
+// Deleting the `: Mappable<T>` already made it error on stable.
+struct IndexWithIter<I, M: Mappable<T>, T>(I, M, T);
+
+impl<I, M, T> IndexWithIter<I, M, T>
+where
+    <M as Mappable<T>>::Output: Bound<T>,
+    // Flipping these where bounds causes this to succeed, even when removing
+    // the where-clause on the struct definition.
+    M: Mappable<T>,
+    I: Generic<M>,
+{
+    fn new(x: I) {
+        IndexWithIter::<_, _, _>::new(x);
+    }
+}
+fn main() {}