Closed
Description
While playing around with #36791, I encountered an ICE when attempting to compile the following code with nightly on the playground:
#![feature(specialization)]
pub struct Cloned<I> {
it: I,
}
impl<'a, I, T: 'a> Iterator for Cloned<I>
where I: Iterator<Item=&'a T>, T: Clone
{
type Item = T;
fn next(&mut self) -> Option<T> {
self.it.next().cloned()
}
fn size_hint(&self) -> (usize, Option<usize>) {
self.it.size_hint()
}
}
impl<'a, I, T: 'a> Iterator for Cloned<I>
where I: Iterator<Item=&'a T>, T: Copy
{
fn nth(&mut self, n: usize) -> Option<T> {
self.it.nth(n).cloned()
}
fn last(self) -> Option<T> {
self.it.last().cloned()
}
fn count(self) -> usize {
self.it.count()
}
}
fn main() {
let mut called = 0;
let a = [1, 2, 3, 4];
Cloned { it: a.iter().map(|x| {
called += 1;
x
}) }.count();
println!("{}", called);
}
Compiler output:
rustc 1.13.0-nightly (d0623cf7b 2016-09-26)
error: internal compiler error: ../src/librustc/traits/specialize/mod.rs:97: When translating substitutions for specialization, the expected specializaiton failed to hold
Metadata
Metadata
Assignees
Labels
Area: Trait impl specializationCategory: This is a bug.Call for participation: An issue has been fixed and does not reproduce, but no test has been added.Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️Relevant to the compiler team, which will review and decide on the PR/issue.