Open
Description
#![feature(specialization)]
use std::vec;
struct Foo<T>(T);
impl<T> Foo<T> {
fn foo<I: IntoIterator<Item = T>>(it: I) -> Foo<T> {
<Self as SpecExtend<_, _>>::from_iter(it.into_iter())
}
}
trait SpecExtend<T, I> {
fn from_iter(iter: I) -> Self;
}
impl<T, I> SpecExtend<T, I> for Foo<T>
where I: Iterator<Item = T>
{
default fn from_iter(iter: I) -> Self {
panic!()
}
}
impl<T> SpecExtend<T, vec::IntoIter<T>> for Foo<T> {
fn from_iter(iter: vec::IntoIter<T>) -> Self {
panic!()
}
}
fn main() {}
rustc 1.17.0-nightly (134c4a0f0 2017-03-20)
error[E0308]: mismatched types
--> <anon>:8:47
|
8 | <Self as SpecExtend<_, _>>::from_iter(it.into_iter())
| ^^^^^^^^^^^^^^ expected struct `std::vec::IntoIter`, found associated type
|
= note: expected type `std::vec::IntoIter<T>`
found type `<I as std::iter::IntoIterator>::IntoIter`
error: aborting due to previous error