diff options
Diffstat (limited to 'crates/ra_hir_def/src/nameres')
-rw-r--r-- | crates/ra_hir_def/src/nameres/collector.rs | 2 | ||||
-rw-r--r-- | crates/ra_hir_def/src/nameres/path_resolution.rs | 26 |
2 files changed, 20 insertions, 8 deletions
diff --git a/crates/ra_hir_def/src/nameres/collector.rs b/crates/ra_hir_def/src/nameres/collector.rs index 912a073ea..8bbf7ffa2 100644 --- a/crates/ra_hir_def/src/nameres/collector.rs +++ b/crates/ra_hir_def/src/nameres/collector.rs | |||
@@ -890,7 +890,7 @@ where | |||
890 | // We rewrite simple path `macro_name` to `self::macro_name` to force resolve in module scope only. | 890 | // We rewrite simple path `macro_name` to `self::macro_name` to force resolve in module scope only. |
891 | let mut path = mac.path.clone(); | 891 | let mut path = mac.path.clone(); |
892 | if path.is_ident() { | 892 | if path.is_ident() { |
893 | path.kind = PathKind::Self_; | 893 | path.kind = PathKind::Super(0); |
894 | } | 894 | } |
895 | 895 | ||
896 | self.def_collector.unexpanded_macros.push(MacroDirective { | 896 | self.def_collector.unexpanded_macros.push(MacroDirective { |
diff --git a/crates/ra_hir_def/src/nameres/path_resolution.rs b/crates/ra_hir_def/src/nameres/path_resolution.rs index 4a249e7e7..a3bfc1542 100644 --- a/crates/ra_hir_def/src/nameres/path_resolution.rs +++ b/crates/ra_hir_def/src/nameres/path_resolution.rs | |||
@@ -10,6 +10,8 @@ | |||
10 | //! | 10 | //! |
11 | //! `ReachedFixedPoint` signals about this. | 11 | //! `ReachedFixedPoint` signals about this. |
12 | 12 | ||
13 | use std::iter::successors; | ||
14 | |||
13 | use hir_expand::name::Name; | 15 | use hir_expand::name::Name; |
14 | use ra_db::Edition; | 16 | use ra_db::Edition; |
15 | use test_utils::tested_by; | 17 | use test_utils::tested_by; |
@@ -97,9 +99,6 @@ impl CrateDefMap { | |||
97 | PathKind::Crate => { | 99 | PathKind::Crate => { |
98 | PerNs::types(ModuleId { krate: self.krate, local_id: self.root }.into()) | 100 | PerNs::types(ModuleId { krate: self.krate, local_id: self.root }.into()) |
99 | } | 101 | } |
100 | PathKind::Self_ => { | ||
101 | PerNs::types(ModuleId { krate: self.krate, local_id: original_module }.into()) | ||
102 | } | ||
103 | // plain import or absolute path in 2015: crate-relative with | 102 | // plain import or absolute path in 2015: crate-relative with |
104 | // fallback to extern prelude (with the simplification in | 103 | // fallback to extern prelude (with the simplification in |
105 | // rust-lang/rust#57745) | 104 | // rust-lang/rust#57745) |
@@ -123,9 +122,22 @@ impl CrateDefMap { | |||
123 | log::debug!("resolving {:?} in module", segment); | 122 | log::debug!("resolving {:?} in module", segment); |
124 | self.resolve_name_in_module(db, original_module, &segment, prefer_module(idx)) | 123 | self.resolve_name_in_module(db, original_module, &segment, prefer_module(idx)) |
125 | } | 124 | } |
126 | PathKind::Super => { | 125 | // PathKind::Self_ => { |
127 | if let Some(p) = self.modules[original_module].parent { | 126 | // PerNs::types(ModuleId { krate: self.krate, local_id: original_module }.into()) |
128 | PerNs::types(ModuleId { krate: self.krate, local_id: p }.into()) | 127 | // } |
128 | // PathKind::Super => { | ||
129 | // if let Some(p) = self.modules[original_module].parent { | ||
130 | // PerNs::types(ModuleId { krate: self.krate, local_id: p }.into()) | ||
131 | // } else { | ||
132 | // log::debug!("super path in root module"); | ||
133 | // return ResolvePathResult::empty(ReachedFixedPoint::Yes); | ||
134 | // } | ||
135 | // } | ||
136 | PathKind::Super(lvl) => { | ||
137 | let m = successors(Some(original_module), |m| self.modules[*m].parent) | ||
138 | .nth(lvl as usize); | ||
139 | if let Some(local_id) = m { | ||
140 | PerNs::types(ModuleId { krate: self.krate, local_id }.into()) | ||
129 | } else { | 141 | } else { |
130 | log::debug!("super path in root module"); | 142 | log::debug!("super path in root module"); |
131 | return ResolvePathResult::empty(ReachedFixedPoint::Yes); | 143 | return ResolvePathResult::empty(ReachedFixedPoint::Yes); |
@@ -170,7 +182,7 @@ impl CrateDefMap { | |||
170 | if module.krate != self.krate { | 182 | if module.krate != self.krate { |
171 | let path = ModPath { | 183 | let path = ModPath { |
172 | segments: path.segments[i..].to_vec(), | 184 | segments: path.segments[i..].to_vec(), |
173 | kind: PathKind::Self_, | 185 | kind: PathKind::Super(0), |
174 | }; | 186 | }; |
175 | log::debug!("resolving {:?} in other crate", path); | 187 | log::debug!("resolving {:?} in other crate", path); |
176 | let defp_map = db.crate_def_map(module.krate); | 188 | let defp_map = db.crate_def_map(module.krate); |