aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_syntax/src/ast/make.rs
diff options
context:
space:
mode:
authorZac Pullar-Strecker <[email protected]>2020-07-31 03:12:44 +0100
committerZac Pullar-Strecker <[email protected]>2020-07-31 03:12:44 +0100
commitf05d7b41a719d848844b054a16477b29d0f063c6 (patch)
tree0a8a0946e8aef2ce64d4c13d0035ba41cce2daf3 /crates/ra_syntax/src/ast/make.rs
parent73ff610e41959e3e7c78a2b4b25b086883132956 (diff)
parent6b7cb8b5ab539fc4333ce34bc29bf77c976f232a (diff)
Merge remote-tracking branch 'upstream/master' into 503-hover-doc-links
Hasn't fixed tests yet.
Diffstat (limited to 'crates/ra_syntax/src/ast/make.rs')
-rw-r--r--crates/ra_syntax/src/ast/make.rs14
1 files changed, 7 insertions, 7 deletions
diff --git a/crates/ra_syntax/src/ast/make.rs b/crates/ra_syntax/src/ast/make.rs
index 192c610f1..509e8ae7a 100644
--- a/crates/ra_syntax/src/ast/make.rs
+++ b/crates/ra_syntax/src/ast/make.rs
@@ -37,7 +37,7 @@ fn path_from_text(text: &str) -> ast::Path {
37pub fn use_tree( 37pub fn use_tree(
38 path: ast::Path, 38 path: ast::Path,
39 use_tree_list: Option<ast::UseTreeList>, 39 use_tree_list: Option<ast::UseTreeList>,
40 alias: Option<ast::Alias>, 40 alias: Option<ast::Rename>,
41 add_star: bool, 41 add_star: bool,
42) -> ast::UseTree { 42) -> ast::UseTree {
43 let mut buf = "use ".to_string(); 43 let mut buf = "use ".to_string();
@@ -60,22 +60,22 @@ pub fn use_tree_list(use_trees: impl IntoIterator<Item = ast::UseTree>) -> ast::
60 ast_from_text(&format!("use {{{}}};", use_trees)) 60 ast_from_text(&format!("use {{{}}};", use_trees))
61} 61}
62 62
63pub fn use_item(use_tree: ast::UseTree) -> ast::UseItem { 63pub fn use_item(use_tree: ast::UseTree) -> ast::Use {
64 ast_from_text(&format!("use {};", use_tree)) 64 ast_from_text(&format!("use {};", use_tree))
65} 65}
66 66
67pub fn record_field(name: ast::NameRef, expr: Option<ast::Expr>) -> ast::RecordField { 67pub fn record_field(name: ast::NameRef, expr: Option<ast::Expr>) -> ast::RecordExprField {
68 return match expr { 68 return match expr {
69 Some(expr) => from_text(&format!("{}: {}", name, expr)), 69 Some(expr) => from_text(&format!("{}: {}", name, expr)),
70 None => from_text(&name.to_string()), 70 None => from_text(&name.to_string()),
71 }; 71 };
72 72
73 fn from_text(text: &str) -> ast::RecordField { 73 fn from_text(text: &str) -> ast::RecordExprField {
74 ast_from_text(&format!("fn f() {{ S {{ {}, }} }}", text)) 74 ast_from_text(&format!("fn f() {{ S {{ {}, }} }}", text))
75 } 75 }
76} 76}
77 77
78pub fn record_field_def(name: ast::NameRef, ty: ast::TypeRef) -> ast::RecordFieldDef { 78pub fn record_field_def(name: ast::NameRef, ty: ast::TypeRef) -> ast::RecordField {
79 ast_from_text(&format!("struct S {{ {}: {}, }}", name, ty)) 79 ast_from_text(&format!("struct S {{ {}: {}, }}", name, ty))
80} 80}
81 81
@@ -291,10 +291,10 @@ pub fn visibility_pub_crate() -> ast::Visibility {
291pub fn fn_def( 291pub fn fn_def(
292 visibility: Option<ast::Visibility>, 292 visibility: Option<ast::Visibility>,
293 fn_name: ast::Name, 293 fn_name: ast::Name,
294 type_params: Option<ast::TypeParamList>, 294 type_params: Option<ast::GenericParamList>,
295 params: ast::ParamList, 295 params: ast::ParamList,
296 body: ast::BlockExpr, 296 body: ast::BlockExpr,
297) -> ast::FnDef { 297) -> ast::Fn {
298 let type_params = 298 let type_params =
299 if let Some(type_params) = type_params { format!("<{}>", type_params) } else { "".into() }; 299 if let Some(type_params) = type_params { format!("<{}>", type_params) } else { "".into() };
300 let visibility = match visibility { 300 let visibility = match visibility {