Probably the biggest way that self is getting special cased here is that it won't try to deref self but it will try to deref other arguments (why is `PartialEq<Inner> for Outer` fine there but not `PartialEq<Outer> for Inner`?)
-
-
Replying to @sgrif
but your example is already asymmetric, it's breaking because `y` is MyRc, not because it's not self. It fails if you swap y with x, it has nothing to do with the receiver being special cased
1 reply 0 retweets 0 likes -
Replying to @ManishEarth @sgrif
What's happening is that for x it's managing to find a single impl that doesn't require coercion. it's done! it's able to coerce for y because there's a single impl, so all the expected types are known
2 replies 0 retweets 0 likes -
Replying to @ManishEarth @sgrif
the moment you add the second impl, it no longer is able to find a single impl for x. which is usually fine, this means that &y needs inference to help pick, but deref coercions don't work with inference
2 replies 0 retweets 0 likes -
Replying to @ManishEarth @sgrif
Though i guess I see what you're saying: the way trait search works is via self, and yes, in that sense self is special cased, but that's not really special casing as much as it's fundamentally how traits work in the type system
1 reply 0 retweets 0 likes -
Replying to @ManishEarth
> it's fundamentally how traits [have arbitrarily been chosen (which is fine) to] work FTFY ;)
2 replies 0 retweets 0 likes -
Replying to @sgrif
Manish Retweeted Miss Dada 🏳️⚧️
right, i'm trying to say this isn't specific to deref coercions. (and also that it's not the same rules as .bar() at all, autoderef works differently from deref coercions)https://twitter.com/sgrif/status/1199080936320557056 …
Manish added,
1 reply 0 retweets 0 likes -
Replying to @ManishEarth
The rules I assume we'd use are basically an extension of that, but I def can't fit anything more in depth than "fewest derefs left to right wins" without writing a formal RFC (which I'd love to do but probably won't any time soon)
1 reply 0 retweets 1 like -
Replying to @sgrif
i think you're misunderstanding how deref coercions currently work, there doesn't need to be a function involved for them to work let y: &str = &String works, for example
2 replies 0 retweets 0 likes -
Replying to @ManishEarth @sgrif
so the deref coercion is just one fudge factor in a sea of inference questions autoderef, on the other hand, works only for one specific type of syntax, and isn't impacted by the types of the arguments
1 reply 0 retweets 0 likes
Right, it's impacted by whether it knows the type it's inferring to or whether it needs to determine the type to satisfy trait resolution, and there's a special case for when there's only one impl of said trait for the receiving type
-
-
Replying to @sgrif @ManishEarth
My biggest frustration has been that it just stops if it sees two impls at all, regardless of whether they could apply or not. It led to (for example) having to inline r2d2-diesel into diesel so we could impl Connection on pointers directly
0 replies 0 retweets 1 likeThanks. Twitter will use this to make your timeline better. UndoUndo
-
Loading seems to be taking a while.
Twitter may be over capacity or experiencing a momentary hiccup. Try again or visit Twitter Status for more information.