-
Notifications
You must be signed in to change notification settings - Fork 12.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
ICE OutputTypeParameterMismatch
#29997
Comments
Minified: trait Mirror { type Image; }
impl<T> Mirror for T { type Image = T; }
fn test<L,T>(l: L) where L: FnOnce(Option<<&T as Mirror>::Image>),
for<'a> &'a T: Mirror
{ l(None); }
fn main() {
test::<_,u8>(|_| {});
} @nikomatsakis @eddyb : why is |
ok, finally getting to some of my older notifications, sorry. An interesting question. Digging through the codebase, I see that there is only one call -- Let me look into your minified example a bit. |
I guess we should just erase regions in that case too. |
The The root cause of the problem here is that typeck/trans assume that if |
I've hit this I think. Other issues with visually similar error messages which I assume are related: #33364 (comment), #39779. |
Reposting #39779 here for future reference: This seems to cause rustc to crash (link shows a slightly more complicated example than the reduced example below): trait Fun<'a> { type Output; }
impl<'a> Fun<'a> for () { type Output = &'a str; }
fn with<F, G>(x: <F as Fun<'static>>::Output, g: G)
where F: for<'a> Fun<'a>,
G: for<'a> FnOnce(<F as Fun<'a>>::Output) {
g(x)
}
fn main() {
with::<(), _>("", |_| ());
} It looks like it forgot to normalize
Crash log for 1.15.0-stable (10893a9 2017-01-19)
Crash log for 1.17.0-nightly (c49d102 2017-02-07)
|
While working on a StreamingIterator trait, I got a similar ICE about an OutputTypeParameterMismatch. pub trait StreamingIterator<'a> {
type Item: 'a;
fn next(&'a mut self) -> Option<Self::Item>;
}
pub trait StreamingIteratorExt: for<'a> StreamingIterator<'a> {
fn for_each<F>(mut self, mut func: F) where
Self: Sized,
F: for<'a> FnMut(<Self as StreamingIterator<'a>>::Item)
{
while let Some(item) = self.next() {
func(item)
}
}
}
impl<I> StreamingIteratorExt for I where
I: for<'a>StreamingIterator<'a>
{}
impl<'a, I: Iterator + 'a> StreamingIterator<'a> for I {
type Item = I::Item;
fn next(&'a mut self) -> Option<Self::Item> {
self.next()
}
}
#[test]
fn test_basic_stuff() {
let it = vec![1i32,2,3].into_iter();
StreamingIteratorExt::for_each(it, |x| println!("{}", x));
} And here's the error on Rust 1.21.0 stable
Backtrace on Rust 1.21.0 stable
Note that |
Another minimal example (#53420): trait Lt<'a> {
type T;
}
impl<'a> Lt<'a> for () {
type T = ();
}
fn main() {
let _:fn(<() as Lt<'_>>::T) = |()| {};
} |
Is #33364 a duplicate of this? |
closing as duplicate of #62529, which is where I will try to track future instances of this field of ICE. |
The error is very long, and the example is not reduced (I tried, but the simple reduction worked ok, so no dice there). To reproduce, one can pull
frankmcsherry/differential-dataflow@2fa719e
and then
cargo build --example cc
. I'm onThe same project ICEs on stable as well, but for a different reason (issue #29991; EDIT: Sorry, not actually this issue; rather, a different ICE that seems fixed in nightly).
I think the salient points are in the complaint
where it seems to be unhappy that it found a weird associated type rather than a
DifferenceIterator<u32>
. Of course, the associated type is thatDifferenceIterator<u32>
, which Rust knew at one point but seems to have lost track of, maybe? There is admittedly a bunch of horribleness going on with associated types, specifically faking out HKT for lifetimes through associated types of traits containing a lifetime implemented for references with that lifetime to the type in question. I can explain what it is doing if that helps, but given that it just ICEs differently in each release mode, maybe it's just time to delete it and try another way.Full backtrace:
The text was updated successfully, but these errors were encountered: