Can't infer both sides of a Result when using ? #138579
Labels
A-inference
Area: Type inference
C-bug
Category: This is a bug.
needs-triage
This issue may need triage. Remove it if it has been sufficiently triaged.
T-compiler
Relevant to the compiler team, which will review and decide on the PR/issue.
T-lang
Relevant to the language team, which will review and decide on the PR/issue.
I tried this code:
I expected to see this happen: I believe this should compile, both T and E should be inferrable by the compiler.
Instead, this happened:
I also tried a couple of other things. An explicit
return Err(...)
in the branch typechecks fine. If I try something like:I get an error telling me I need to specify the type of
T
. So it appears that it's able to infer either type, but not both at the same time.Meta
Tried on stable and nightly
rustc --version --verbose
:The text was updated successfully, but these errors were encountered: