Closed
Description
I've been playing around with label-break-value
today, and it comes in super handy in async
blocks. However, it seems to run into issues when combined with the try_blocks
feature.
I tried this code:
#![feature(try_blocks, label_break_value)]
fn main() {
let _: Result<(), ()> = try {
'foo: {
Err(())?;
break 'foo;
}
};
}
I expected to see this happen: the code should compile just fine.
Instead, this happened:
error[E0695]: unlabeled `break` inside of a labeled block
--> src/main.rs:6:20
|
6 | Err(())?;
| ^ `break` statements that would diverge to or through a labeled block need to bear a label
error: aborting due to previous error
This is a continuation of the discussion here. As @ciphergoth pointed out, this code (following the syntactic sugar from the label-break-value RFC) compiles:
#![feature(try_blocks, label_break_value)]
fn main() {
let _: Result<(), ()> = try {
'foo: loop {
break {
Err(())?;
break 'foo;
}
}
};
}
Meta
rustc --version --verbose
:
rustc 1.45.0-nightly (a74d1862d 2020-05-14)
This issue has been assigned to @samrat via this comment.
Metadata
Metadata
Assignees
Labels
Category: This is a bug.Call for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue.Call for participation: This issue has a mentor. Use #t-compiler/help on Zulip for discussion.`#![feature(label_break_value)]``#![feature(try_blocks)]`Relevant to the compiler team, which will review and decide on the PR/issue.This issue requires a nightly compiler in some way.