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
-
-
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 -
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
Note: Ignoring impls which cannot possibly apply via deref coercion is fundamentally different than having rules to let the compiler handle legitimately ambiguous cases. I'm not trying to claim that both should be obviously done
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.