use ControlFlow::Break(_) pattern

This commit is contained in:
Dezhi Wu 2021-09-22 18:48:47 +08:00
parent 971a271840
commit f888e85f79

View file

@ -1185,13 +1185,12 @@ impl FlowHandler {
let stmt = make::expr_stmt(action); let stmt = make::expr_stmt(action);
let block = make::block_expr(iter::once(stmt.into()), None); let block = make::block_expr(iter::once(stmt.into()), None);
let controlflow_break_path = make::path_from_text("ControlFlow::Break"); let controlflow_break_path = make::path_from_text("ControlFlow::Break");
let tuple_pat = make::tuple_pat(iter::empty());
let condition = make::condition( let condition = make::condition(
call_expr, call_expr,
Some( Some(
make::tuple_struct_pat( make::tuple_struct_pat(
controlflow_break_path, controlflow_break_path,
iter::once(tuple_pat.into()), iter::once(make::wildcard_pat().into()),
) )
.into(), .into(),
), ),
@ -3301,7 +3300,7 @@ fn foo() {
fn foo() { fn foo() {
loop { loop {
let mut n = 1; let mut n = 1;
if let ControlFlow::Break(()) = fun_name(&mut n) { if let ControlFlow::Break(_) = fun_name(&mut n) {
break; break;
} }
let h = 1 + n; let h = 1 + n;
@ -3338,7 +3337,7 @@ fn foo() {
fn foo() { fn foo() {
loop { loop {
let mut n = 1; let mut n = 1;
if let ControlFlow::Break(()) = fun_name(n) { if let ControlFlow::Break(_) = fun_name(n) {
break; break;
} }
let h = 1; let h = 1;