Unnamed repository; edit this file 'description' to name the repository.
Diffstat (limited to 'crates/hir-ty/src/tests/traits.rs')
-rw-r--r--crates/hir-ty/src/tests/traits.rs32
1 files changed, 32 insertions, 0 deletions
diff --git a/crates/hir-ty/src/tests/traits.rs b/crates/hir-ty/src/tests/traits.rs
index 97ae732a90..764e77950f 100644
--- a/crates/hir-ty/src/tests/traits.rs
+++ b/crates/hir-ty/src/tests/traits.rs
@@ -4410,3 +4410,35 @@ fn test(v: S<i32>) {
"#,
);
}
+
+#[test]
+fn rustc_coinductive() {
+ // Taken from rust-lang/rust#108033 with modification.
+ check_types(
+ r#"
+#[rustc_coinductive]
+trait Trait { type Assoc; }
+
+impl<T, U> Trait for (T, U)
+where
+ (U, T): Trait,
+ (): ConstrainToU32<T>,
+{
+ type Assoc = i32;
+}
+
+trait ConstrainToU32<T> {}
+impl ConstrainToU32<u32> for () {}
+
+fn impls_trait<T, U, R>() -> R
+where
+ (T, U): Trait<Assoc = R>,
+{ loop {} }
+
+fn main() {
+ let _ = impls_trait::<_, _, _>();
+ //^ i32
+}
+"#,
+ );
+}