aboutsummaryrefslogtreecommitdiff
path: root/crates/syntax/src/ast
diff options
context:
space:
mode:
authorJesse Bakker <[email protected]>2020-12-15 15:25:57 +0000
committerJesse Bakker <[email protected]>2020-12-15 15:25:57 +0000
commit0f42a71806ad62cd042dd40ab42501180fb72999 (patch)
treeb6224de2218c9a13477f05f23c5e63e6184b5957 /crates/syntax/src/ast
parent8cba4231092b0d9ca44ea1f545856239e2fb6eed (diff)
Parenthesize composite if condition before inverting in invert-if assist
Diffstat (limited to 'crates/syntax/src/ast')
-rw-r--r--crates/syntax/src/ast/make.rs3
1 files changed, 3 insertions, 0 deletions
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
196pub fn expr_ref(expr: ast::Expr, exclusive: bool) -> ast::Expr { 196pub fn expr_ref(expr: ast::Expr, exclusive: bool) -> ast::Expr {
197 expr_from_text(&if exclusive { format!("&mut {}", expr) } else { format!("&{}", expr) }) 197 expr_from_text(&if exclusive { format!("&mut {}", expr) } else { format!("&{}", expr) })
198} 198}
199pub fn expr_paren(expr: ast::Expr) -> ast::Expr {
200 expr_from_text(&format!("({})", expr))
201}
199fn expr_from_text(text: &str) -> ast::Expr { 202fn expr_from_text(text: &str) -> ast::Expr {
200 ast_from_text(&format!("const C: () = {};", text)) 203 ast_from_text(&format!("const C: () = {};", text))
201} 204}