diff options
author | bors[bot] <26634292+bors[bot]@users.noreply.github.com> | 2020-08-25 10:01:12 +0100 |
---|---|---|
committer | GitHub <[email protected]> | 2020-08-25 10:01:12 +0100 |
commit | b4bc34649857cfcf7fcb39b9af02342fb7b8c89e (patch) | |
tree | f23650fe42fdc32d81108ff891d17d0bb7b60b6f /crates/syntax | |
parent | ef9cea945d5767e7c60d5931a7649a73caea23ad (diff) | |
parent | 7721accebf5e2c39bd4cb984346b11b72c12ba56 (diff) |
Merge #5863
5863: Cleanup invert-if
r=matklad a=matklad
bors r+
🤖
Co-authored-by: Aleksey Kladov <[email protected]>
Diffstat (limited to 'crates/syntax')
-rw-r--r-- | crates/syntax/src/ast/make.rs | 9 |
1 files changed, 3 insertions, 6 deletions
diff --git a/crates/syntax/src/ast/make.rs b/crates/syntax/src/ast/make.rs index 7958721e2..7ba625990 100644 --- a/crates/syntax/src/ast/make.rs +++ b/crates/syntax/src/ast/make.rs | |||
@@ -7,7 +7,7 @@ | |||
7 | use itertools::Itertools; | 7 | use itertools::Itertools; |
8 | use stdx::format_to; | 8 | use stdx::format_to; |
9 | 9 | ||
10 | use crate::{ast, AstNode, SourceFile, SyntaxKind, SyntaxNode, SyntaxText, SyntaxToken}; | 10 | use crate::{ast, AstNode, SourceFile, SyntaxKind, SyntaxNode, SyntaxToken}; |
11 | 11 | ||
12 | pub fn name(text: &str) -> ast::Name { | 12 | pub fn name(text: &str) -> ast::Name { |
13 | ast_from_text(&format!("mod {};", text)) | 13 | ast_from_text(&format!("mod {};", text)) |
@@ -137,11 +137,8 @@ pub fn expr_prefix(op: SyntaxKind, expr: ast::Expr) -> ast::Expr { | |||
137 | pub fn expr_call(f: ast::Expr, arg_list: ast::ArgList) -> ast::Expr { | 137 | pub fn expr_call(f: ast::Expr, arg_list: ast::ArgList) -> ast::Expr { |
138 | expr_from_text(&format!("{}{}", f, arg_list)) | 138 | expr_from_text(&format!("{}{}", f, arg_list)) |
139 | } | 139 | } |
140 | pub fn expr_method_call<F>(text: &str, caller: F) -> Option<ast::Expr> | 140 | pub fn expr_method_call(receiver: ast::Expr, method: &str, arg_list: ast::ArgList) -> ast::Expr { |
141 | where | 141 | expr_from_text(&format!("{}.{}{}", receiver, method, arg_list)) |
142 | F: FnOnce() -> Option<SyntaxText>, | ||
143 | { | ||
144 | try_expr_from_text(&format!("{}.{}()", caller()?, text)) | ||
145 | } | 142 | } |
146 | fn expr_from_text(text: &str) -> ast::Expr { | 143 | fn expr_from_text(text: &str) -> ast::Expr { |
147 | ast_from_text(&format!("const C: () = {};", text)) | 144 | ast_from_text(&format!("const C: () = {};", text)) |