`try{}`: What does homogeneity mean for `Poll`?
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 119k
- Forks
- 16.1k
- PR merge metrics
- PR metrics pending
Description
The idea of https://github.com/rust-lang/rfcs/pull/3721 is that you get "the same" thing out of try { x? }.
However, there's currently no requirement that that actually happen in either the trait nor the desugaring.
As usual, Poll is the problem child for this: https://doc.rust-lang.org/std/task/enum.Poll.html#impl-Try-for-Poll%3COption%3CResult%3CT,+E%3E%3E%3E
Some potential options:
- Add a bound like
type Residual: Residual<Self::Output, TryType = Self>;to theTrytrait so that this can't happen any more.- that insists on separately-coloured residuals. This would require changing the residual types for
Pollto be distinct, and to update theFromResidualimplementations accordingly to continue to support stable things.
- that insists on separately-coloured residuals. This would require changing the residual types for
- Give up and say "meh, whatever" and
try { my_poll? }will give aResultor anOption. - Add a bound into the desugaring for
?ortry {somehow that would enforce that it's usable only onTrytypes with full homogeneity- perhaps merge the branch+from_residual into one helper function that calls both but which has some extra
wherebounds
- perhaps merge the branch+from_residual into one helper function that calls both but which has some extra
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Read RFC 3721 and the linked Poll implementation, then trace the Try trait and try-block/? desugaring. Compare the three options in the issue and document or implement the selected homogeneity rule, including compatibility implications for Poll residuals and FromResidual implementations.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- compilers
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 30/100