Skip to content

Support heterogeneous try blocks (try_blocks_heterogeneous) RFC#3953

Open
MusicalNinjaDad wants to merge 25 commits into
rust-lang:masterfrom
MusicalNinjaDad:first_draft
Open

Support heterogeneous try blocks (try_blocks_heterogeneous) RFC#3953
MusicalNinjaDad wants to merge 25 commits into
rust-lang:masterfrom
MusicalNinjaDad:first_draft

Conversation

@MusicalNinjaDad

@MusicalNinjaDad MusicalNinjaDad commented Apr 21, 2026

Copy link
Copy Markdown

RFC 3721 implemented default support for homogeneous try {...} blocks, where all ?s return the same error type. This RFC aims to provide support for explicit annotation of the returned error type from a try {...} block.

Note to reviewers

This RFC provides post-hoc documentation of the current status-quo to act as an anchor point for moving forwards and a consolidation point for historical comments across multiple tickets. The changes described are already implemented in nightly as described.

I appreciate that particularly the current syntax is need of bikeshedding 🚳 - I propose that the RFC is first merged to reflect the current implementation, effectively documentation to the state that matches reality. Then I'd be happy to lead, or hand over, driving the discussion on refinements to syntax etc. Having something implemented that should have had an RFC first, but didn't, leaves a gap which makes moving forward difficult and puts barriers in place for anyone trying to experiment with the feature & give feedback.

This is created at the request of the implementor (@scottmcm) based on a brief zulip chat and written in a way to mimic those RFCs that I, as a nightly user, find valuable.

Important

Since RFCs involve many conversations at once that can be difficult to follow, please use review comment threads on the text changes instead of direct comments on the RFC.

If you don't have a particular section of the RFC to comment on, you can click on the "Comment on this file" button on the top-right corner of the diff, to the right of the "Viewed" checkbox. This will create a separate thread even if others have commented on the file too.

r? @scottmcm

AI Statement

  • The text is all my own work, hand-written, by a human, no AI.
  • The research and analysis is all my own work, no AI assistance.
  • The only AI assistance came in the form of an early review for typos but that was so unreliable I switched it off too

Rendered

Comment thread text/0000-try-blocks-heterogeneous.md
Comment thread text/0000-try-blocks-heterogeneous.md Outdated
thanks @kennytm

Co-authored-by: kennytm <kennytm@gmail.com>
@ehuss ehuss added T-lang Relevant to the language team, which will review and decide on the RFC. T-libs-api Relevant to the library API team, which will review and decide on the RFC. labels Apr 21, 2026
@ehuss ehuss removed the T-libs-api Relevant to the library API team, which will review and decide on the RFC. label Apr 28, 2026
@lyphyser

Copy link
Copy Markdown

Why not instead just fix type inference so that let x: Result<_, B> = try {} works, as well as variants like returning the try value, etc.?

@MusicalNinjaDad

Copy link
Copy Markdown
Author

Why not instead just fix type inference so that let x: Result<_, B> = try {} works, as well as variants like returning the try value, etc.?

Does the explanation added in 5101305 help @lyphyser ?

@MusicalNinjaDad

MusicalNinjaDad commented May 26, 2026

Copy link
Copy Markdown
Author

Hi @scottmcm - is this anywhere near your expectations? Would you like me to re-roll the reviewer, so this gets "taken off your plate"?

@MusicalNinjaDad

Copy link
Copy Markdown
Author

r? lang

@rustbot rustbot assigned traviscross and unassigned scottmcm Jun 14, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

T-lang Relevant to the language team, which will review and decide on the RFC.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants