mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-08-18 17:40:29 +00:00
Remove make::match_arm_with_guard
This commit is contained in:
parent
8967856d78
commit
071ac48b6c
7 changed files with 34 additions and 17 deletions
|
@ -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!(
|
||||
|
|
|
@ -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))
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue