aboutsummaryrefslogtreecommitdiff
path: root/crates/hir_expand
diff options
context:
space:
mode:
authorbors[bot] <26634292+bors[bot]@users.noreply.github.com>2021-02-17 13:45:27 +0000
committerGitHub <[email protected]>2021-02-17 13:45:27 +0000
commit4054525c418085db4ceb2df70475a1ac9c019aff (patch)
tree64adbc8c62df3a6ebbe8c1a799589a94ddfbf490 /crates/hir_expand
parent056601b41fbc5208cae5d996ec7fd18526d79e41 (diff)
parente1dbf43cf85f84c3a7e40f9731fc1f7ac96f8979 (diff)
Merge #7699
7699: Implement ast::AstNode for NameLike and move it to node_ext r=matklad a=Veykril With this `search`(and 2 other modules) don't necessarily go through 3 calls of `find_node_at_offset_with_descend` to find the correct node. Also makes the code that searches for NameLikes a bit easier on the eyes imo, though that can be fixed with just a helper function as well so its not that relevant. Co-authored-by: Lukas Wirth <[email protected]>
Diffstat (limited to 'crates/hir_expand')
-rw-r--r--crates/hir_expand/src/name.rs13
1 files changed, 10 insertions, 3 deletions
diff --git a/crates/hir_expand/src/name.rs b/crates/hir_expand/src/name.rs
index c7609e90d..74cf64aab 100644
--- a/crates/hir_expand/src/name.rs
+++ b/crates/hir_expand/src/name.rs
@@ -87,11 +87,18 @@ impl AsName for ast::Name {
87 } 87 }
88} 88}
89 89
90impl AsName for ast::NameOrNameRef { 90impl AsName for ast::Lifetime {
91 fn as_name(&self) -> Name {
92 Name::resolve(self.text())
93 }
94}
95
96impl AsName for ast::NameLike {
91 fn as_name(&self) -> Name { 97 fn as_name(&self) -> Name {
92 match self { 98 match self {
93 ast::NameOrNameRef::Name(it) => it.as_name(), 99 ast::NameLike::Name(it) => it.as_name(),
94 ast::NameOrNameRef::NameRef(it) => it.as_name(), 100 ast::NameLike::NameRef(it) => it.as_name(),
101 ast::NameLike::Lifetime(it) => it.as_name(),
95 } 102 }
96 } 103 }
97} 104}