-
Notifications
You must be signed in to change notification settings - Fork 909
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Don't remove block label from closure body (#6468)
- Loading branch information
Showing
3 changed files
with
418 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,192 @@ | ||
// _0: in-macro | ||
// _1: last argument in function invocation | ||
// _2: non-last argument in function invocation | ||
// _3: simple expression | ||
|
||
// test0: the cause reported in issue: label is used, and there is usage, multiple statements | ||
pub fn rustfmt_test0_0(condition: bool) { | ||
test_macro!(|transaction| 'block: { | ||
if condition { | ||
break 'block 0; | ||
} | ||
|
||
todo!() | ||
}); | ||
} | ||
|
||
pub fn rustfmt_test0_1(condition: bool) { | ||
test_func(|transaction| 'block: { | ||
if condition { | ||
break 'block 0; | ||
} | ||
|
||
todo!() | ||
}); | ||
} | ||
|
||
pub fn rustfmt_test0_2(condition: bool) { | ||
test_func2(|transaction| 'block: { | ||
if condition { | ||
break 'block 0; | ||
} | ||
|
||
todo!() | ||
}, 0); | ||
} | ||
|
||
pub fn rustfmt_test0_3(condition: bool) { | ||
let x = |transaction| 'block: { | ||
if condition { | ||
break 'block 0; | ||
} | ||
|
||
todo!() | ||
}; | ||
} | ||
|
||
|
||
// test1: label is unused, and there is usage, multiple statements | ||
pub fn rustfmt_test1_0(condition: bool) { | ||
test_macro!(|transaction| 'block: { | ||
if condition { | ||
todo!(""); | ||
} | ||
|
||
todo!() | ||
}); | ||
} | ||
|
||
pub fn rustfmt_test1_1(condition: bool) { | ||
test_func(|transaction| 'block: { | ||
if condition { | ||
todo!(""); | ||
} | ||
|
||
todo!() | ||
}); | ||
} | ||
|
||
pub fn rustfmt_test1_2(condition: bool) { | ||
test_func2(|transaction| 'block: { | ||
if condition { | ||
todo!(""); | ||
} | ||
|
||
todo!() | ||
}, 0); | ||
} | ||
|
||
pub fn rustfmt_test1_3(condition: bool) { | ||
let x = |transaction| 'block: { | ||
if condition { | ||
todo!(""); | ||
} | ||
|
||
todo!() | ||
}; | ||
} | ||
|
||
|
||
|
||
// test2: label is used, single expression | ||
pub fn rustfmt_test2_0(condition: bool) { | ||
test_macro!(|transaction| 'block: { | ||
break 'block 0; | ||
}); | ||
} | ||
|
||
pub fn rustfmt_test2_1(condition: bool) { | ||
test_func(|transaction| 'block: { | ||
break 'block 0; | ||
}); | ||
} | ||
|
||
pub fn rustfmt_test2_2(condition: bool) { | ||
test_func2(|transaction| 'block: { | ||
break 'block 0; | ||
}, 0); | ||
} | ||
|
||
pub fn rustfmt_test2_3(condition: bool) { | ||
let x = |transaction| 'block: { | ||
break 'block 0; | ||
}; | ||
} | ||
|
||
// test3: label is unused, single general multi-line expression | ||
pub fn rustfmt_test3_0(condition: bool) { | ||
test_macro!(|transaction| 'block: { | ||
vec![ | ||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, | ||
0, | ||
] | ||
}); | ||
} | ||
|
||
pub fn rustfmt_test3_1(condition: bool) { | ||
test_func(|transaction| 'block: { | ||
vec![ | ||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, | ||
0, | ||
] | ||
}); | ||
} | ||
|
||
pub fn rustfmt_test3_2(condition: bool) { | ||
test_func2(|transaction| 'block: { | ||
vec![ | ||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, | ||
0, | ||
] | ||
}, 0); | ||
} | ||
|
||
pub fn rustfmt_test3_3(condition: bool) { | ||
let x = |transaction| 'block: { | ||
vec![ | ||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, | ||
0, | ||
] | ||
}; | ||
} | ||
|
||
// test4: label is unused, single block statement-expression | ||
pub fn rustfmt_test4_0(condition: bool) { | ||
test_macro!(|transaction| 'block: { | ||
if condition { | ||
break 'block 1; | ||
} else { | ||
break 'block 0; | ||
} | ||
}); | ||
} | ||
|
||
pub fn rustfmt_test4_1(condition: bool) { | ||
test_func(|transaction| 'block: { | ||
if condition { | ||
break 'block 1; | ||
} else { | ||
break 'block 0; | ||
} | ||
}); | ||
} | ||
|
||
pub fn rustfmt_test4_2(condition: bool) { | ||
test_func2(|transaction| 'block: { | ||
if condition { | ||
break 'block 1; | ||
} else { | ||
break 'block 0; | ||
} | ||
}, 1); | ||
} | ||
|
||
pub fn rustfmt_test4_3(condition: bool) { | ||
let x = |transaction| 'block: { | ||
if condition { | ||
break 'block 1; | ||
} else { | ||
break 'block 0; | ||
} | ||
}; | ||
} |
Oops, something went wrong.