diff options
Diffstat (limited to 'crates/hir_def/src/path')
-rw-r--r-- | crates/hir_def/src/path/lower.rs | 14 |
1 files changed, 5 insertions, 9 deletions
diff --git a/crates/hir_def/src/path/lower.rs b/crates/hir_def/src/path/lower.rs index 3b3a3738f..a873325b2 100644 --- a/crates/hir_def/src/path/lower.rs +++ b/crates/hir_def/src/path/lower.rs | |||
@@ -2,7 +2,7 @@ | |||
2 | 2 | ||
3 | mod lower_use; | 3 | mod lower_use; |
4 | 4 | ||
5 | use crate::{db::DefDatabase, intern::Interned}; | 5 | use crate::intern::Interned; |
6 | use std::sync::Arc; | 6 | use std::sync::Arc; |
7 | 7 | ||
8 | use either::Either; | 8 | use either::Either; |
@@ -20,11 +20,7 @@ pub(super) use lower_use::lower_use_tree; | |||
20 | 20 | ||
21 | /// Converts an `ast::Path` to `Path`. Works with use trees. | 21 | /// Converts an `ast::Path` to `Path`. Works with use trees. |
22 | /// It correctly handles `$crate` based path from macro call. | 22 | /// It correctly handles `$crate` based path from macro call. |
23 | pub(super) fn lower_path( | 23 | pub(super) fn lower_path(mut path: ast::Path, ctx: &LowerCtx) -> Option<Path> { |
24 | db: &dyn DefDatabase, | ||
25 | mut path: ast::Path, | ||
26 | ctx: &LowerCtx, | ||
27 | ) -> Option<Path> { | ||
28 | let mut kind = PathKind::Plain; | 24 | let mut kind = PathKind::Plain; |
29 | let mut type_anchor = None; | 25 | let mut type_anchor = None; |
30 | let mut segments = Vec::new(); | 26 | let mut segments = Vec::new(); |
@@ -40,7 +36,7 @@ pub(super) fn lower_path( | |||
40 | match segment.kind()? { | 36 | match segment.kind()? { |
41 | ast::PathSegmentKind::Name(name_ref) => { | 37 | ast::PathSegmentKind::Name(name_ref) => { |
42 | // FIXME: this should just return name | 38 | // FIXME: this should just return name |
43 | match hygiene.name_ref_to_name(db.upcast(), name_ref) { | 39 | match hygiene.name_ref_to_name(ctx.db.upcast(), name_ref) { |
44 | Either::Left(name) => { | 40 | Either::Left(name) => { |
45 | let args = segment | 41 | let args = segment |
46 | .generic_arg_list() | 42 | .generic_arg_list() |
@@ -75,7 +71,7 @@ pub(super) fn lower_path( | |||
75 | } | 71 | } |
76 | // <T as Trait<A>>::Foo desugars to Trait<Self=T, A>::Foo | 72 | // <T as Trait<A>>::Foo desugars to Trait<Self=T, A>::Foo |
77 | Some(trait_ref) => { | 73 | Some(trait_ref) => { |
78 | let path = Path::from_src(db, trait_ref.path()?, ctx)?; | 74 | let path = Path::from_src(trait_ref.path()?, ctx)?; |
79 | let mod_path = (*path.mod_path).clone(); | 75 | let mod_path = (*path.mod_path).clone(); |
80 | let num_segments = path.mod_path.segments.len(); | 76 | let num_segments = path.mod_path.segments.len(); |
81 | kind = mod_path.kind; | 77 | kind = mod_path.kind; |
@@ -137,7 +133,7 @@ pub(super) fn lower_path( | |||
137 | // We follow what it did anyway :) | 133 | // We follow what it did anyway :) |
138 | if segments.len() == 1 && kind == PathKind::Plain { | 134 | if segments.len() == 1 && kind == PathKind::Plain { |
139 | if let Some(_macro_call) = path.syntax().parent().and_then(ast::MacroCall::cast) { | 135 | if let Some(_macro_call) = path.syntax().parent().and_then(ast::MacroCall::cast) { |
140 | if let Some(crate_id) = hygiene.local_inner_macros(db.upcast(), path) { | 136 | if let Some(crate_id) = hygiene.local_inner_macros(ctx.db.upcast(), path) { |
141 | kind = PathKind::DollarCrate(crate_id); | 137 | kind = PathKind::DollarCrate(crate_id); |
142 | } | 138 | } |
143 | } | 139 | } |