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
I can promise you I understand how deref coercion works today. My beef is entirely about when it is applied vs not, and how we could make it apply in the cases that it doesn't.
1 reply 0 retweets 1 like
I'm just saying that &str == Rc<String> should work I didn't mean for this to become such a long thread XD
-
-
Replying to @sgrif
oh, i agree, i'm just reacting to the "just apply the rules that autoderef uses", because as far as I can tell that's not possible at all, they're very different.
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.