Description
It'd be nice to be able to define an impl like this:
impl<Sized? F,A,R> FnMut<A,R> for F
where F : Fn<A,R>
{
extern "rust-call" fn call_mut(&mut self, args: A) -> R {
self.call(args)
}
}
However, at present impls like this fail to apply for a bound like FnMut(&int) -> &int
. This is because the bound region is not part of the impl declaration, and so the current higher-ranked code views this impl as as provided insufficient polymorphism. However, this code is just overly conservative. This is a problem because that impl above is crucial to the overall design.
But wait, you say! I thought there WAS an impl like that which had landed. This is true. Unfortunately, there is also a bug in the higher-ranked code that is presently masking the failure I would expect to see. In other words, the bug allows this impl to function correctly (but also other impls which should not).
I have a plan to fix this but it requires rejiggering how we process HRTB bounds. Instead of an impl providing a higher-ranked trait reference, and then relying on subtyping of trait references, we will instead have the trait selector skolemize the trait reference it is looking for and attempt to match impls. We can then do the same taint checking procedure and so forth, but in the trait checker. I won't go into the details here, it's hard to explain concisely.