Skip to content

Handle easy try-block desugar#3997

Merged
CohenArthur merged 2 commits into
Rust-GCC:masterfrom
CohenArthur:try-block-desugar-mk1
Jul 28, 2025
Merged

Handle easy try-block desugar#3997
CohenArthur merged 2 commits into
Rust-GCC:masterfrom
CohenArthur:try-block-desugar-mk1

Conversation

@CohenArthur

Copy link
Copy Markdown
Member

This PR adds a desugar dispatcher for expressions, called expression yeast (since yeast consumes all the sugar...) and a desugar for try-block in the easy case, which is the most common in core. Basically, it can handle try-blocks with a tail expression and no statements - as that requires block labels to be handled properly

@CohenArthur CohenArthur force-pushed the try-block-desugar-mk1 branch from 5b89afc to 1e0238f Compare July 22, 2025 11:37
@CohenArthur

Copy link
Copy Markdown
Member Author

Actually, this is enough for all of core - the crate only uses the form try { <expr> }

@CohenArthur CohenArthur added this pull request to the merge queue Jul 24, 2025
@github-merge-queue github-merge-queue Bot removed this pull request from the merge queue due to a conflict with the base branch Jul 24, 2025
@CohenArthur CohenArthur force-pushed the try-block-desugar-mk1 branch from 1e0238f to 7b81ea9 Compare July 28, 2025 07:21
@CohenArthur CohenArthur enabled auto-merge July 28, 2025 07:21
gcc/rust/ChangeLog:

	* ast/rust-ast.h: Add the new variant.
	* ast/rust-expr.h: Use it for TryExpr class.
gcc/rust/ChangeLog:

	* Make-lang.in: Compile it.
	* ast/rust-expression-yeast.cc (ExpressionYeast::dispatch): Dispatch to try-block
	desugar.
	* ast/rust-desugar-try-block.cc: New file.
	* ast/rust-desugar-try-block.h: New file.

gcc/testsuite/ChangeLog:

	* rust/compile/try_block1.rs: New test.
@CohenArthur CohenArthur added this pull request to the merge queue Jul 28, 2025
auto-merge was automatically disabled July 28, 2025 07:57

Pull Request is not mergeable

Merged via the queue into Rust-GCC:master with commit 39a5c15 Jul 28, 2025
13 checks passed
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.

1 participant