Commit 1d56e3a
committed
Auto merge of rust-lang#112953 - compiler-errors:interpolated-block-exprs, r=WaffleLapkin
Support interpolated block for `try` and `async`
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 rust-lang#112952, which surprised me. There doesn't seem to be a *technical* reason why we don't support this.
### Precedent:
This is supported:
```rust
macro_rules! always {
($block:block) => {
if true $block
}
}
fn main() {
always!({});
}
```
### Counterpoint:
However, for context, this is *not* supported:
```rust
macro_rules! unsafe_block {
($block:block) => {
unsafe $block
}
}
fn main() {
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 rust-lang#69760 for why something like `unsafe $block` is not supported, and even that PR doesn't have much information.
Fixes rust-lang#112952File tree
3 files changed
+45
-4
lines changed- compiler/rustc_parse/src/parser
- tests/ui/parser
3 files changed
+45
-4
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
3003 | 3003 | | |
3004 | 3004 | | |
3005 | 3005 | | |
3006 | | - | |
| 3006 | + | |
| 3007 | + | |
3007 | 3008 | | |
3008 | 3009 | | |
3009 | 3010 | | |
| |||
3013 | 3014 | | |
3014 | 3015 | | |
3015 | 3016 | | |
3016 | | - | |
| 3017 | + | |
| 3018 | + | |
3017 | 3019 | | |
3018 | 3020 | | |
3019 | 3021 | | |
| |||
3032 | 3034 | | |
3033 | 3035 | | |
3034 | 3036 | | |
3035 | | - | |
| 3037 | + | |
| 3038 | + | |
| 3039 | + | |
3036 | 3040 | | |
3037 | 3041 | | |
3038 | | - | |
| 3042 | + | |
| 3043 | + | |
| 3044 | + | |
3039 | 3045 | | |
3040 | 3046 | | |
3041 | 3047 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
0 commit comments