aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_syntax/src/ast
diff options
context:
space:
mode:
Diffstat (limited to 'crates/ra_syntax/src/ast')
-rw-r--r--crates/ra_syntax/src/ast/edit.rs2
-rw-r--r--crates/ra_syntax/src/ast/generated/nodes.rs80
-rw-r--r--crates/ra_syntax/src/ast/make.rs16
-rw-r--r--crates/ra_syntax/src/ast/traits.rs5
4 files changed, 51 insertions, 52 deletions
diff --git a/crates/ra_syntax/src/ast/edit.rs b/crates/ra_syntax/src/ast/edit.rs
index 667a9294f..5ed123f91 100644
--- a/crates/ra_syntax/src/ast/edit.rs
+++ b/crates/ra_syntax/src/ast/edit.rs
@@ -621,7 +621,7 @@ fn single_node(element: impl Into<SyntaxElement>) -> RangeInclusive<SyntaxElemen
621#[test] 621#[test]
622fn test_increase_indent() { 622fn test_increase_indent() {
623 let arm_list = { 623 let arm_list = {
624 let arm = make::match_arm(iter::once(make::placeholder_pat().into()), make::expr_unit()); 624 let arm = make::match_arm(iter::once(make::wildcard_pat().into()), make::expr_unit());
625 make::match_arm_list(vec![arm.clone(), arm]) 625 make::match_arm_list(vec![arm.clone(), arm])
626 }; 626 };
627 assert_eq!( 627 assert_eq!(
diff --git a/crates/ra_syntax/src/ast/generated/nodes.rs b/crates/ra_syntax/src/ast/generated/nodes.rs
index 5f51c7536..3d49309d1 100644
--- a/crates/ra_syntax/src/ast/generated/nodes.rs
+++ b/crates/ra_syntax/src/ast/generated/nodes.rs
@@ -1006,10 +1006,10 @@ impl DynTraitType {
1006 pub fn type_bound_list(&self) -> Option<TypeBoundList> { support::child(&self.syntax) } 1006 pub fn type_bound_list(&self) -> Option<TypeBoundList> { support::child(&self.syntax) }
1007} 1007}
1008#[derive(Debug, Clone, PartialEq, Eq, Hash)] 1008#[derive(Debug, Clone, PartialEq, Eq, Hash)]
1009pub struct FnPointerType { 1009pub struct FnPtrType {
1010 pub(crate) syntax: SyntaxNode, 1010 pub(crate) syntax: SyntaxNode,
1011} 1011}
1012impl FnPointerType { 1012impl FnPtrType {
1013 pub fn const_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![const]) } 1013 pub fn const_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![const]) }
1014 pub fn async_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![async]) } 1014 pub fn async_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![async]) }
1015 pub fn unsafe_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![unsafe]) } 1015 pub fn unsafe_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![unsafe]) }
@@ -1059,20 +1059,20 @@ impl ParenType {
1059 pub fn r_paren_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![')']) } 1059 pub fn r_paren_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![')']) }
1060} 1060}
1061#[derive(Debug, Clone, PartialEq, Eq, Hash)] 1061#[derive(Debug, Clone, PartialEq, Eq, Hash)]
1062pub struct PointerType { 1062pub struct PtrType {
1063 pub(crate) syntax: SyntaxNode, 1063 pub(crate) syntax: SyntaxNode,
1064} 1064}
1065impl PointerType { 1065impl PtrType {
1066 pub fn star_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![*]) } 1066 pub fn star_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![*]) }
1067 pub fn const_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![const]) } 1067 pub fn const_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![const]) }
1068 pub fn mut_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![mut]) } 1068 pub fn mut_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![mut]) }
1069 pub fn ty(&self) -> Option<Type> { support::child(&self.syntax) } 1069 pub fn ty(&self) -> Option<Type> { support::child(&self.syntax) }
1070} 1070}
1071#[derive(Debug, Clone, PartialEq, Eq, Hash)] 1071#[derive(Debug, Clone, PartialEq, Eq, Hash)]
1072pub struct ReferenceType { 1072pub struct RefType {
1073 pub(crate) syntax: SyntaxNode, 1073 pub(crate) syntax: SyntaxNode,
1074} 1074}
1075impl ReferenceType { 1075impl RefType {
1076 pub fn amp_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![&]) } 1076 pub fn amp_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![&]) }
1077 pub fn lifetime_token(&self) -> Option<SyntaxToken> { 1077 pub fn lifetime_token(&self) -> Option<SyntaxToken> {
1078 support::token(&self.syntax, T![lifetime]) 1078 support::token(&self.syntax, T![lifetime])
@@ -1263,15 +1263,15 @@ pub enum GenericArg {
1263pub enum Type { 1263pub enum Type {
1264 ArrayType(ArrayType), 1264 ArrayType(ArrayType),
1265 DynTraitType(DynTraitType), 1265 DynTraitType(DynTraitType),
1266 FnPointerType(FnPointerType), 1266 FnPtrType(FnPtrType),
1267 ForType(ForType), 1267 ForType(ForType),
1268 ImplTraitType(ImplTraitType), 1268 ImplTraitType(ImplTraitType),
1269 InferType(InferType), 1269 InferType(InferType),
1270 NeverType(NeverType), 1270 NeverType(NeverType),
1271 ParenType(ParenType), 1271 ParenType(ParenType),
1272 PathType(PathType), 1272 PathType(PathType),
1273 PointerType(PointerType), 1273 PtrType(PtrType),
1274 ReferenceType(ReferenceType), 1274 RefType(RefType),
1275 SliceType(SliceType), 1275 SliceType(SliceType),
1276 TupleType(TupleType), 1276 TupleType(TupleType),
1277} 1277}
@@ -1377,8 +1377,8 @@ impl ast::NameOwner for AssocItem {}
1377#[derive(Debug, Clone, PartialEq, Eq, Hash)] 1377#[derive(Debug, Clone, PartialEq, Eq, Hash)]
1378pub enum ExternItem { 1378pub enum ExternItem {
1379 Fn(Fn), 1379 Fn(Fn),
1380 Static(Static),
1381 MacroCall(MacroCall), 1380 MacroCall(MacroCall),
1381 Static(Static),
1382} 1382}
1383impl ast::AttrsOwner for ExternItem {} 1383impl ast::AttrsOwner for ExternItem {}
1384impl ast::NameOwner for ExternItem {} 1384impl ast::NameOwner for ExternItem {}
@@ -2434,8 +2434,8 @@ impl AstNode for DynTraitType {
2434 } 2434 }
2435 fn syntax(&self) -> &SyntaxNode { &self.syntax } 2435 fn syntax(&self) -> &SyntaxNode { &self.syntax }
2436} 2436}
2437impl AstNode for FnPointerType { 2437impl AstNode for FnPtrType {
2438 fn can_cast(kind: SyntaxKind) -> bool { kind == FN_POINTER_TYPE } 2438 fn can_cast(kind: SyntaxKind) -> bool { kind == FN_PTR_TYPE }
2439 fn cast(syntax: SyntaxNode) -> Option<Self> { 2439 fn cast(syntax: SyntaxNode) -> Option<Self> {
2440 if Self::can_cast(syntax.kind()) { 2440 if Self::can_cast(syntax.kind()) {
2441 Some(Self { syntax }) 2441 Some(Self { syntax })
@@ -2500,8 +2500,8 @@ impl AstNode for ParenType {
2500 } 2500 }
2501 fn syntax(&self) -> &SyntaxNode { &self.syntax } 2501 fn syntax(&self) -> &SyntaxNode { &self.syntax }
2502} 2502}
2503impl AstNode for PointerType { 2503impl AstNode for PtrType {
2504 fn can_cast(kind: SyntaxKind) -> bool { kind == POINTER_TYPE } 2504 fn can_cast(kind: SyntaxKind) -> bool { kind == PTR_TYPE }
2505 fn cast(syntax: SyntaxNode) -> Option<Self> { 2505 fn cast(syntax: SyntaxNode) -> Option<Self> {
2506 if Self::can_cast(syntax.kind()) { 2506 if Self::can_cast(syntax.kind()) {
2507 Some(Self { syntax }) 2507 Some(Self { syntax })
@@ -2511,8 +2511,8 @@ impl AstNode for PointerType {
2511 } 2511 }
2512 fn syntax(&self) -> &SyntaxNode { &self.syntax } 2512 fn syntax(&self) -> &SyntaxNode { &self.syntax }
2513} 2513}
2514impl AstNode for ReferenceType { 2514impl AstNode for RefType {
2515 fn can_cast(kind: SyntaxKind) -> bool { kind == REFERENCE_TYPE } 2515 fn can_cast(kind: SyntaxKind) -> bool { kind == REF_TYPE }
2516 fn cast(syntax: SyntaxNode) -> Option<Self> { 2516 fn cast(syntax: SyntaxNode) -> Option<Self> {
2517 if Self::can_cast(syntax.kind()) { 2517 if Self::can_cast(syntax.kind()) {
2518 Some(Self { syntax }) 2518 Some(Self { syntax })
@@ -2786,8 +2786,8 @@ impl From<ArrayType> for Type {
2786impl From<DynTraitType> for Type { 2786impl From<DynTraitType> for Type {
2787 fn from(node: DynTraitType) -> Type { Type::DynTraitType(node) } 2787 fn from(node: DynTraitType) -> Type { Type::DynTraitType(node) }
2788} 2788}
2789impl From<FnPointerType> for Type { 2789impl From<FnPtrType> for Type {
2790 fn from(node: FnPointerType) -> Type { Type::FnPointerType(node) } 2790 fn from(node: FnPtrType) -> Type { Type::FnPtrType(node) }
2791} 2791}
2792impl From<ForType> for Type { 2792impl From<ForType> for Type {
2793 fn from(node: ForType) -> Type { Type::ForType(node) } 2793 fn from(node: ForType) -> Type { Type::ForType(node) }
@@ -2807,11 +2807,11 @@ impl From<ParenType> for Type {
2807impl From<PathType> for Type { 2807impl From<PathType> for Type {
2808 fn from(node: PathType) -> Type { Type::PathType(node) } 2808 fn from(node: PathType) -> Type { Type::PathType(node) }
2809} 2809}
2810impl From<PointerType> for Type { 2810impl From<PtrType> for Type {
2811 fn from(node: PointerType) -> Type { Type::PointerType(node) } 2811 fn from(node: PtrType) -> Type { Type::PtrType(node) }
2812} 2812}
2813impl From<ReferenceType> for Type { 2813impl From<RefType> for Type {
2814 fn from(node: ReferenceType) -> Type { Type::ReferenceType(node) } 2814 fn from(node: RefType) -> Type { Type::RefType(node) }
2815} 2815}
2816impl From<SliceType> for Type { 2816impl From<SliceType> for Type {
2817 fn from(node: SliceType) -> Type { Type::SliceType(node) } 2817 fn from(node: SliceType) -> Type { Type::SliceType(node) }
@@ -2822,9 +2822,9 @@ impl From<TupleType> for Type {
2822impl AstNode for Type { 2822impl AstNode for Type {
2823 fn can_cast(kind: SyntaxKind) -> bool { 2823 fn can_cast(kind: SyntaxKind) -> bool {
2824 match kind { 2824 match kind {
2825 ARRAY_TYPE | DYN_TRAIT_TYPE | FN_POINTER_TYPE | FOR_TYPE | IMPL_TRAIT_TYPE 2825 ARRAY_TYPE | DYN_TRAIT_TYPE | FN_PTR_TYPE | FOR_TYPE | IMPL_TRAIT_TYPE | INFER_TYPE
2826 | INFER_TYPE | NEVER_TYPE | PAREN_TYPE | PATH_TYPE | POINTER_TYPE | REFERENCE_TYPE 2826 | NEVER_TYPE | PAREN_TYPE | PATH_TYPE | PTR_TYPE | REF_TYPE | SLICE_TYPE
2827 | SLICE_TYPE | TUPLE_TYPE => true, 2827 | TUPLE_TYPE => true,
2828 _ => false, 2828 _ => false,
2829 } 2829 }
2830 } 2830 }
@@ -2832,15 +2832,15 @@ impl AstNode for Type {
2832 let res = match syntax.kind() { 2832 let res = match syntax.kind() {
2833 ARRAY_TYPE => Type::ArrayType(ArrayType { syntax }), 2833 ARRAY_TYPE => Type::ArrayType(ArrayType { syntax }),
2834 DYN_TRAIT_TYPE => Type::DynTraitType(DynTraitType { syntax }), 2834 DYN_TRAIT_TYPE => Type::DynTraitType(DynTraitType { syntax }),
2835 FN_POINTER_TYPE => Type::FnPointerType(FnPointerType { syntax }), 2835 FN_PTR_TYPE => Type::FnPtrType(FnPtrType { syntax }),
2836 FOR_TYPE => Type::ForType(ForType { syntax }), 2836 FOR_TYPE => Type::ForType(ForType { syntax }),
2837 IMPL_TRAIT_TYPE => Type::ImplTraitType(ImplTraitType { syntax }), 2837 IMPL_TRAIT_TYPE => Type::ImplTraitType(ImplTraitType { syntax }),
2838 INFER_TYPE => Type::InferType(InferType { syntax }), 2838 INFER_TYPE => Type::InferType(InferType { syntax }),
2839 NEVER_TYPE => Type::NeverType(NeverType { syntax }), 2839 NEVER_TYPE => Type::NeverType(NeverType { syntax }),
2840 PAREN_TYPE => Type::ParenType(ParenType { syntax }), 2840 PAREN_TYPE => Type::ParenType(ParenType { syntax }),
2841 PATH_TYPE => Type::PathType(PathType { syntax }), 2841 PATH_TYPE => Type::PathType(PathType { syntax }),
2842 POINTER_TYPE => Type::PointerType(PointerType { syntax }), 2842 PTR_TYPE => Type::PtrType(PtrType { syntax }),
2843 REFERENCE_TYPE => Type::ReferenceType(ReferenceType { syntax }), 2843 REF_TYPE => Type::RefType(RefType { syntax }),
2844 SLICE_TYPE => Type::SliceType(SliceType { syntax }), 2844 SLICE_TYPE => Type::SliceType(SliceType { syntax }),
2845 TUPLE_TYPE => Type::TupleType(TupleType { syntax }), 2845 TUPLE_TYPE => Type::TupleType(TupleType { syntax }),
2846 _ => return None, 2846 _ => return None,
@@ -2851,15 +2851,15 @@ impl AstNode for Type {
2851 match self { 2851 match self {
2852 Type::ArrayType(it) => &it.syntax, 2852 Type::ArrayType(it) => &it.syntax,
2853 Type::DynTraitType(it) => &it.syntax, 2853 Type::DynTraitType(it) => &it.syntax,
2854 Type::FnPointerType(it) => &it.syntax, 2854 Type::FnPtrType(it) => &it.syntax,
2855 Type::ForType(it) => &it.syntax, 2855 Type::ForType(it) => &it.syntax,
2856 Type::ImplTraitType(it) => &it.syntax, 2856 Type::ImplTraitType(it) => &it.syntax,
2857 Type::InferType(it) => &it.syntax, 2857 Type::InferType(it) => &it.syntax,
2858 Type::NeverType(it) => &it.syntax, 2858 Type::NeverType(it) => &it.syntax,
2859 Type::ParenType(it) => &it.syntax, 2859 Type::ParenType(it) => &it.syntax,
2860 Type::PathType(it) => &it.syntax, 2860 Type::PathType(it) => &it.syntax,
2861 Type::PointerType(it) => &it.syntax, 2861 Type::PtrType(it) => &it.syntax,
2862 Type::ReferenceType(it) => &it.syntax, 2862 Type::RefType(it) => &it.syntax,
2863 Type::SliceType(it) => &it.syntax, 2863 Type::SliceType(it) => &it.syntax,
2864 Type::TupleType(it) => &it.syntax, 2864 Type::TupleType(it) => &it.syntax,
2865 } 2865 }
@@ -3332,24 +3332,24 @@ impl AstNode for AssocItem {
3332impl From<Fn> for ExternItem { 3332impl From<Fn> for ExternItem {
3333 fn from(node: Fn) -> ExternItem { ExternItem::Fn(node) } 3333 fn from(node: Fn) -> ExternItem { ExternItem::Fn(node) }
3334} 3334}
3335impl From<Static> for ExternItem {
3336 fn from(node: Static) -> ExternItem { ExternItem::Static(node) }
3337}
3338impl From<MacroCall> for ExternItem { 3335impl From<MacroCall> for ExternItem {
3339 fn from(node: MacroCall) -> ExternItem { ExternItem::MacroCall(node) } 3336 fn from(node: MacroCall) -> ExternItem { ExternItem::MacroCall(node) }
3340} 3337}
3338impl From<Static> for ExternItem {
3339 fn from(node: Static) -> ExternItem { ExternItem::Static(node) }
3340}
3341impl AstNode for ExternItem { 3341impl AstNode for ExternItem {
3342 fn can_cast(kind: SyntaxKind) -> bool { 3342 fn can_cast(kind: SyntaxKind) -> bool {
3343 match kind { 3343 match kind {
3344 FN | STATIC | MACRO_CALL => true, 3344 FN | MACRO_CALL | STATIC => true,
3345 _ => false, 3345 _ => false,
3346 } 3346 }
3347 } 3347 }
3348 fn cast(syntax: SyntaxNode) -> Option<Self> { 3348 fn cast(syntax: SyntaxNode) -> Option<Self> {
3349 let res = match syntax.kind() { 3349 let res = match syntax.kind() {
3350 FN => ExternItem::Fn(Fn { syntax }), 3350 FN => ExternItem::Fn(Fn { syntax }),
3351 STATIC => ExternItem::Static(Static { syntax }),
3352 MACRO_CALL => ExternItem::MacroCall(MacroCall { syntax }), 3351 MACRO_CALL => ExternItem::MacroCall(MacroCall { syntax }),
3352 STATIC => ExternItem::Static(Static { syntax }),
3353 _ => return None, 3353 _ => return None,
3354 }; 3354 };
3355 Some(res) 3355 Some(res)
@@ -3357,8 +3357,8 @@ impl AstNode for ExternItem {
3357 fn syntax(&self) -> &SyntaxNode { 3357 fn syntax(&self) -> &SyntaxNode {
3358 match self { 3358 match self {
3359 ExternItem::Fn(it) => &it.syntax, 3359 ExternItem::Fn(it) => &it.syntax,
3360 ExternItem::Static(it) => &it.syntax,
3361 ExternItem::MacroCall(it) => &it.syntax, 3360 ExternItem::MacroCall(it) => &it.syntax,
3361 ExternItem::Static(it) => &it.syntax,
3362 } 3362 }
3363 } 3363 }
3364} 3364}
@@ -3925,7 +3925,7 @@ impl std::fmt::Display for DynTraitType {
3925 std::fmt::Display::fmt(self.syntax(), f) 3925 std::fmt::Display::fmt(self.syntax(), f)
3926 } 3926 }
3927} 3927}
3928impl std::fmt::Display for FnPointerType { 3928impl std::fmt::Display for FnPtrType {
3929 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { 3929 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
3930 std::fmt::Display::fmt(self.syntax(), f) 3930 std::fmt::Display::fmt(self.syntax(), f)
3931 } 3931 }
@@ -3955,12 +3955,12 @@ impl std::fmt::Display for ParenType {
3955 std::fmt::Display::fmt(self.syntax(), f) 3955 std::fmt::Display::fmt(self.syntax(), f)
3956 } 3956 }
3957} 3957}
3958impl std::fmt::Display for PointerType { 3958impl std::fmt::Display for PtrType {
3959 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { 3959 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
3960 std::fmt::Display::fmt(self.syntax(), f) 3960 std::fmt::Display::fmt(self.syntax(), f)
3961 } 3961 }
3962} 3962}
3963impl std::fmt::Display for ReferenceType { 3963impl std::fmt::Display for RefType {
3964 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { 3964 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
3965 std::fmt::Display::fmt(self.syntax(), f) 3965 std::fmt::Display::fmt(self.syntax(), f)
3966 } 3966 }
diff --git a/crates/ra_syntax/src/ast/make.rs b/crates/ra_syntax/src/ast/make.rs
index 673777015..254a37fe3 100644
--- a/crates/ra_syntax/src/ast/make.rs
+++ b/crates/ra_syntax/src/ast/make.rs
@@ -17,7 +17,7 @@ pub fn name_ref(text: &str) -> ast::NameRef {
17 ast_from_text(&format!("fn f() {{ {}; }}", text)) 17 ast_from_text(&format!("fn f() {{ {}; }}", text))
18} 18}
19 19
20pub fn type_ref(text: &str) -> ast::Type { 20pub fn ty(text: &str) -> ast::Type {
21 ast_from_text(&format!("impl {} for D {{}};", text)) 21 ast_from_text(&format!("impl {} for D {{}};", text))
22} 22}
23 23
@@ -30,7 +30,7 @@ pub fn path_unqualified(segment: ast::PathSegment) -> ast::Path {
30pub fn path_qualified(qual: ast::Path, segment: ast::PathSegment) -> ast::Path { 30pub fn path_qualified(qual: ast::Path, segment: ast::PathSegment) -> ast::Path {
31 path_from_text(&format!("{}::{}", qual, segment)) 31 path_from_text(&format!("{}::{}", qual, segment))
32} 32}
33fn path_from_text(text: &str) -> ast::Path { 33pub fn path_from_text(text: &str) -> ast::Path {
34 ast_from_text(text) 34 ast_from_text(text)
35} 35}
36 36
@@ -60,11 +60,11 @@ 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::Use { 63pub fn use_(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::RecordExprField { 67pub fn record_expr_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()),
@@ -75,7 +75,7 @@ pub fn record_field(name: ast::NameRef, expr: Option<ast::Expr>) -> ast::RecordE
75 } 75 }
76} 76}
77 77
78pub fn record_field_def(name: ast::NameRef, ty: ast::Type) -> ast::RecordField { 78pub fn record_field(name: ast::NameRef, ty: ast::Type) -> ast::RecordField {
79 ast_from_text(&format!("struct S {{ {}: {}, }}", name, ty)) 79 ast_from_text(&format!("struct S {{ {}: {}, }}", name, ty))
80} 80}
81 81
@@ -148,7 +148,7 @@ pub fn condition(expr: ast::Expr, pattern: Option<ast::Pat>) -> ast::Condition {
148 } 148 }
149} 149}
150 150
151pub fn bind_pat(name: ast::Name) -> ast::IdentPat { 151pub fn ident_pat(name: ast::Name) -> ast::IdentPat {
152 return from_text(name.text()); 152 return from_text(name.text());
153 153
154 fn from_text(text: &str) -> ast::IdentPat { 154 fn from_text(text: &str) -> ast::IdentPat {
@@ -156,7 +156,7 @@ pub fn bind_pat(name: ast::Name) -> ast::IdentPat {
156 } 156 }
157} 157}
158 158
159pub fn placeholder_pat() -> ast::WildcardPat { 159pub fn wildcard_pat() -> ast::WildcardPat {
160 return from_text("_"); 160 return from_text("_");
161 161
162 fn from_text(text: &str) -> ast::WildcardPat { 162 fn from_text(text: &str) -> ast::WildcardPat {
@@ -288,7 +288,7 @@ pub fn visibility_pub_crate() -> ast::Visibility {
288 ast_from_text("pub(crate) struct S") 288 ast_from_text("pub(crate) struct S")
289} 289}
290 290
291pub fn fn_def( 291pub fn fn_(
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::GenericParamList>, 294 type_params: Option<ast::GenericParamList>,
diff --git a/crates/ra_syntax/src/ast/traits.rs b/crates/ra_syntax/src/ast/traits.rs
index 3a56b1674..0bdc22d95 100644
--- a/crates/ra_syntax/src/ast/traits.rs
+++ b/crates/ra_syntax/src/ast/traits.rs
@@ -1,7 +1,7 @@
1//! Various traits that are implemented by ast nodes. 1//! Various traits that are implemented by ast nodes.
2//! 2//!
3//! The implementations are usually trivial, and live in generated.rs 3//! The implementations are usually trivial, and live in generated.rs
4use stdx::SepBy; 4use itertools::Itertools;
5 5
6use crate::{ 6use crate::{
7 ast::{self, support, AstChildren, AstNode, AstToken}, 7 ast::{self, support, AstChildren, AstNode, AstToken},
@@ -119,8 +119,7 @@ impl CommentIter {
119 // of a line in markdown. 119 // of a line in markdown.
120 line[pos..end].to_owned() 120 line[pos..end].to_owned()
121 }) 121 })
122 .sep_by("\n") 122 .join("\n");
123 .to_string();
124 123
125 if has_comments { 124 if has_comments {
126 Some(docs) 125 Some(docs)