diff options
Diffstat (limited to '')
-rw-r--r-- | src/test/ui/traits/assoc-type-in-supertrait.rs | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/src/test/ui/traits/assoc-type-in-supertrait.rs b/src/test/ui/traits/assoc-type-in-supertrait.rs new file mode 100644 index 000000000..7d6a754cc --- /dev/null +++ b/src/test/ui/traits/assoc-type-in-supertrait.rs @@ -0,0 +1,23 @@ +// run-pass +// Test case where an associated type is referenced from within the +// supertrait definition. Issue #20220. + + +use std::vec::IntoIter; + +pub trait Foo: Iterator<Item=<Self as Foo>::Key> { + type Key; +} + +impl Foo for IntoIter<i32> { + type Key = i32; +} + +fn sum_foo<F:Foo<Key=i32>>(f: F) -> i32 { + f.fold(0, |a,b| a + b) +} + +fn main() { + let x = sum_foo(vec![11, 10, 1].into_iter()); + assert_eq!(x, 22); +} |