aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_hir_def/src/nameres
diff options
context:
space:
mode:
authorbors[bot] <26634292+bors[bot]@users.noreply.github.com>2019-12-22 21:42:54 +0000
committerGitHub <[email protected]>2019-12-22 21:42:54 +0000
commit60aa4d12f95477565d5b01f122d2c9dd845015b4 (patch)
tree86f6d29653ba7e548f2a321b2ecdb20e7dc366f4 /crates/ra_hir_def/src/nameres
parent78f7683b9a1c6192b4828ceedb14ed498b241263 (diff)
parente424545c0f5cbaf135c52764169ea20df7d07d35 (diff)
Merge #2648
2648: Rudimentary name resolution for local items r=matklad a=matklad Co-authored-by: Aleksey Kladov <[email protected]>
Diffstat (limited to 'crates/ra_hir_def/src/nameres')
-rw-r--r--crates/ra_hir_def/src/nameres/collector.rs2
-rw-r--r--crates/ra_hir_def/src/nameres/path_resolution.rs15
2 files changed, 5 insertions, 12 deletions
diff --git a/crates/ra_hir_def/src/nameres/collector.rs b/crates/ra_hir_def/src/nameres/collector.rs
index 4f1fd4801..b9f40d3dd 100644
--- a/crates/ra_hir_def/src/nameres/collector.rs
+++ b/crates/ra_hir_def/src/nameres/collector.rs
@@ -446,7 +446,7 @@ where
446 let scope = &mut self.def_map.modules[module_id].scope; 446 let scope = &mut self.def_map.modules[module_id].scope;
447 let mut changed = false; 447 let mut changed = false;
448 for (name, res) in resolutions { 448 for (name, res) in resolutions {
449 changed |= scope.push_res(name.clone(), res); 449 changed |= scope.push_res(name.clone(), *res);
450 } 450 }
451 451
452 if !changed { 452 if !changed {
diff --git a/crates/ra_hir_def/src/nameres/path_resolution.rs b/crates/ra_hir_def/src/nameres/path_resolution.rs
index 378d49455..695014c7b 100644
--- a/crates/ra_hir_def/src/nameres/path_resolution.rs
+++ b/crates/ra_hir_def/src/nameres/path_resolution.rs
@@ -180,13 +180,7 @@ impl CrateDefMap {
180 } 180 }
181 181
182 // Since it is a qualified path here, it should not contains legacy macros 182 // Since it is a qualified path here, it should not contains legacy macros
183 match self[module.local_id].scope.get(&segment, prefer_module(i)) { 183 self[module.local_id].scope.get(&segment, prefer_module(i))
184 Some(def) => *def,
185 _ => {
186 log::debug!("path segment {:?} not found", segment);
187 return ResolvePathResult::empty(ReachedFixedPoint::No);
188 }
189 }
190 } 184 }
191 ModuleDefId::AdtId(AdtId::EnumId(e)) => { 185 ModuleDefId::AdtId(AdtId::EnumId(e)) => {
192 // enum variant 186 // enum variant
@@ -243,7 +237,7 @@ impl CrateDefMap {
243 // - std prelude 237 // - std prelude
244 let from_legacy_macro = 238 let from_legacy_macro =
245 self[module].scope.get_legacy_macro(name).map_or_else(PerNs::none, PerNs::macros); 239 self[module].scope.get_legacy_macro(name).map_or_else(PerNs::none, PerNs::macros);
246 let from_scope = self[module].scope.get(name, shadow).copied().unwrap_or_else(PerNs::none); 240 let from_scope = self[module].scope.get(name, shadow);
247 let from_extern_prelude = 241 let from_extern_prelude =
248 self.extern_prelude.get(name).map_or(PerNs::none(), |&it| PerNs::types(it)); 242 self.extern_prelude.get(name).map_or(PerNs::none(), |&it| PerNs::types(it));
249 let from_prelude = self.resolve_in_prelude(db, name, shadow); 243 let from_prelude = self.resolve_in_prelude(db, name, shadow);
@@ -256,8 +250,7 @@ impl CrateDefMap {
256 name: &Name, 250 name: &Name,
257 shadow: BuiltinShadowMode, 251 shadow: BuiltinShadowMode,
258 ) -> PerNs { 252 ) -> PerNs {
259 let from_crate_root = 253 let from_crate_root = self[self.root].scope.get(name, shadow);
260 self[self.root].scope.get(name, shadow).copied().unwrap_or_else(PerNs::none);
261 let from_extern_prelude = self.resolve_name_in_extern_prelude(name); 254 let from_extern_prelude = self.resolve_name_in_extern_prelude(name);
262 255
263 from_crate_root.or(from_extern_prelude) 256 from_crate_root.or(from_extern_prelude)
@@ -278,7 +271,7 @@ impl CrateDefMap {
278 keep = db.crate_def_map(prelude.krate); 271 keep = db.crate_def_map(prelude.krate);
279 &keep 272 &keep
280 }; 273 };
281 def_map[prelude.local_id].scope.get(name, shadow).copied().unwrap_or_else(PerNs::none) 274 def_map[prelude.local_id].scope.get(name, shadow)
282 } else { 275 } else {
283 PerNs::none() 276 PerNs::none()
284 } 277 }