aboutsummaryrefslogtreecommitdiff
path: root/crates
diff options
context:
space:
mode:
Diffstat (limited to 'crates')
-rw-r--r--crates/ra_hir/src/nameres/lower.rs19
1 files changed, 16 insertions, 3 deletions
diff --git a/crates/ra_hir/src/nameres/lower.rs b/crates/ra_hir/src/nameres/lower.rs
index df87f520f..db898a782 100644
--- a/crates/ra_hir/src/nameres/lower.rs
+++ b/crates/ra_hir/src/nameres/lower.rs
@@ -8,7 +8,7 @@ use ra_arena::{Arena, RawId, impl_arena_id, map::ArenaMap};
8use rustc_hash::FxHashMap; 8use rustc_hash::FxHashMap;
9 9
10use crate::{ 10use crate::{
11 SourceItemId, Path, ModuleSource, Name, 11 SourceItemId, Path, PathKind, ModuleSource, Name,
12 HirFileId, MacroCallLoc, AsName, PerNs, Function, 12 HirFileId, MacroCallLoc, AsName, PerNs, Function,
13 ModuleDef, Module, Struct, Enum, Const, Static, Trait, Type, 13 ModuleDef, Module, Struct, Enum, Const, Static, Trait, Type,
14 ids::LocationCtx, PersistentHirDatabase, 14 ids::LocationCtx, PersistentHirDatabase,
@@ -186,8 +186,21 @@ impl LoweredModule {
186 ast::ModuleItemKind::UseItem(it) => { 186 ast::ModuleItemKind::UseItem(it) => {
187 self.add_use_item(source_map, it); 187 self.add_use_item(source_map, it);
188 } 188 }
189 ast::ModuleItemKind::ExternCrateItem(_) => { 189 ast::ModuleItemKind::ExternCrateItem(it) => {
190 // TODO 190 // Lower `extern crate x` to `use ::x`. This is kind of cheating
191 // and only works if we always interpret absolute paths in the
192 // 2018 style; otherwise `::x` could also refer to a module in
193 // the crate root.
194 if let Some(name_ref) = it.name_ref() {
195 let mut path = Path::from_name_ref(name_ref);
196 path.kind = PathKind::Abs;
197 let alias = it.alias().and_then(|a| a.name()).map(AsName::as_name);
198 self.imports.alloc(ImportData {
199 path,
200 alias,
201 is_glob: false,
202 });
203 }
191 } 204 }
192 ast::ModuleItemKind::ConstDef(it) => { 205 ast::ModuleItemKind::ConstDef(it) => {
193 if let Some(name) = it.name() { 206 if let Some(name) = it.name() {