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
#![feature(specialization)]use std::marker::PhantomData;traitTrait{typeA;typeB;fnfoo(&self,a:Self::A,b:Self::B);}structFoo<A,B>{a:PhantomData<A>,b:PhantomData<B>,}impl<A,B>Foo<A,B>{fnnew() -> Self{Foo{a:PhantomData,b:PhantomData,}}}impl<A,B>TraitforFoo<A,B>{typeA = A;typeB = B;defaultfnfoo(&self, _:A, _:B){println!("default impl");}}// Specializedimpl<A,B:Eq>TraitforFoo<A,B>{fnfoo(&self, _:A, _:B){println!("specialized");}}fnmain(){let a = "a";let b = "b";let f = Foo::new();// Need to specify concrete type here to compile
f.foo(a, b);}
Expected Result
Program should compile and print out "specialized"
Actual Result
rustc 1.15.0-nightly (2217bd771 2016-11-25)
error[E0282]: unable to infer enough type information about `_`
--> <anon>:44:13
|
44 | let f = Foo::new(); // Need to specify concrete type here to compile
| ^^^^^^^^ cannot infer type for `_`
|
= note: type annotations or generic parameter binding required
error: aborting due to previous error
What I thought was interesting here was that the program compiles without the specialization impl (line 34), and when it is added, there is a type inference error.
Expected Result
Program should compile and print out "specialized"
Actual Result
May be related to #36262
The text was updated successfully, but these errors were encountered: