Unnamed repository; edit this file 'description' to name the repository.
Diffstat (limited to 'crates/hir-def/src/nameres/attr_resolution.rs')
| -rw-r--r-- | crates/hir-def/src/nameres/attr_resolution.rs | 26 |
1 files changed, 14 insertions, 12 deletions
diff --git a/crates/hir-def/src/nameres/attr_resolution.rs b/crates/hir-def/src/nameres/attr_resolution.rs index d1f6ed023c..e7e96804ae 100644 --- a/crates/hir-def/src/nameres/attr_resolution.rs +++ b/crates/hir-def/src/nameres/attr_resolution.rs @@ -1,21 +1,21 @@ //! Post-nameres attribute resolution. -use base_db::CrateId; +use base_db::Crate; use hir_expand::{ + MacroCallId, MacroCallKind, MacroDefId, attrs::{Attr, AttrId, AttrInput}, inert_attr_macro::find_builtin_attr_idx, - MacroCallId, MacroCallKind, MacroDefId, + mod_path::{ModPath, PathKind}, }; -use span::SyntaxContextId; +use span::SyntaxContext; use syntax::ast; use triomphe::Arc; use crate::{ + AstIdWithPath, LocalModuleId, MacroId, UnresolvedMacro, db::DefDatabase, item_scope::BuiltinShadowMode, - nameres::path_resolution::ResolveMode, - path::{self, ModPath, PathKind}, - AstIdWithPath, LocalModuleId, MacroId, UnresolvedMacro, + nameres::{LocalDefMap, path_resolution::ResolveMode}, }; use super::{DefMap, MacroSubNs}; @@ -30,6 +30,7 @@ pub enum ResolvedAttr { impl DefMap { pub(crate) fn resolve_attr_macro( &self, + local_def_map: &LocalDefMap, db: &dyn DefDatabase, original_module: LocalModuleId, ast_id: AstIdWithPath<ast::Item>, @@ -42,6 +43,7 @@ impl DefMap { } let resolved_res = self.resolve_path_fp_with_macro( + local_def_map, db, ResolveMode::Other, original_module, @@ -105,7 +107,7 @@ pub(super) fn attr_macro_as_call_id( db: &dyn DefDatabase, item_attr: &AstIdWithPath<ast::Item>, macro_attr: &Attr, - krate: CrateId, + krate: Crate, def: MacroDefId, ) -> MacroCallId { let arg = match macro_attr.input.as_deref() { @@ -119,7 +121,7 @@ pub(super) fn attr_macro_as_call_id( }; def.make_call( - db.upcast(), + db, krate, MacroCallKind::Attr { ast_id: item_attr.ast_id, @@ -135,16 +137,16 @@ pub(super) fn derive_macro_as_call_id( item_attr: &AstIdWithPath<ast::Adt>, derive_attr_index: AttrId, derive_pos: u32, - call_site: SyntaxContextId, - krate: CrateId, - resolver: impl Fn(&path::ModPath) -> Option<(MacroId, MacroDefId)>, + call_site: SyntaxContext, + krate: Crate, + resolver: impl Fn(&ModPath) -> Option<(MacroId, MacroDefId)>, derive_macro_id: MacroCallId, ) -> Result<(MacroId, MacroDefId, MacroCallId), UnresolvedMacro> { let (macro_id, def_id) = resolver(&item_attr.path) .filter(|(_, def_id)| def_id.is_derive()) .ok_or_else(|| UnresolvedMacro { path: item_attr.path.as_ref().clone() })?; let call_id = def_id.make_call( - db.upcast(), + db, krate, MacroCallKind::Derive { ast_id: item_attr.ast_id, |