about summary refs log tree commit diff
path: root/tests/ui/chalkify/projection.rs
diff options
context:
space:
mode:
Diffstat (limited to 'tests/ui/chalkify/projection.rs')
-rw-r--r--tests/ui/chalkify/projection.rs25
1 files changed, 25 insertions, 0 deletions
diff --git a/tests/ui/chalkify/projection.rs b/tests/ui/chalkify/projection.rs
new file mode 100644
index 00000000000..19bb2ae1497
--- /dev/null
+++ b/tests/ui/chalkify/projection.rs
@@ -0,0 +1,25 @@
+// run-pass
+// compile-flags: -Z trait-solver=chalk
+
+trait Foo { }
+
+trait Bar {
+    type Item: Foo;
+}
+
+impl Foo for i32 { }
+impl Bar for i32 {
+    type Item = i32;
+}
+
+fn only_foo<T: Foo>() { }
+
+fn only_bar<T: Bar>() {
+    // `T` implements `Bar` hence `<T as Bar>::Item` must also implement `Bar`
+    only_foo::<T::Item>()
+}
+
+fn main() {
+    only_bar::<i32>();
+    only_foo::<<i32 as Bar>::Item>();
+}