From 25fca0475343170b8398f5c87c76c455205ed3c4 Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Wed, 25 Sep 2019 15:09:03 +0300 Subject: cleaned up record field builder --- crates/ra_assists/src/ast_builder.rs | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) (limited to 'crates/ra_assists') diff --git a/crates/ra_assists/src/ast_builder.rs b/crates/ra_assists/src/ast_builder.rs index e4ea1fca9..9b9158ae2 100644 --- a/crates/ra_assists/src/ast_builder.rs +++ b/crates/ra_assists/src/ast_builder.rs @@ -1,6 +1,5 @@ use itertools::Itertools; -use hir::Name; use ra_syntax::{ast, AstNode, SourceFile}; pub struct AstBuilder { @@ -8,15 +7,11 @@ pub struct AstBuilder { } impl AstBuilder { - pub fn from_name(name: &Name) -> ast::RecordField { - ast_node_from_file_text(&format!("fn f() {{ S {{ {}: (), }} }}", name)) - } - fn from_text(text: &str) -> ast::RecordField { ast_node_from_file_text(&format!("fn f() {{ S {{ {}, }} }}", text)) } - pub fn from_pieces(name: &ast::NameRef, expr: Option<&ast::Expr>) -> ast::RecordField { + pub fn from_pieces(name: ast::NameRef, expr: Option) -> ast::RecordField { match expr { Some(expr) => Self::from_text(&format!("{}: {}", name.syntax(), expr.syntax())), None => Self::from_text(&name.syntax().to_string()), -- cgit v1.2.3