Description
Now that basic support for associated types is there, we should be able to
implement type inference for the ?
operator. For example, in
let x = Ok(1u32);
let y = x?;
y;
hovering y
should say u32
.
Like for
loops, rustc implements the ?
operator via desugaring.
So the same thing as there goes here: we could do the same, but it's probably
simpler for now to handle them directly during type inference.
This should work very similarly as for
loops, so basically the same steps as
there apply, except we need to project to std::ops::Try::Ok
. Note that we
don't really care about the error part at this moment, because there are no
types to be inferred there -- the error type almost always needs to be already
known because Into
is used to convert it to the function's error type.
Since this shares a few steps and the general approach with for
, I'd suggest
doing one after the other.
Here's a Zulip stream for questions about this.