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 think that this is something @nikomatsakis is planning on fixing. Currently, coherence ignores type arguments to generic traits when determining whether there are multiple implementations of a trait for the same type.
I ran into this too (layering traits on eachother): here was my case:-
// CONFLICTING TRAIT TEST
// compiles ok until adding (iii) .. desired behaviour would be for this to compile
trait A { }// VertexGrid interface (heightfield, bezier patch..
trait B { }// trimesh interface
struct P<T> { // heightfield
i:int}
struct Q<T> { // concrete trimesh of ... (may be more ways of storing)
i:int}
// (i) heightfield has VertexGrid behaviours
impl<T> A for P<T> { }
// (ii) VertexGrid can be viewed as a mesh
impl<X:A> B for X { }
// (iii)concrete trimesh has trimesh interface
impl<T> B for Q<T> { }
//^^^^ error: 25:1 conflicting implementations for a trait
// (iii) conflicting here (ii)
// ideally i'd hope the error/ambiguity would come *if* i implemeneted B for Q
fn main() { }
Note that we probably are going to make some changes, at the very least to ease the use case of operator overloading. We currently use (only) the Self type for method resolution, but I think everyone would like to see us adopt something more flexible here, if possible.
In particular I am referring to the discussion of trait method resolution from the winter 2014 workweek, where we discussed putting in something like functional dependencies in order to allow the types of "inputs" to an operator to participate in the trait method resolution process.
(Of course the details here still need to be ironed out; it will happen via the RFC process. I just wanted to make an explicit note here since I saw some recent chatter about how to accomplish things like #7935.)
@japaric probably should have been closed long ago as "working as intended", but I guess we've expanded the design now such that this use case is actually supposed to work...funny.
Activity
catamorphism commentedon Jul 4, 2013
I think that this is something @nikomatsakis is planning on fixing. Currently, coherence ignores type arguments to generic traits when determining whether there are multiple implementations of a trait for the same type.
jmgrosen commentedon Jul 4, 2013
Great, I'll make sure to watch for that commit.
dobkeratops commentedon Jul 12, 2013
I ran into this too (layering traits on eachother): here was my case:-
thestinger commentedon Sep 9, 2013
This is still an issue.
k4nar commentedon Feb 14, 2014
I think I encountered this issue too :
It was with 0.9, but someone on IRC said he had the same issue on master.
nikomatsakis commentedon Feb 14, 2014
It's unclear whether any of these things should be possible. cc #5527
pnkfelix commentedon Mar 27, 2014
Note that we probably are going to make some changes, at the very least to ease the use case of operator overloading. We currently use (only) the
Selftype for method resolution, but I think everyone would like to see us adopt something more flexible here, if possible.In particular I am referring to the discussion of trait method resolution from the winter 2014 workweek, where we discussed putting in something like functional dependencies in order to allow the types of "inputs" to an operator to participate in the trait method resolution process.
(Of course the details here still need to be ironed out; it will happen via the RFC process. I just wanted to make an explicit note here since I saw some recent chatter about how to accomplish things like #7935.)
japaric commentedon Oct 13, 2014
A updated version of the OP's code compiles today because of the recent multidispatch PR (#17669)
(Although, we are likely to convert the
Resultparameter of theIndextrait into an associated output type in the future)@nikomatsakis Should this be closed as fixed?
alexcrichton commentedon Oct 13, 2014
Thanks @japaric!
nikomatsakis commentedon Oct 14, 2014
@japaric probably should have been closed long ago as "working as intended", but I guess we've expanded the design now such that this use case is actually supposed to work...funny.
k4nar commentedon Oct 14, 2014
Thanks very much for your awesome work !
0.1.2: no more `num` dependency, multidispatched addition.