You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have seen many OutputTypeParameterMismatch ICEs filed, so I decided to try to make a single representative issue for all of them.
Its possible that not all of these share the same root cause. But until I see a more fine grain way to categorize them, I'm going to at least try to track them in a single place.
Below are transcribed minimized versions of each of the original issues, labelled accordingly, so that we remember to double check each of their behavior before closing this issue as fixed in the future.
// FamilyType (GAT workaround)pubtraitFamilyLt<'a>{typeOut;}structRefMutFamily<T>(std::marker::PhantomData<T>,());impl<'a,T:'a>FamilyLt<'a>forRefMutFamily<T>{typeOut = &'amutT;}pubtraitExecute{typeE:Inject;fnexecute(self,value: <<Self::EasInject>::IasFamilyLt>::Out);}pubtraitInjectwhereSelf:Sized,{typeI:for<'a>FamilyLt<'a>;fninject(_:&()) -> <Self::IasFamilyLt>::Out;}impl<T:'static>InjectforRefMutFamily<T>{typeI = Self;fninject(_:&()) -> <Self::IasFamilyLt>::Out{unimplemented!()}}// This struct is only used to give a hint to the compiler about the type `Q`structAnnotate<Q>(std::marker::PhantomData<Q>);impl<Q>Annotate<Q>{fnnew() -> Self{Self(std::marker::PhantomData)}}// This function annotate a closure so it can have Higher-Rank Lifetime Bounds//// See 'annotate' workaround: https://github.com/rust-lang/rust/issues/58052fnannotate<F,Q>(_q:Annotate<Q>,func:F) -> implExecute + 'staticwhereF:for<'r>FnOnce(<<QasInject>::IasFamilyLt<'r>>::Out) + 'static,Q:Inject + 'static,{let wrapper:Wrapper<Q,F> = Wrapper(std::marker::PhantomData, func);
wrapper
}structWrapper<Q,F>(std::marker::PhantomData<Q>,F);impl<Q,F>ExecuteforWrapper<Q,F>whereQ:Inject,F:for<'r>FnOnce(<<QasInject>::IasFamilyLt<'r>>::Out),{typeE = Q;fnexecute(self,value: <<Self::EasInject>::IasFamilyLt>::Out){(self.1)(value)}}structTask{_processor:Box<dynFnOnce()>,}// This function consume the closurefntask<P>(processor:P) -> TaskwhereP:Execute + 'static{Task{_processor:Box::new(move || {let q = P::E::inject(&());
processor.execute(q);})}}fnmain(){task(annotate(Annotate::<RefMutFamily<usize>>::new(),
|value:&mutusize| {*value = 2;}));}
traitATC<'a>{typeType:Sized;}traitWithDefault:for<'a>ATC<'a>{fnwith_default<F:for<'a>Fn(<SelfasATC<'a>>::Type)>(f:F);}fncall<'b,T:for<'a>ATC<'a>,F:for<'a>Fn(<TasATC<'a>>::Type)>(f:F,x: <TasATC<'b>>::Type,){f(x);}impl<'a>ATC<'a>for(){typeType = Self;}implWithDefaultfor(){fnwith_default<F:for<'a>Fn(<SelfasATC<'a>>::Type)>(f:F){// Errors with a bogus type mismatch.//f(());// Going through another generic function works fine.call(f,());}}fnmain(){// <()>::with_default(|_| {});}
This one (and ICE OutputTypeParameterMismatch #29997) are potentially different/interesting because it has the for<'a> ... on the left-hand side of a constraint, where for<'a> &'a D: Tr; most of the other examples have it on the right-hand side
use std::marker::PhantomData;traitFoo<'a>{typeItem;fnconsume<F>(self,f:F)whereF:Fn(Self::Item);}structConsume<A>(PhantomData<A>);impl<'a,A:'a>Foo<'a>forConsume<A>{typeItem = &'aA;fnconsume<F>(self,_f:F)whereF:Fn(Self::Item){ifblackbox(){_f(any());// Gotta keep this (1.)}}}#[derive(Clone)]structWrap<T>{foo:T}impl<T:for<'a>Foo<'a>>Wrap<T>{fnconsume<F>(self,f:F)whereF:for<'b>Fn(<TasFoo<'b>>::Item){self.foo.consume(f);}}fnmain(){// This worksConsume(PhantomData::<u32>).consume(|item| {let _a = item;});// This does not (but is only noticed if you call the closure).let _wrap = Wrap{foo:Consume(PhantomData::<u32>,)};
_wrap.consume(|item| {let _a = item;});// Gotta keep this (2.)}pubstaticmutFLAG:bool = false;fnblackbox() -> bool{unsafe{FLAG}}fnany<T>() -> T{loop{}}
This one (and ICE on all current Rust channels #42950) are potentially different/interesting because it has the for<'a> ... on the left-hand side of a constraint, where for<'a> &'a D: Tr; most of the other examples have it on the right-hand side
I have seen many
OutputTypeParameterMismatchICEs filed, so I decided to try to make a single representative issue for all of them.Below are transcribed minimized versions of each of the original issues, labelled accordingly, so that we remember to double check each of their behavior before closing this issue as fixed in the future.
#60070 (play):
Click to expand the code for minimized example
#57485 (play):
Click to expand the code for minimized example
#53420 (play):
Click to expand the code for minimized example
#52812 (play):
Click to expand the code for minimized example
#50886 (play):
Click to expand the code for minimized example
#48112 (play):
Click to expand the code for minimized example
#42950 (play):
Click to expand the code for minimized example
OutputTypeParameterMismatch#29997) are potentially different/interesting because it has the for<'a> ... on the left-hand side of a constraint, where for<'a> &'a D: Tr; most of the other examples have it on the right-hand side#33364 (play):
Click to expand the code for minimized example
#30860 (comment) (play):
Click to expand the code for minimized example
#29997 (play):
Click to expand the code for minimized #29997
#68578 (play):
Click to expand the code for minimized example
#70120
(needs its minimized example to be transcribed...)
#70243