From 6eea06415d96012b01204611a65159b1a251a99d Mon Sep 17 00:00:00 2001 From: Jonas Schievink Date: Thu, 17 Sep 2020 15:28:23 +0200 Subject: Give `ExternCrate` a `Name`, not a `ModPath` --- crates/hir_def/src/item_tree/lower.rs | 4 ++-- crates/hir_def/src/item_tree/tests.rs | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) (limited to 'crates/hir_def/src/item_tree') diff --git a/crates/hir_def/src/item_tree/lower.rs b/crates/hir_def/src/item_tree/lower.rs index da62e1297..54814f141 100644 --- a/crates/hir_def/src/item_tree/lower.rs +++ b/crates/hir_def/src/item_tree/lower.rs @@ -503,7 +503,7 @@ impl Ctx { &mut self, extern_crate: &ast::ExternCrate, ) -> Option> { - let path = ModPath::from_name_ref(&extern_crate.name_ref()?); + let name = extern_crate.name_ref()?.as_name(); let alias = extern_crate.rename().map(|a| { a.name().map(|it| it.as_name()).map_or(ImportAlias::Underscore, ImportAlias::Alias) }); @@ -512,7 +512,7 @@ impl Ctx { // FIXME: cfg_attr let is_macro_use = extern_crate.has_atom_attr("macro_use"); - let res = ExternCrate { path, alias, visibility, is_macro_use, ast_id }; + let res = ExternCrate { name, alias, visibility, is_macro_use, ast_id }; Some(id(self.data().extern_crates.alloc(res))) } diff --git a/crates/hir_def/src/item_tree/tests.rs b/crates/hir_def/src/item_tree/tests.rs index 4d0a3b7e6..1a806cda5 100644 --- a/crates/hir_def/src/item_tree/tests.rs +++ b/crates/hir_def/src/item_tree/tests.rs @@ -232,7 +232,7 @@ fn smoke() { #[Attrs { entries: Some([Attr { path: ModPath { kind: Plain, segments: [Name(Text("attr_on_use"))] }, input: None }]) }] Import { path: ModPath { kind: Plain, segments: [Name(Text("b"))] }, alias: None, visibility: RawVisibilityId("pub(self)"), is_glob: true, is_prelude: false, ast_id: FileAstId::(0), index: 1 } #[Attrs { entries: Some([Attr { path: ModPath { kind: Plain, segments: [Name(Text("ext_crate"))] }, input: None }]) }] - ExternCrate { path: ModPath { kind: Plain, segments: [Name(Text("krate"))] }, alias: None, visibility: RawVisibilityId("pub(self)"), is_macro_use: false, ast_id: FileAstId::(1) } + ExternCrate { name: Name(Text("krate")), alias: None, visibility: RawVisibilityId("pub(self)"), is_macro_use: false, ast_id: FileAstId::(1) } #[Attrs { entries: Some([Attr { path: ModPath { kind: Plain, segments: [Name(Text("on_trait"))] }, input: None }]) }] Trait { name: Name(Text("Tr")), visibility: RawVisibilityId("pub(self)"), generic_params: GenericParamsId(0), auto: false, items: [TypeAlias(Idx::(0)), Const(Idx::(0)), Function(Idx::(0)), Function(Idx::(1))], ast_id: FileAstId::(2) } > #[Attrs { entries: Some([Attr { path: ModPath { kind: Plain, segments: [Name(Text("assoc_ty"))] }, input: None }]) }] -- cgit v1.2.3