Join GitHub today
GitHub is home to over 31 million developers working together to host and review code, manage projects, and build software together.
Sign upICE: Explicit deref of non-derefable type: _ #20108
Comments
This comment has been minimized.
This comment has been minimized.
|
Following works: use std::iter::Iterator;
fn map<T, U, I: Iterator<T>>(fun: |T| -> U, mut iter: I) -> Vec<U> {
let mut acc = vec![];
for elt in iter {
acc.push(fun(elt));
}
acc
}
fn main() {
let x = map(|x| *x + 2, vec![1u,2,3].iter());
println!("{}", x);
} |
flaper87
added
the
I-ICE
label
Dec 21, 2014
flaper87
changed the title
Another internal compiler error: Explicit deref of non-derefable type: _
ICE: Explicit deref of non-derefable type: _
Dec 21, 2014
This comment has been minimized.
This comment has been minimized.
|
This doesn't compile today - can you refresh this to modern syntax? |
This comment has been minimized.
This comment has been minimized.
|
I've tried to update the code using the compiler errors as a guide and I ended up with this: use std::iter::Iterator;
fn map<T, U, I: Iterator<Item = T>>(fun: &(Fn(&T) -> U), mut iter: I) -> Vec<U> {
let mut acc = vec![];
for elt in iter {
acc.push(fun(&elt));
}
acc
}
fn main() {
let x = map(&|&x| x + 2, vec![1u32,2,3].iter());
println!("{:?}", x);
}It did not trigger ICE, but I'm not sure if it has the same semantics with the boxed closure. |
alexcrichton
added
the
E-needstest
label
Oct 24, 2015
This comment has been minimized.
This comment has been minimized.
|
Given the above comments, I'm giving this one a close. If anyone is still seeing this ICE somehow, please open a new bug. Thanks! |
steveklabnik
closed this
Mar 23, 2017
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
oderwat commentedDec 21, 2014
Following Code "suddenly" (TM) gives a compiler panick:
(probably a duplicate but the other code did not look similar to the one here in my eyes)