diff options
author | bors[bot] <26634292+bors[bot]@users.noreply.github.com> | 2021-03-06 23:21:49 +0000 |
---|---|---|
committer | GitHub <[email protected]> | 2021-03-06 23:21:49 +0000 |
commit | 07a54f7ae451451292e3282f1e7defb4391b766f (patch) | |
tree | 296a5f2b2aff6f74eb3cc5db851d59bea5cc3889 | |
parent | c44575b4857e2d97067afab7df1f98042aa591c4 (diff) | |
parent | 6750c11df33868ffac07af4c8d4b050331663f5e (diff) |
Merge #7899
7899: Rename a few `crate_def_map`s to `def_map` r=jonas-schievink a=jonas-schievink
These could all be block `DefMap`s instead of crate-level `DefMap`s
bors r+
Co-authored-by: Jonas Schievink <[email protected]>
-rw-r--r-- | crates/hir/src/code_model.rs | 6 | ||||
-rw-r--r-- | crates/hir_def/src/body.rs | 4 | ||||
-rw-r--r-- | crates/hir_def/src/child_by_source.rs | 4 | ||||
-rw-r--r-- | crates/hir_def/src/resolver.rs | 24 |
4 files changed, 19 insertions, 19 deletions
diff --git a/crates/hir/src/code_model.rs b/crates/hir/src/code_model.rs index 7656db974..9ee4b3059 100644 --- a/crates/hir/src/code_model.rs +++ b/crates/hir/src/code_model.rs | |||
@@ -365,14 +365,14 @@ impl Module { | |||
365 | let _p = profile::span("Module::diagnostics").detail(|| { | 365 | let _p = profile::span("Module::diagnostics").detail(|| { |
366 | format!("{:?}", self.name(db).map_or("<unknown>".into(), |name| name.to_string())) | 366 | format!("{:?}", self.name(db).map_or("<unknown>".into(), |name| name.to_string())) |
367 | }); | 367 | }); |
368 | let crate_def_map = self.id.def_map(db.upcast()); | 368 | let def_map = self.id.def_map(db.upcast()); |
369 | crate_def_map.add_diagnostics(db.upcast(), self.id.local_id, sink); | 369 | def_map.add_diagnostics(db.upcast(), self.id.local_id, sink); |
370 | for decl in self.declarations(db) { | 370 | for decl in self.declarations(db) { |
371 | match decl { | 371 | match decl { |
372 | crate::ModuleDef::Function(f) => f.diagnostics(db, sink), | 372 | crate::ModuleDef::Function(f) => f.diagnostics(db, sink), |
373 | crate::ModuleDef::Module(m) => { | 373 | crate::ModuleDef::Module(m) => { |
374 | // Only add diagnostics from inline modules | 374 | // Only add diagnostics from inline modules |
375 | if crate_def_map[m.id.local_id].origin.is_inline() { | 375 | if def_map[m.id.local_id].origin.is_inline() { |
376 | m.diagnostics(db, sink) | 376 | m.diagnostics(db, sink) |
377 | } | 377 | } |
378 | } | 378 | } |
diff --git a/crates/hir_def/src/body.rs b/crates/hir_def/src/body.rs index ff4b4a0cf..16e1bac40 100644 --- a/crates/hir_def/src/body.rs +++ b/crates/hir_def/src/body.rs | |||
@@ -87,11 +87,11 @@ impl Expander { | |||
87 | module: ModuleId, | 87 | module: ModuleId, |
88 | ) -> Expander { | 88 | ) -> Expander { |
89 | let cfg_expander = CfgExpander::new(db, current_file_id, module.krate); | 89 | let cfg_expander = CfgExpander::new(db, current_file_id, module.krate); |
90 | let crate_def_map = module.def_map(db); | 90 | let def_map = module.def_map(db); |
91 | let ast_id_map = db.ast_id_map(current_file_id); | 91 | let ast_id_map = db.ast_id_map(current_file_id); |
92 | Expander { | 92 | Expander { |
93 | cfg_expander, | 93 | cfg_expander, |
94 | def_map: crate_def_map, | 94 | def_map, |
95 | current_file_id, | 95 | current_file_id, |
96 | ast_id_map, | 96 | ast_id_map, |
97 | module: module.local_id, | 97 | module: module.local_id, |
diff --git a/crates/hir_def/src/child_by_source.rs b/crates/hir_def/src/child_by_source.rs index 65d85c86a..75c2d756b 100644 --- a/crates/hir_def/src/child_by_source.rs +++ b/crates/hir_def/src/child_by_source.rs | |||
@@ -74,8 +74,8 @@ impl ChildBySource for ImplId { | |||
74 | 74 | ||
75 | impl ChildBySource for ModuleId { | 75 | impl ChildBySource for ModuleId { |
76 | fn child_by_source(&self, db: &dyn DefDatabase) -> DynMap { | 76 | fn child_by_source(&self, db: &dyn DefDatabase) -> DynMap { |
77 | let crate_def_map = self.def_map(db); | 77 | let def_map = self.def_map(db); |
78 | let module_data = &crate_def_map[self.local_id]; | 78 | let module_data = &def_map[self.local_id]; |
79 | module_data.scope.child_by_source(db) | 79 | module_data.scope.child_by_source(db) |
80 | } | 80 | } |
81 | } | 81 | } |
diff --git a/crates/hir_def/src/resolver.rs b/crates/hir_def/src/resolver.rs index e85f85e49..77ff21739 100644 --- a/crates/hir_def/src/resolver.rs +++ b/crates/hir_def/src/resolver.rs | |||
@@ -34,7 +34,7 @@ pub struct Resolver { | |||
34 | // FIXME how to store these best | 34 | // FIXME how to store these best |
35 | #[derive(Debug, Clone)] | 35 | #[derive(Debug, Clone)] |
36 | struct ModuleItemMap { | 36 | struct ModuleItemMap { |
37 | crate_def_map: Arc<DefMap>, | 37 | def_map: Arc<DefMap>, |
38 | module_id: LocalModuleId, | 38 | module_id: LocalModuleId, |
39 | } | 39 | } |
40 | 40 | ||
@@ -337,11 +337,11 @@ impl Resolver { | |||
337 | let mut traits = FxHashSet::default(); | 337 | let mut traits = FxHashSet::default(); |
338 | for scope in &self.scopes { | 338 | for scope in &self.scopes { |
339 | if let Scope::ModuleScope(m) = scope { | 339 | if let Scope::ModuleScope(m) = scope { |
340 | if let Some(prelude) = m.crate_def_map.prelude() { | 340 | if let Some(prelude) = m.def_map.prelude() { |
341 | let prelude_def_map = prelude.def_map(db); | 341 | let prelude_def_map = prelude.def_map(db); |
342 | traits.extend(prelude_def_map[prelude.local_id].scope.traits()); | 342 | traits.extend(prelude_def_map[prelude.local_id].scope.traits()); |
343 | } | 343 | } |
344 | traits.extend(m.crate_def_map[m.module_id].scope.traits()); | 344 | traits.extend(m.def_map[m.module_id].scope.traits()); |
345 | } | 345 | } |
346 | } | 346 | } |
347 | traits | 347 | traits |
@@ -349,7 +349,7 @@ impl Resolver { | |||
349 | 349 | ||
350 | fn module_scope(&self) -> Option<(&DefMap, LocalModuleId)> { | 350 | fn module_scope(&self) -> Option<(&DefMap, LocalModuleId)> { |
351 | self.scopes.iter().rev().find_map(|scope| match scope { | 351 | self.scopes.iter().rev().find_map(|scope| match scope { |
352 | Scope::ModuleScope(m) => Some((&*m.crate_def_map, m.module_id)), | 352 | Scope::ModuleScope(m) => Some((&*m.def_map, m.module_id)), |
353 | 353 | ||
354 | _ => None, | 354 | _ => None, |
355 | }) | 355 | }) |
@@ -413,21 +413,21 @@ impl Scope { | |||
413 | // def: m.module.into(), | 413 | // def: m.module.into(), |
414 | // }), | 414 | // }), |
415 | // ); | 415 | // ); |
416 | m.crate_def_map[m.module_id].scope.entries().for_each(|(name, def)| { | 416 | m.def_map[m.module_id].scope.entries().for_each(|(name, def)| { |
417 | f(name.clone(), ScopeDef::PerNs(def)); | 417 | f(name.clone(), ScopeDef::PerNs(def)); |
418 | }); | 418 | }); |
419 | m.crate_def_map[m.module_id].scope.legacy_macros().for_each(|(name, macro_)| { | 419 | m.def_map[m.module_id].scope.legacy_macros().for_each(|(name, macro_)| { |
420 | let scope = PerNs::macros(macro_, Visibility::Public); | 420 | let scope = PerNs::macros(macro_, Visibility::Public); |
421 | seen.insert((name.clone(), scope)); | 421 | seen.insert((name.clone(), scope)); |
422 | f(name.clone(), ScopeDef::PerNs(scope)); | 422 | f(name.clone(), ScopeDef::PerNs(scope)); |
423 | }); | 423 | }); |
424 | m.crate_def_map.extern_prelude().for_each(|(name, &def)| { | 424 | m.def_map.extern_prelude().for_each(|(name, &def)| { |
425 | f(name.clone(), ScopeDef::PerNs(PerNs::types(def, Visibility::Public))); | 425 | f(name.clone(), ScopeDef::PerNs(PerNs::types(def, Visibility::Public))); |
426 | }); | 426 | }); |
427 | BUILTIN_SCOPE.iter().for_each(|(name, &def)| { | 427 | BUILTIN_SCOPE.iter().for_each(|(name, &def)| { |
428 | f(name.clone(), ScopeDef::PerNs(def)); | 428 | f(name.clone(), ScopeDef::PerNs(def)); |
429 | }); | 429 | }); |
430 | if let Some(prelude) = m.crate_def_map.prelude() { | 430 | if let Some(prelude) = m.def_map.prelude() { |
431 | let prelude_def_map = prelude.def_map(db); | 431 | let prelude_def_map = prelude.def_map(db); |
432 | prelude_def_map[prelude.local_id].scope.entries().for_each(|(name, def)| { | 432 | prelude_def_map[prelude.local_id].scope.entries().for_each(|(name, def)| { |
433 | let seen_tuple = (name.clone(), def); | 433 | let seen_tuple = (name.clone(), def); |
@@ -513,8 +513,8 @@ impl Resolver { | |||
513 | self.push_scope(Scope::ImplDefScope(impl_def)) | 513 | self.push_scope(Scope::ImplDefScope(impl_def)) |
514 | } | 514 | } |
515 | 515 | ||
516 | fn push_module_scope(self, crate_def_map: Arc<DefMap>, module_id: LocalModuleId) -> Resolver { | 516 | fn push_module_scope(self, def_map: Arc<DefMap>, module_id: LocalModuleId) -> Resolver { |
517 | self.push_scope(Scope::ModuleScope(ModuleItemMap { crate_def_map, module_id })) | 517 | self.push_scope(Scope::ModuleScope(ModuleItemMap { def_map, module_id })) |
518 | } | 518 | } |
519 | 519 | ||
520 | fn push_expr_scope( | 520 | fn push_expr_scope( |
@@ -534,7 +534,7 @@ impl ModuleItemMap { | |||
534 | path: &ModPath, | 534 | path: &ModPath, |
535 | ) -> Option<ResolveValueResult> { | 535 | ) -> Option<ResolveValueResult> { |
536 | let (module_def, idx) = | 536 | let (module_def, idx) = |
537 | self.crate_def_map.resolve_path(db, self.module_id, &path, BuiltinShadowMode::Other); | 537 | self.def_map.resolve_path(db, self.module_id, &path, BuiltinShadowMode::Other); |
538 | match idx { | 538 | match idx { |
539 | None => { | 539 | None => { |
540 | let value = to_value_ns(module_def)?; | 540 | let value = to_value_ns(module_def)?; |
@@ -564,7 +564,7 @@ impl ModuleItemMap { | |||
564 | path: &ModPath, | 564 | path: &ModPath, |
565 | ) -> Option<(TypeNs, Option<usize>)> { | 565 | ) -> Option<(TypeNs, Option<usize>)> { |
566 | let (module_def, idx) = | 566 | let (module_def, idx) = |
567 | self.crate_def_map.resolve_path(db, self.module_id, &path, BuiltinShadowMode::Other); | 567 | self.def_map.resolve_path(db, self.module_id, &path, BuiltinShadowMode::Other); |
568 | let res = to_type_ns(module_def)?; | 568 | let res = to_type_ns(module_def)?; |
569 | Some((res, idx)) | 569 | Some((res, idx)) |
570 | } | 570 | } |