Skip to content

Implement the new homogeneous & heterogeneous try blocks#21572

Merged
ChayimFriedman2 merged 3 commits intorust-lang:masterfrom
goffrie:try
Feb 3, 2026
Merged

Implement the new homogeneous & heterogeneous try blocks#21572
ChayimFriedman2 merged 3 commits intorust-lang:masterfrom
goffrie:try

Conversation

@goffrie
Copy link
Contributor

@goffrie goffrie commented Feb 2, 2026

Match rust-lang/rust#148725 / rust-lang/rust#149489 from rustc nightly.
This adds parser support for the bikeshed syntax & desugaring.

@rustbot rustbot added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Feb 2, 2026
@goffrie goffrie marked this pull request as draft February 2, 2026 22:48
@rustbot rustbot removed the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Feb 2, 2026
@goffrie goffrie marked this pull request as ready for review February 2, 2026 22:51
@rustbot rustbot added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Feb 2, 2026
@goffrie
Copy link
Contributor Author

goffrie commented Feb 2, 2026

(i previously stated that type inference was broken, but I was just missing a minicore import)

Copy link
Contributor

@ChayimFriedman2 ChayimFriedman2 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Overall LGTM, have a few comments.

self.current_try_block = old_try_block;
match result_type {
Some(ty) => {
// `{ let <name>: <ty> = <expr>; <name> }`
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Technically in the MIR forcing a type is not the same as introducing a new local variable, but our MIR is horribly broken anyway and I believe in typeck the effect should be the same.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You are correct of course, but I don't think we have a construct for type ascription in an expression (which is what rustc uses) :')

HygieneId::ROOT,
);
let pat = self.alloc_pat_desugared(Pat::Bind { id: binding, subpat: None });
self.add_definition_to_binding(binding, pat);
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i think i was missing this add_definition_to_binding before but I confess that I don't know what it actually does.

Copy link
Contributor

@ChayimFriedman2 ChayimFriedman2 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

@ChayimFriedman2 ChayimFriedman2 added this pull request to the merge queue Feb 3, 2026
Merged via the queue into rust-lang:master with commit a22c1af Feb 3, 2026
15 checks passed
@rustbot rustbot removed the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Feb 3, 2026
@goffrie goffrie deleted the try branch February 3, 2026 02:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants