3 #![allow(unused_imports)]
4 // Test how resolving a projection interacts with inference. In this
5 // case, we were eagerly unifying the type variable for the iterator
6 // type with `I` from the where clause, ignoring the in-scope `impl`
7 // for `ByRef`. The right answer was to consider the result ambiguous
8 // until more type information was available.
10 #![feature(lang_items)]
11 #![no_implicit_prelude]
13 use std::marker::Sized;
14 use std::option::Option::{None, Some, self};
19 fn next(&mut self) -> Option<Self::Item>;
22 trait IteratorExt: Iterator + Sized {
23 fn by_ref(&mut self) -> ByRef<Self> {
28 impl<I> IteratorExt for I where I: Iterator {}
30 struct ByRef<'a, I: 'a + Iterator>(&'a mut I);
32 impl<'a, A, I> Iterator for ByRef<'a, I> where I: Iterator<Item=A> {
35 fn next(&mut self) -> Option< <I as Iterator>::Item > {
40 fn is_iterator_of<A, I: Iterator<Item=A>>(_: &I) {}
42 fn test<A, I: Iterator<Item=A>>(mut it: I) {
43 is_iterator_of::<A, _>(&it.by_ref());