not really: in the former situation you're looking for a type -- any type -- with the method "bar". it's a simple linear search down the deref chain in the latter you're looking for a type which satisfies certain constraints, which is much trickier
-
-
Replying to @ManishEarth @sgrif and
a == b is sugar for PartialEq::eq(&a, &b), not a.eq(&b). These are different, and more importantly the former situation can't be figured out as a simple search
1 reply 0 retweets 0 likes -
Assuming `a` does not have an inherent method named `eq`, I don't think those resolve differently at all. They certainly both fail in the same way with the code mentioned
2 replies 0 retweets 0 likes -
Replying to @sgrif
Oh, sorry, the problem here is b not a, my bad. Actually in that case it's far more stark, we're not looking for a method at all, we're looking to see if &b satisfies a certain trait
1 reply 0 retweets 0 likes -
Replying to @ManishEarth @sgrif
yes, we could implement stuff here to make it better, but "does b or *(n)b have a method foo" is different from "does b or &*(n)b work as T in PartialEq<T> for str".
1 reply 0 retweets 0 likes -
Replying to @ManishEarth
https://play.rust-lang.org/?version=stable&mode=debug&edition=2018&gist=be5ff1a4c279c3f05e1d4607391623ec … is a more concrete explanation of what I mean. `Self` is special cased in more than just dot form
1 reply 0 retweets 0 likes -
Replying to @sgrif
I don't understand how that's special casing self types? Deref coercions give up pretty easily, that's the root of this. Here it's giving up on the UFCS form only, with the autoderef working: https://play.rust-lang.org/?version=stable&mode=debug&edition=2018&gist=c0197afb83c273b0f4181ddef6fd0cf6 …
2 replies 0 retweets 0 likes -
Replying to @ManishEarth
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`?)
1 reply 0 retweets 0 likes -
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
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
-
-
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 - 13 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.