9458: minor: Remove make::match_arm_with_guard r=Veykril a=Veykril

bors r+

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
This commit is contained in:
bors[bot] 2021-07-01 23:47:38 +00:00 committed by GitHub
commit d18cfd4467
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 34 additions and 17 deletions

View file

@ -228,7 +228,7 @@ fn single_node(element: impl Into<SyntaxElement>) -> RangeInclusive<SyntaxElemen
#[test]
fn test_increase_indent() {
let arm_list = {
let arm = make::match_arm(iter::once(make::wildcard_pat().into()), make::expr_unit());
let arm = make::match_arm(iter::once(make::wildcard_pat().into()), None, make::expr_unit());
make::match_arm_list(vec![arm.clone(), arm])
};
assert_eq!(

View file

@ -421,9 +421,16 @@ pub fn path_pat(path: ast::Path) -> ast::Pat {
}
}
pub fn match_arm(pats: impl IntoIterator<Item = ast::Pat>, expr: ast::Expr) -> ast::MatchArm {
pub fn match_arm(
pats: impl IntoIterator<Item = ast::Pat>,
guard: Option<ast::Expr>,
expr: ast::Expr,
) -> ast::MatchArm {
let pats_str = pats.into_iter().join(" | ");
return from_text(&format!("{} => {}", pats_str, expr));
return match guard {
Some(guard) => from_text(&format!("{} if {} => {}", pats_str, guard, expr)),
None => from_text(&format!("{} => {}", pats_str, expr)),
};
fn from_text(text: &str) -> ast::MatchArm {
ast_from_text(&format!("fn f() {{ match () {{{}}} }}", text))