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".
-
-
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 -
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
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)
-
-
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 - 2 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.