4 #![allow(unused_imports)]
5 // Test how resolving a projection interacts with inference. In this
6 // case, we were eagerly unifying the type variable for the iterator
7 // type with `I` from the where clause, ignoring the in-scope `impl`
8 // for `ByRef`. The right answer was to consider the result ambiguous
9 // until more type information was available.
11 #![feature(lang_items)]
12 #![no_implicit_prelude]
14 use std::marker::Sized;
15 use std::option::Option::{None, Some, self};
20 fn next(&mut self) -> Option<Self::Item>;
23 trait IteratorExt: Iterator + Sized {
24 fn by_ref(&mut self) -> ByRef<Self> {
29 impl<I> IteratorExt for I where I: Iterator {}
31 struct ByRef<'a, I: 'a + Iterator>(&'a mut I);
33 impl<'a, I: Iterator> Iterator for ByRef<'a, I> {
36 fn next(&mut self) -> Option< <I as Iterator>::Item > {
41 fn is_iterator_of<A, I: Iterator<Item=A>>(_: &I) {}
43 fn test<A, I: Iterator<Item=A>>(mut it: I) {
44 is_iterator_of::<A, _>(&it.by_ref());
47 fn test2<A, I1: Iterator<Item=A>, I2: Iterator<Item=I1::Item>>(mut it: I2) {
48 is_iterator_of::<A, _>(&it)