aboutsummaryrefslogtreecommitdiff
path: root/crates/hir_def/src/nameres
diff options
context:
space:
mode:
authorbors[bot] <26634292+bors[bot]@users.noreply.github.com>2020-09-17 14:27:50 +0100
committerGitHub <[email protected]>2020-09-17 14:27:50 +0100
commit7af7e1f25322b723fbaf0b2477b2b0716905f619 (patch)
tree939afa0f475610c3b618b7366ffd05101334c8c8 /crates/hir_def/src/nameres
parentd84c18d989d07785127d00395b929fc69eca19e6 (diff)
parent6eea06415d96012b01204611a65159b1a251a99d (diff)
Merge #6024
6024: Give `ExternCrate` a `Name`, not a `ModPath` r=jonas-schievink a=jonas-schievink Simplifies things Co-authored-by: Jonas Schievink <[email protected]>
Diffstat (limited to 'crates/hir_def/src/nameres')
-rw-r--r--crates/hir_def/src/nameres/collector.rs17
1 files changed, 7 insertions, 10 deletions
diff --git a/crates/hir_def/src/nameres/collector.rs b/crates/hir_def/src/nameres/collector.rs
index 818008169..c1e1d53f6 100644
--- a/crates/hir_def/src/nameres/collector.rs
+++ b/crates/hir_def/src/nameres/collector.rs
@@ -3,6 +3,8 @@
3//! `DefCollector::collect` contains the fixed-point iteration loop which 3//! `DefCollector::collect` contains the fixed-point iteration loop which
4//! resolves imports and expands macros. 4//! resolves imports and expands macros.
5 5
6use std::iter;
7
6use base_db::{CrateId, FileId, ProcMacroId}; 8use base_db::{CrateId, FileId, ProcMacroId};
7use cfg::CfgOptions; 9use cfg::CfgOptions;
8use hir_expand::InFile; 10use hir_expand::InFile;
@@ -149,7 +151,7 @@ impl Import {
149 let it = &tree[id.value]; 151 let it = &tree[id.value];
150 let visibility = &tree[it.visibility]; 152 let visibility = &tree[it.visibility];
151 Self { 153 Self {
152 path: it.path.clone(), 154 path: ModPath::from_segments(PathKind::Plain, iter::once(it.name.clone())),
153 alias: it.alias.clone(), 155 alias: it.alias.clone(),
154 visibility: visibility.clone(), 156 visibility: visibility.clone(),
155 is_glob: false, 157 is_glob: false,
@@ -356,20 +358,15 @@ impl DefCollector<'_> {
356 fn import_macros_from_extern_crate( 358 fn import_macros_from_extern_crate(
357 &mut self, 359 &mut self,
358 current_module_id: LocalModuleId, 360 current_module_id: LocalModuleId,
359 import: &item_tree::ExternCrate, 361 extern_crate: &item_tree::ExternCrate,
360 ) { 362 ) {
361 log::debug!( 363 log::debug!(
362 "importing macros from extern crate: {:?} ({:?})", 364 "importing macros from extern crate: {:?} ({:?})",
363 import, 365 extern_crate,
364 self.def_map.edition, 366 self.def_map.edition,
365 ); 367 );
366 368
367 let res = self.def_map.resolve_name_in_extern_prelude( 369 let res = self.def_map.resolve_name_in_extern_prelude(&extern_crate.name);
368 &import
369 .path
370 .as_ident()
371 .expect("extern crate should have been desugared to one-element path"),
372 );
373 370
374 if let Some(ModuleDefId::ModuleId(m)) = res.take_types() { 371 if let Some(ModuleDefId::ModuleId(m)) = res.take_types() {
375 mark::hit!(macro_rules_from_other_crates_are_visible_with_macro_use); 372 mark::hit!(macro_rules_from_other_crates_are_visible_with_macro_use);
@@ -802,7 +799,7 @@ impl DefCollector<'_> {
802 let item_tree = self.db.item_tree(krate.file_id); 799 let item_tree = self.db.item_tree(krate.file_id);
803 let extern_crate = &item_tree[krate.value]; 800 let extern_crate = &item_tree[krate.value];
804 801
805 diagnosed_extern_crates.insert(extern_crate.path.segments[0].clone()); 802 diagnosed_extern_crates.insert(extern_crate.name.clone());
806 803
807 self.def_map.diagnostics.push(DefDiagnostic::unresolved_extern_crate( 804 self.def_map.diagnostics.push(DefDiagnostic::unresolved_extern_crate(
808 directive.module_id, 805 directive.module_id,