Skip to content

Support interpolated block for try and async - #112953

Merged
bors merged 1 commit into
rust-lang:masterfrom
compiler-errors:interpolated-block-exprs
Jul 22, 2023
Merged

Support interpolated block for try and async#112953
bors merged 1 commit into
rust-lang:masterfrom
compiler-errors:interpolated-block-exprs

Conversation

@compiler-errors

Copy link
Copy Markdown
Contributor

I'm putting this up for T-lang discussion, to decide whether or not they feel like this should be supported. This was raised in #112952, which surprised me. There doesn't seem to be a technical reason why we don't support this.

Precedent:

This is supported:

macro_rules! always {($block:block) => {iftrue $block
}}fnmain(){always!({});}

Counterpoint:

However, for context, this is not supported:

macro_rules! unsafe_block {($block:block) => {unsafe $block
}}fnmain(){unsafe_block!({});}

If this support for async and try with interpolated blocks is not desirable, then I can convert them to instead the same diagnostic as unsafe $block and make this situation a lot less ambiguous.


I'll try to write up more before T-lang triage on Tuesday. I couldn't find anything other than #69760 for why something like unsafe $block is not supported, and even that PR doesn't have much information.

Fixes#112952

Loading
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-grammarArea: The grammar of RustA-parserArea: The lexing & parsing of Rust source code to an ASTdisposition-mergeThis issue / PR is in PFCP or FCP with a disposition to merge it.finished-final-comment-periodThe final comment period is finished for this PR / Issue.merged-by-borsThis PR was explicitly merged by bors.needs-fcpThis change is insta-stable, or significant enough to need a team FCP to proceed.S-waiting-on-borsStatus: Waiting on bors to run and complete tests. Bors will change the label on completion.T-langRelevant to the language team

Projects

None yet

Development

Successfully merging this pull request may close these issues.

try $body:block in a macro is not recognized as a try block

11 participants

@compiler-errors@rustbot@joshtriplett@rfcbot@scottmcm@RalfJung@bors@rust-timer@WaffleLapkin@Noratrieb@apiraino