aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_hir/src/nameres.rs
diff options
context:
space:
mode:
Diffstat (limited to 'crates/ra_hir/src/nameres.rs')
-rw-r--r--crates/ra_hir/src/nameres.rs24
1 files changed, 12 insertions, 12 deletions
diff --git a/crates/ra_hir/src/nameres.rs b/crates/ra_hir/src/nameres.rs
index 4efafd409..4874e82f3 100644
--- a/crates/ra_hir/src/nameres.rs
+++ b/crates/ra_hir/src/nameres.rs
@@ -221,10 +221,10 @@ where
221 }; 221 };
222 } 222 }
223 for (import_id, import_data) in input.imports.iter() { 223 for (import_id, import_data) in input.imports.iter() {
224 if let Some(name) = import_data.path.segments.iter().last() { 224 if let Some(segment) = import_data.path.segments.iter().last() {
225 if !import_data.is_glob { 225 if !import_data.is_glob {
226 module_items.items.insert( 226 module_items.items.insert(
227 name.clone(), 227 segment.name.clone(),
228 Resolution { 228 Resolution {
229 def_id: PerNs::none(), 229 def_id: PerNs::none(),
230 import: Some(import_id), 230 import: Some(import_id),
@@ -319,13 +319,13 @@ where
319 PathKind::Crate => module_id.crate_root(&self.module_tree), 319 PathKind::Crate => module_id.crate_root(&self.module_tree),
320 }; 320 };
321 321
322 for (i, name) in import.path.segments.iter().enumerate() { 322 for (i, segment) in import.path.segments.iter().enumerate() {
323 let is_last = i == import.path.segments.len() - 1; 323 let is_last = i == import.path.segments.len() - 1;
324 324
325 let def_id = match self.result.per_module[&curr].items.get(name) { 325 let def_id = match self.result.per_module[&curr].items.get(&segment.name) {
326 Some(res) if !res.def_id.is_none() => res.def_id, 326 Some(res) if !res.def_id.is_none() => res.def_id,
327 _ => { 327 _ => {
328 log::debug!("path segment {:?} not found", name); 328 log::debug!("path segment {:?} not found", segment.name);
329 return false; 329 return false;
330 } 330 }
331 }; 331 };
@@ -336,7 +336,7 @@ where
336 } else { 336 } else {
337 log::debug!( 337 log::debug!(
338 "path segment {:?} resolved to value only, but is not last", 338 "path segment {:?} resolved to value only, but is not last",
339 name 339 segment.name
340 ); 340 );
341 return false; 341 return false;
342 }; 342 };
@@ -358,17 +358,17 @@ where
358 log::debug!("resolving {:?} in other source root", path); 358 log::debug!("resolving {:?} in other source root", path);
359 let def_id = module.resolve_path(self.db, &path); 359 let def_id = module.resolve_path(self.db, &path);
360 if !def_id.is_none() { 360 if !def_id.is_none() {
361 let name = path.segments.last().unwrap(); 361 let last_segment = path.segments.last().unwrap();
362 self.update(module_id, |items| { 362 self.update(module_id, |items| {
363 let res = Resolution { 363 let res = Resolution {
364 def_id, 364 def_id,
365 import: Some(import_id), 365 import: Some(import_id),
366 }; 366 };
367 items.items.insert(name.clone(), res); 367 items.items.insert(last_segment.name.clone(), res);
368 }); 368 });
369 log::debug!( 369 log::debug!(
370 "resolved import {:?} ({:?}) cross-source root to {:?}", 370 "resolved import {:?} ({:?}) cross-source root to {:?}",
371 name, 371 last_segment.name,
372 import, 372 import,
373 def_id.map(|did| did.loc(self.db)) 373 def_id.map(|did| did.loc(self.db))
374 ); 374 );
@@ -382,7 +382,7 @@ where
382 _ => { 382 _ => {
383 log::debug!( 383 log::debug!(
384 "path segment {:?} resolved to non-module {:?}, but is not last", 384 "path segment {:?} resolved to non-module {:?}, but is not last",
385 name, 385 segment.name,
386 type_def_id.loc(self.db) 386 type_def_id.loc(self.db)
387 ); 387 );
388 return true; // this resolved to a non-module, so the path won't ever resolve 388 return true; // this resolved to a non-module, so the path won't ever resolve
@@ -391,7 +391,7 @@ where
391 } else { 391 } else {
392 log::debug!( 392 log::debug!(
393 "resolved import {:?} ({:?}) within source root to {:?}", 393 "resolved import {:?} ({:?}) within source root to {:?}",
394 name, 394 segment.name,
395 import, 395 import,
396 def_id.map(|did| did.loc(self.db)) 396 def_id.map(|did| did.loc(self.db))
397 ); 397 );
@@ -400,7 +400,7 @@ where
400 def_id, 400 def_id,
401 import: Some(import_id), 401 import: Some(import_id),
402 }; 402 };
403 items.items.insert(name.clone(), res); 403 items.items.insert(segment.name.clone(), res);
404 }) 404 })
405 } 405 }
406 } 406 }