Cleanup and consolidate operator/method dispatch code
Once upon a time, both operator dispatch and method lookup went through the same tangled, twisty paths. It was a mess. But lo, they were severed and made two. Each could follow its own path. Overall, this is progress. But there is still room for improvement:
- The second half of "operator dispatch" is basically the same as
confirm::confirm, but with some slight differences. - The autoderef loop for
[]is basically the same asprobe, but with some slight differences (e.g., at each step it consists builtin[]as well). - The
probeloop, which usescheck::autoderef, isn't able to be part of an inference transaction betweencheck::autoderefuses operator dispatch which adds things into the main fulfillment context, thus leaking inference types etc outside the transaction.
It feels like things could still be cleaned up a bit further, allowing for more code reuse and happiness all around.
Some FIXMEs are scattered about at relevant points of the code.
I am happy to mentor.
Niko Matsakis at 2014-11-07 18:19:04
@nikomatsakis is this ticket still valid?
Steve Klabnik at 2015-12-31 18:25:36
On Thu, Dec 31, 2015 at 10:26:12AM -0800, Steve Klabnik wrote:
@nikomatsakis is this ticket still valid?
yes
Niko Matsakis at 2016-01-04 20:33:15
Inspired by this and having been a long time fan of Rust and wanting to contribute, I'm interested in solving this issue. With that said, is there anything I need to know to get started? Also, where can I start looking?
Jacob Shaffer at 2016-01-13 19:17:45
@Phyllostachys to be honest it's a bit out of cache for me. I'd have to go read into the code some to see where things stand. Anyway, usually a good place to start is to try and touch base at some point on IRC or over e-mail.
Niko Matsakis at 2016-01-13 19:37:41
I'll have to jump on IRC tonight. Who would I email if I emailed someone?
Jacob Shaffer at 2016-01-13 20:07:44
@Phyllostachys me, my e-mail is on my github page
Niko Matsakis at 2016-01-14 20:54:38
@nikomatsakis Are you still willing to mentor this?
Ahmed Charles at 2016-08-27 09:55:24
@ahmedcharles Are you still interested? We can try to connect you with niko if so
Mark Rousskov at 2017-05-13 00:11:00
Well, it's quite out of cache, but let me start by giving a few very basic pointers. The relevant code is now found at
src/librustc_typeck/check/method/mod.rs-- the fns in question arelookup_method()andlookup_method_in_trait_adjusted(). You may find theREADME.mdin that same directory useful.Niko Matsakis at 2017-05-25 18:40:01
@Mark-Simulacrum @nikomatsakis It's been a while since anyone showed any interest in this. If it's not picked up soon, I'll give it a shot, though I'm fairly certain I'll need more mentoring than what has a been provided so far.
Michael Kohl at 2017-06-06 10:16:12
Let us know if you want further instructions and we'll do our best to connect you with @nikomatsakis.
Mark Rousskov at 2017-06-06 13:13:40
Work got in the way a bit, but I'm still planning on tackling this. Started looking through the README and code a bit, will get back to you if I need more info.
Michael Kohl at 2017-06-13 03:52:53
Sorry for the long radio silence. Anyway, I just looked at this again and I don't think that this issue is a good fit for my current level of knowledge regarding
rustcinternals. Therefore I'm also not quite sure if commits like de0ffadb6722371b9eb636ee9b2d4627db9e02fa already addressed some of the issues outlined here.Michael Kohl at 2017-10-22 09:06:13
@nikomatsakis is this still relevant? I'm not afraid to give it a try :)
Seems like FIXMEs are still there: https://github.com/rust-lang/rust/blob/9fe05e9456b84996637c2f29b35c37960e537540/src/librustc_typeck/check/mod.rs#L3424 https://github.com/rust-lang/rust/blob/175631311716d7dfeceec40d2587cde7142ffa8c/src/librustc_typeck/check/method/mod.rs#L285
Sergey Melnychuk at 2020-01-16 19:02:21
To be quite honest, I don't know! It's been an awfully long time. I imagine it's still relevant, though how much things can be improved I'm not sure.
Niko Matsakis at 2020-01-17 23:06:55
Came across this issue through E-Mentor, looked up the above mentioned FIXME locations now more than a year later just in case someone is interested to do a more thorough peek:
https://github.com/rust-lang/rust/blob/39eee173fbcc21462d255b364b87715cd33b62db/compiler/rustc_typeck/src/check/place_op.rs#L52-L54
https://github.com/rust-lang/rust/blob/39eee173fbcc21462d255b364b87715cd33b62db/compiler/rustc_typeck/src/check/method/mod.rs#L293-L295
Joonas Koivunen at 2021-04-05 14:39:35
I'm removing E-mentor not because I wouldn't want to mentor but because i prefer to use the tag only for issues with some decent mentoring instructions, and I don't think this quite qualifies.
Niko Matsakis at 2021-04-09 16:45:15