Allow break
and co to go through try{}
blocks
This commit is contained in:
parent
16264a3a53
commit
eecab99dec
@ -152,7 +152,7 @@ fn infer_expr_inner(&mut self, tgt_expr: ExprId, expected: &Expectation) -> Ty {
|
|||||||
.1
|
.1
|
||||||
}
|
}
|
||||||
Expr::TryBlock { body } => {
|
Expr::TryBlock { body } => {
|
||||||
self.with_breakable_ctx(BreakableKind::Border, self.err_ty(), None, |this| {
|
self.with_breakable_ctx(BreakableKind::Block, self.err_ty(), None, |this| {
|
||||||
let _inner = this.infer_expr(*body, expected);
|
let _inner = this.infer_expr(*body, expected);
|
||||||
});
|
});
|
||||||
// FIXME should be std::result::Result<{inner}, _>
|
// FIXME should be std::result::Result<{inner}, _>
|
||||||
|
@ -37,28 +37,6 @@ fn foo() {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
|
||||||
fn try_blocks_are_borders() {
|
|
||||||
check_diagnostics(
|
|
||||||
r#"
|
|
||||||
fn foo() {
|
|
||||||
'a: loop {
|
|
||||||
try {
|
|
||||||
break;
|
|
||||||
//^^^^^ error: break outside of loop
|
|
||||||
break 'a;
|
|
||||||
//^^^^^^^^ error: break outside of loop
|
|
||||||
continue;
|
|
||||||
//^^^^^^^^ error: continue outside of loop
|
|
||||||
continue 'a;
|
|
||||||
//^^^^^^^^^^^ error: continue outside of loop
|
|
||||||
};
|
|
||||||
}
|
|
||||||
}
|
|
||||||
"#,
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn async_blocks_are_borders() {
|
fn async_blocks_are_borders() {
|
||||||
check_diagnostics(
|
check_diagnostics(
|
||||||
@ -121,6 +99,24 @@ fn foo() {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn try_blocks_pass_through() {
|
||||||
|
check_diagnostics(
|
||||||
|
r#"
|
||||||
|
fn foo() {
|
||||||
|
'a: loop {
|
||||||
|
try {
|
||||||
|
break;
|
||||||
|
break 'a;
|
||||||
|
continue;
|
||||||
|
continue 'a;
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
"#,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn label_blocks() {
|
fn label_blocks() {
|
||||||
check_diagnostics(
|
check_diagnostics(
|
||||||
|
Loading…
Reference in New Issue
Block a user