diff options
author | bors[bot] <bors[bot]@users.noreply.github.com> | 2019-04-02 11:26:43 +0100 |
---|---|---|
committer | bors[bot] <bors[bot]@users.noreply.github.com> | 2019-04-02 11:26:43 +0100 |
commit | 2d680ff93aa30a52ffe40bb7d359e19565dca733 (patch) | |
tree | 1b5fbd8228beb3d6ccd6b713c97e4c0d38783703 /crates/ra_hir/src/nameres | |
parent | bb3b159fb7d377f667732ade715cbe019da84d71 (diff) | |
parent | 49f13d3a9bb5bf3ab92c3fbf23ad79cb001b76e0 (diff) |
Merge #1089
1089: fix a panic with glob-import missing a source map r=matklad a=matklad
Co-authored-by: Aleksey Kladov <[email protected]>
Diffstat (limited to 'crates/ra_hir/src/nameres')
-rw-r--r-- | crates/ra_hir/src/nameres/raw.rs | 16 |
1 files changed, 7 insertions, 9 deletions
diff --git a/crates/ra_hir/src/nameres/raw.rs b/crates/ra_hir/src/nameres/raw.rs index 0936229ac..35cbe6655 100644 --- a/crates/ra_hir/src/nameres/raw.rs +++ b/crates/ra_hir/src/nameres/raw.rs | |||
@@ -31,15 +31,15 @@ pub struct RawItems { | |||
31 | 31 | ||
32 | #[derive(Debug, Default, PartialEq, Eq)] | 32 | #[derive(Debug, Default, PartialEq, Eq)] |
33 | pub struct ImportSourceMap { | 33 | pub struct ImportSourceMap { |
34 | map: ArenaMap<ImportId, AstPtr<ast::PathSegment>>, | 34 | map: ArenaMap<ImportId, AstPtr<ast::UseTree>>, |
35 | } | 35 | } |
36 | 36 | ||
37 | impl ImportSourceMap { | 37 | impl ImportSourceMap { |
38 | fn insert(&mut self, import: ImportId, segment: &ast::PathSegment) { | 38 | fn insert(&mut self, import: ImportId, use_tree: &ast::UseTree) { |
39 | self.map.insert(import, AstPtr::new(segment)) | 39 | self.map.insert(import, AstPtr::new(use_tree)) |
40 | } | 40 | } |
41 | 41 | ||
42 | pub(crate) fn get(&self, source: &ModuleSource, import: ImportId) -> TreeArc<ast::PathSegment> { | 42 | pub(crate) fn get(&self, source: &ModuleSource, import: ImportId) -> TreeArc<ast::UseTree> { |
43 | let file = match source { | 43 | let file = match source { |
44 | ModuleSource::SourceFile(file) => &*file, | 44 | ModuleSource::SourceFile(file) => &*file, |
45 | ModuleSource::Module(m) => m.syntax().ancestors().find_map(SourceFile::cast).unwrap(), | 45 | ModuleSource::Module(m) => m.syntax().ancestors().find_map(SourceFile::cast).unwrap(), |
@@ -256,17 +256,15 @@ impl RawItemsCollector { | |||
256 | fn add_use_item(&mut self, current_module: Option<Module>, use_item: &ast::UseItem) { | 256 | fn add_use_item(&mut self, current_module: Option<Module>, use_item: &ast::UseItem) { |
257 | let is_prelude = use_item.has_atom_attr("prelude_import"); | 257 | let is_prelude = use_item.has_atom_attr("prelude_import"); |
258 | 258 | ||
259 | Path::expand_use_item(use_item, |path, segment, alias| { | 259 | Path::expand_use_item(use_item, |path, use_tree, is_glob, alias| { |
260 | let import = self.raw_items.imports.alloc(ImportData { | 260 | let import = self.raw_items.imports.alloc(ImportData { |
261 | path, | 261 | path, |
262 | alias, | 262 | alias, |
263 | is_glob: segment.is_none(), | 263 | is_glob, |
264 | is_prelude, | 264 | is_prelude, |
265 | is_extern_crate: false, | 265 | is_extern_crate: false, |
266 | }); | 266 | }); |
267 | if let Some(segment) = segment { | 267 | self.source_map.insert(import, use_tree); |
268 | self.source_map.insert(import, segment) | ||
269 | } | ||
270 | self.push_item(current_module, RawItem::Import(import)) | 268 | self.push_item(current_module, RawItem::Import(import)) |
271 | }) | 269 | }) |
272 | } | 270 | } |