summaryrefslogtreecommitdiffstats
path: root/src/test/ui/associated-types/associated-types-multiple-types-one-trait.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/test/ui/associated-types/associated-types-multiple-types-one-trait.rs')
-rw-r--r--src/test/ui/associated-types/associated-types-multiple-types-one-trait.rs46
1 files changed, 46 insertions, 0 deletions
diff --git a/src/test/ui/associated-types/associated-types-multiple-types-one-trait.rs b/src/test/ui/associated-types/associated-types-multiple-types-one-trait.rs
new file mode 100644
index 000000000..daeaf9011
--- /dev/null
+++ b/src/test/ui/associated-types/associated-types-multiple-types-one-trait.rs
@@ -0,0 +1,46 @@
+trait Foo {
+ type X;
+ type Y;
+}
+
+fn have_x_want_x<T:Foo<X=u32>>(t: &T)
+{
+ want_x(t);
+}
+
+fn have_x_want_y<T:Foo<X=u32>>(t: &T)
+{
+ want_y(t); //~ ERROR type mismatch
+}
+
+fn have_y_want_x<T:Foo<Y=i32>>(t: &T)
+{
+ want_x(t); //~ ERROR type mismatch
+}
+
+fn have_y_want_y<T:Foo<Y=i32>>(t: &T)
+{
+ want_y(t);
+}
+
+fn have_xy_want_x<T:Foo<X=u32,Y=i32>>(t: &T)
+{
+ want_x(t);
+}
+
+fn have_xy_want_y<T:Foo<X=u32,Y=i32>>(t: &T)
+{
+ want_y(t);
+}
+
+fn have_xy_want_xy<T:Foo<X=u32,Y=i32>>(t: &T)
+{
+ want_x(t);
+ want_y(t);
+}
+
+fn want_x<T:Foo<X=u32>>(t: &T) { }
+
+fn want_y<T:Foo<Y=i32>>(t: &T) { }
+
+fn main() { }