From 0f42a71806ad62cd042dd40ab42501180fb72999 Mon Sep 17 00:00:00 2001 From: Jesse Bakker Date: Tue, 15 Dec 2020 16:25:57 +0100 Subject: Parenthesize composite if condition before inverting in invert-if assist --- crates/syntax/src/ast/make.rs | 3 +++ 1 file changed, 3 insertions(+) (limited to 'crates/syntax/src') diff --git a/crates/syntax/src/ast/make.rs b/crates/syntax/src/ast/make.rs index cc09b77a5..16b079c42 100644 --- a/crates/syntax/src/ast/make.rs +++ b/crates/syntax/src/ast/make.rs @@ -196,6 +196,9 @@ pub fn expr_method_call(receiver: ast::Expr, method: &str, arg_list: ast::ArgLis pub fn expr_ref(expr: ast::Expr, exclusive: bool) -> ast::Expr { expr_from_text(&if exclusive { format!("&mut {}", expr) } else { format!("&{}", expr) }) } +pub fn expr_paren(expr: ast::Expr) -> ast::Expr { + expr_from_text(&format!("({})", expr)) +} fn expr_from_text(text: &str) -> ast::Expr { ast_from_text(&format!("const C: () = {};", text)) } -- cgit v1.2.3