Join GitHub today
Rewrite how trait-impl matching works in typeck #3742
Right now, we have this hokey thing where it walks the tree at the end, but sometimes (to help with inference) does resolution eagerly, and it's all a big mess. Besides being hard to understand and inefficient, this also means that inference often fails where it could succeed. An example is the overloading example I gave in my blog post, where the result type often fails to be inferred (at least according to some folk on IRC, I haven't experimented much with this myself, so I don't have a precise test case).
I want to have it work something like this:
These pairs more-or-less correspond to Haskell's type contexts. "Eager resolution" is context simplification. The only reason it's reasonable to use pairs is if we decide to enforce overload freedom, as I described in my blog post.
Also, to ensure termination, it may be necessary to add a depth to these pairs, unless we decide to enforce something like Haskell's Paterson or Basic conditions (which I am not sure how I feel about).
Here is a test case where inference fails: