Unnamed repository; edit this file 'description' to name the repository.
Diffstat (limited to 'crates/hir-def/src/data.rs')
-rw-r--r--crates/hir-def/src/data.rs18
1 files changed, 11 insertions, 7 deletions
diff --git a/crates/hir-def/src/data.rs b/crates/hir-def/src/data.rs
index bec6627877..9c87dc31db 100644
--- a/crates/hir-def/src/data.rs
+++ b/crates/hir-def/src/data.rs
@@ -2,7 +2,7 @@
pub mod adt;
-use base_db::CrateId;
+use base_db::Crate;
use hir_expand::{
name::Name, AstId, ExpandResult, HirFileId, InFile, MacroCallId, MacroCallKind, MacroDefKind,
};
@@ -22,7 +22,7 @@ use crate::{
attr_resolution::ResolvedAttr,
diagnostics::{DefDiagnostic, DefDiagnostics},
proc_macro::{parse_macro_name_and_helper_attrs, ProcMacroKind},
- DefMap, MacroSubNs,
+ DefMap, LocalDefMap, MacroSubNs,
},
path::ImportAlias,
type_ref::{TraitRef, TypeBound, TypeRefId, TypesMap},
@@ -57,8 +57,7 @@ impl FunctionData {
item_tree[func.visibility].clone()
};
- let crate_graph = db.crate_graph();
- let cfg_options = &crate_graph[krate].cfg_options;
+ let cfg_options = krate.cfg_options(db);
let attr_owner = |idx| {
item_tree::AttrOwner::Param(loc.id.value, Idx::from_raw(RawIdx::from(idx as u32)))
};
@@ -525,7 +524,7 @@ pub struct ExternCrateDeclData {
pub name: Name,
pub alias: Option<ImportAlias>,
pub visibility: RawVisibility,
- pub crate_id: Option<CrateId>,
+ pub crate_id: Option<Crate>,
}
impl ExternCrateDeclData {
@@ -542,7 +541,7 @@ impl ExternCrateDeclData {
let crate_id = if name == sym::self_.clone() {
Some(krate)
} else {
- db.crate_graph()[krate].dependencies.iter().find_map(|dep| {
+ krate.data(db).dependencies.iter().find_map(|dep| {
if dep.name.symbol() == name.symbol() {
Some(dep.crate_id)
} else {
@@ -633,6 +632,7 @@ struct AssocItemCollector<'a> {
db: &'a dyn DefDatabase,
module_id: ModuleId,
def_map: Arc<DefMap>,
+ local_def_map: Arc<LocalDefMap>,
diagnostics: Vec<DefDiagnostic>,
container: ItemContainerId,
expander: Expander,
@@ -648,10 +648,12 @@ impl<'a> AssocItemCollector<'a> {
file_id: HirFileId,
container: ItemContainerId,
) -> Self {
+ let (def_map, local_def_map) = module_id.local_def_map(db);
Self {
db,
module_id,
- def_map: module_id.def_map(db),
+ def_map,
+ local_def_map,
container,
expander: Expander::new(db, file_id, module_id),
items: Vec::new(),
@@ -697,6 +699,7 @@ impl<'a> AssocItemCollector<'a> {
let ast_id_with_path = AstIdWithPath { path: attr.path.clone(), ast_id };
match self.def_map.resolve_attr_macro(
+ &self.local_def_map,
self.db,
self.module_id.local_id,
ast_id_with_path,
@@ -780,6 +783,7 @@ impl<'a> AssocItemCollector<'a> {
let resolver = |path: &_| {
self.def_map
.resolve_path(
+ &self.local_def_map,
self.db,
module,
path,