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
Right, which is my point. It's willing to try coercing y, it's not willing to try coercing x. It's a special case for `Self`. I'm not saying it's bad, I'm saying it's arbitrary
1 reply 0 retweets 1 like -
Replying to @sgrif
I think my issue is with the term "special case" here, because the underlying reason here is that trait search fundamentally works off of self, and this isn't the only way that manifests. this isn't specific to deref coercions.
1 reply 0 retweets 1 like -
Replying to @ManishEarth
Sure, but what is self other than the first argument? re-rebalancing coherence was literally about changing the trait system to stop treating self as different, and instead just treating it as the leftmost argument, and applying the same rules left to right
1 reply 0 retweets 3 likes -
Replying to @sgrif
self isn't always the first argument, though It's not for foo<T: Trait<U>, U>(x: bool, y: T, z: U), and you'll have similar problems here the UFCS call is basically eq<T: PartialEq<U>, U>(&T, &U)
1 reply 0 retweets 0 likes -
Replying to @ManishEarth
Right, which is why I wouldn't want to treat `self` as special at all, rules for dispatching both are the same. Fewest derefs left to right. (don't deref T, try derefing U repeatedly, if you find an impl stop, deref T once, ...)
1 reply 0 retweets 1 like -
Replying to @sgrif
"left to right" assumes that there's a function here *at all*, though
2 replies 0 retweets 0 likes -
Replying to @ManishEarth @sgrif
i guess you can special case for deref coercions that are happening in function call arguments only
1 reply 0 retweets 0 likes
We already do (by not doing it)
-
-
Replying to @sgrif
?? we don't? we treat deref coercions the same everywhere. autoderef is special, but it works totally differently
1 reply 0 retweets 0 likes -
Replying to @ManishEarth
Function arguments where the only place that you cannot consistently rely on `&` performing deref coercion
1 reply 0 retweets 0 likes - 6 more replies
New conversation -
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.