diff options
author | Aleksey Kladov <[email protected]> | 2020-07-30 19:51:43 +0100 |
---|---|---|
committer | Aleksey Kladov <[email protected]> | 2020-07-30 19:51:43 +0100 |
commit | 2e2642efccd5855e4158b01a006e7884a96982bb (patch) | |
tree | de4342a453b3b504178dd17c46fab3e1d6e995d2 /crates/ra_ide/src/file_structure.rs | |
parent | fbe60a2e284035d16c2a1ee743ee88db418689aa (diff) |
Remove TypeAscriptionOwner
Diffstat (limited to 'crates/ra_ide/src/file_structure.rs')
-rw-r--r-- | crates/ra_ide/src/file_structure.rs | 28 |
1 files changed, 9 insertions, 19 deletions
diff --git a/crates/ra_ide/src/file_structure.rs b/crates/ra_ide/src/file_structure.rs index 7d378f2d0..22cf8637a 100644 --- a/crates/ra_ide/src/file_structure.rs +++ b/crates/ra_ide/src/file_structure.rs | |||
@@ -1,5 +1,5 @@ | |||
1 | use ra_syntax::{ | 1 | use ra_syntax::{ |
2 | ast::{self, AttrsOwner, GenericParamsOwner, NameOwner, TypeAscriptionOwner}, | 2 | ast::{self, AttrsOwner, GenericParamsOwner, NameOwner}, |
3 | match_ast, AstNode, SourceFile, SyntaxKind, SyntaxNode, TextRange, WalkEvent, | 3 | match_ast, AstNode, SourceFile, SyntaxKind, SyntaxNode, TextRange, WalkEvent, |
4 | }; | 4 | }; |
5 | 5 | ||
@@ -52,18 +52,11 @@ pub fn file_structure(file: &SourceFile) -> Vec<StructureNode> { | |||
52 | 52 | ||
53 | fn structure_node(node: &SyntaxNode) -> Option<StructureNode> { | 53 | fn structure_node(node: &SyntaxNode) -> Option<StructureNode> { |
54 | fn decl<N: NameOwner + AttrsOwner>(node: N) -> Option<StructureNode> { | 54 | fn decl<N: NameOwner + AttrsOwner>(node: N) -> Option<StructureNode> { |
55 | decl_with_detail(node, None) | 55 | decl_with_detail(&node, None) |
56 | } | ||
57 | |||
58 | fn decl_with_ascription<N: NameOwner + AttrsOwner + TypeAscriptionOwner>( | ||
59 | node: N, | ||
60 | ) -> Option<StructureNode> { | ||
61 | let ty = node.ascribed_type(); | ||
62 | decl_with_type_ref(node, ty) | ||
63 | } | 56 | } |
64 | 57 | ||
65 | fn decl_with_type_ref<N: NameOwner + AttrsOwner>( | 58 | fn decl_with_type_ref<N: NameOwner + AttrsOwner>( |
66 | node: N, | 59 | node: &N, |
67 | type_ref: Option<ast::TypeRef>, | 60 | type_ref: Option<ast::TypeRef>, |
68 | ) -> Option<StructureNode> { | 61 | ) -> Option<StructureNode> { |
69 | let detail = type_ref.map(|type_ref| { | 62 | let detail = type_ref.map(|type_ref| { |
@@ -75,7 +68,7 @@ fn structure_node(node: &SyntaxNode) -> Option<StructureNode> { | |||
75 | } | 68 | } |
76 | 69 | ||
77 | fn decl_with_detail<N: NameOwner + AttrsOwner>( | 70 | fn decl_with_detail<N: NameOwner + AttrsOwner>( |
78 | node: N, | 71 | node: &N, |
79 | detail: Option<String>, | 72 | detail: Option<String>, |
80 | ) -> Option<StructureNode> { | 73 | ) -> Option<StructureNode> { |
81 | let name = node.name()?; | 74 | let name = node.name()?; |
@@ -124,7 +117,7 @@ fn structure_node(node: &SyntaxNode) -> Option<StructureNode> { | |||
124 | collapse_ws(ret_type.syntax(), &mut detail); | 117 | collapse_ws(ret_type.syntax(), &mut detail); |
125 | } | 118 | } |
126 | 119 | ||
127 | decl_with_detail(it, Some(detail)) | 120 | decl_with_detail(&it, Some(detail)) |
128 | }, | 121 | }, |
129 | ast::Struct(it) => decl(it), | 122 | ast::Struct(it) => decl(it), |
130 | ast::Union(it) => decl(it), | 123 | ast::Union(it) => decl(it), |
@@ -132,13 +125,10 @@ fn structure_node(node: &SyntaxNode) -> Option<StructureNode> { | |||
132 | ast::Variant(it) => decl(it), | 125 | ast::Variant(it) => decl(it), |
133 | ast::Trait(it) => decl(it), | 126 | ast::Trait(it) => decl(it), |
134 | ast::Module(it) => decl(it), | 127 | ast::Module(it) => decl(it), |
135 | ast::TypeAlias(it) => { | 128 | ast::TypeAlias(it) => decl_with_type_ref(&it, it.type_ref()), |
136 | let ty = it.type_ref(); | 129 | ast::RecordField(it) => decl_with_type_ref(&it, it.ty()), |
137 | decl_with_type_ref(it, ty) | 130 | ast::Const(it) => decl_with_type_ref(&it, it.ty()), |
138 | }, | 131 | ast::Static(it) => decl_with_type_ref(&it, it.ty()), |
139 | ast::RecordField(it) => decl_with_ascription(it), | ||
140 | ast::Const(it) => decl_with_ascription(it), | ||
141 | ast::Static(it) => decl_with_ascription(it), | ||
142 | ast::Impl(it) => { | 132 | ast::Impl(it) => { |
143 | let target_type = it.target_type()?; | 133 | let target_type = it.target_type()?; |
144 | let target_trait = it.target_trait(); | 134 | let target_trait = it.target_trait(); |