Skip to content

Commit 91dcbbb

Browse files
committed
Allow unlabeled breaks from desugared ? in labeled blocks
1 parent ff991d6 commit 91dcbbb

File tree

2 files changed

+14
-1
lines changed

2 files changed

+14
-1
lines changed

src/librustc_passes/loops.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ use rustc_middle::hir::map::Map;
99
use rustc_middle::ty::query::Providers;
1010
use rustc_middle::ty::TyCtxt;
1111
use rustc_session::Session;
12+
use rustc_span::hygiene::DesugaringKind;
1213
use rustc_span::Span;
1314

1415
#[derive(Clone, Copy, Debug, PartialEq)]
@@ -203,7 +204,7 @@ impl<'a, 'hir> CheckLoopVisitor<'a, 'hir> {
203204
label: &Destination,
204205
cf_type: &str,
205206
) -> bool {
206-
if self.cx == LabeledBlock {
207+
if !span.is_desugaring(DesugaringKind::QuestionMark) && self.cx == LabeledBlock {
207208
if label.label.is_none() {
208209
struct_span_err!(
209210
self.sess,
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
// compile-flags: --edition 2018
2+
#![feature(label_break_value, try_blocks)]
3+
4+
// run-pass
5+
fn main() {
6+
let _: Result<(), ()> = try {
7+
'foo: {
8+
Err(())?;
9+
break 'foo;
10+
}
11+
};
12+
}

0 commit comments

Comments
 (0)