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
You can create an inherent impl where the impl substs are not constrained by the impl signature. If the parameters are constrained by the method signature, you can even get code that usefully runs (otherwise you get "can't resolve" errors):
structS<T>(T);traitTr{typeAssoc;fntest();}implTrforu32{typeAssoc = u32;fntest(){println!("test for u32!");}}implTrforu64{typeAssoc = u32;fntest(){println!("test for u64!");}}impl<T:Tr>S<T::Assoc>{fnfoo(self, _:T){T::test();}}fnmain(){
<S<u32>>::foo(S(4u32),4u32);}
Note that you need to use UFCS notation to avoid #25679 (which is an issue with method lookup).
RFC447 is silent with regards to this issue, but this allows you to create an impl that is not resolvable by its trait-ref.
The text was updated successfully, but these errors were encountered:
Heh, I was just telling @aturon in IRC the other day that this case was broken. I agree, the current logic is too simplistic (it's also something I've been writing up in this RFC I keep talking about...). Basically, it currently considers all input/type parameters which appear as constrianed, but it ought to stop at projections. I made this gist, which is a similar example: https://gist.github.com/0c562768aeb9412269ce
To be clear, I don't think that fixing this issue requires an RFC (it's just a bug, I think). I just meant that I was writing up various text that referenced the notion of "constrained type parameters" and tried to give a definition, which is how I realized this problem.
arielb1
added a commit
to arielb1/rust
that referenced
this issue
Jun 13, 2015
You can create an inherent impl where the impl substs are not constrained by the impl signature. If the parameters are constrained by the method signature, you can even get code that usefully runs (otherwise you get "can't resolve" errors):
Note that you need to use UFCS notation to avoid #25679 (which is an issue with method lookup).
RFC447 is silent with regards to this issue, but this allows you to create an impl that is not resolvable by its trait-ref.
The text was updated successfully, but these errors were encountered: