From f5bea9051b81f3a490c08afdb336c63c9180aae0 Mon Sep 17 00:00:00 2001 From: uHOOCCOOHu Date: Fri, 30 Aug 2019 01:56:00 +0800 Subject: Support resolution of `#[macro_use] extern crate` --- crates/ra_hir/src/nameres/raw.rs | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) (limited to 'crates/ra_hir/src/nameres/raw.rs') diff --git a/crates/ra_hir/src/nameres/raw.rs b/crates/ra_hir/src/nameres/raw.rs index 2f973359f..129b047eb 100644 --- a/crates/ra_hir/src/nameres/raw.rs +++ b/crates/ra_hir/src/nameres/raw.rs @@ -154,6 +154,7 @@ pub struct ImportData { pub(super) is_glob: bool, pub(super) is_prelude: bool, pub(super) is_extern_crate: bool, + pub(super) is_macro_use: bool, } #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] @@ -293,8 +294,14 @@ impl RawItemsCollector { let is_prelude = use_item.has_atom_attr("prelude_import"); Path::expand_use_item(&use_item, |path, use_tree, is_glob, alias| { - let import_data = - ImportData { path, alias, is_glob, is_prelude, is_extern_crate: false }; + let import_data = ImportData { + path, + alias, + is_glob, + is_prelude, + is_extern_crate: false, + is_macro_use: false, + }; self.push_import(current_module, import_data, Either::A(AstPtr::new(use_tree))); }) } @@ -307,12 +314,14 @@ impl RawItemsCollector { if let Some(name_ref) = extern_crate.name_ref() { let path = Path::from_name_ref(&name_ref); let alias = extern_crate.alias().and_then(|a| a.name()).map(|it| it.as_name()); + let is_macro_use = extern_crate.has_atom_attr("macro_use"); let import_data = ImportData { path, alias, is_glob: false, is_prelude: false, is_extern_crate: true, + is_macro_use, }; self.push_import(current_module, import_data, Either::B(AstPtr::new(&extern_crate))); } -- cgit v1.2.3